├── Horizontal Axis Wind Turbine Evaluation ├── task_4a.m ├── Read_Me.md ├── project_4.pdf ├── task_4b.m ├── task_1.m ├── task_1_corr.m └── task_3.m ├── Solar Hybrid Power Design and Analysis ├── task_5A.fig ├── Project2.pdf ├── READ_ME.md ├── task_1.m ├── task_2.m ├── task_3 (1).m ├── task_3_2.m ├── task_6b.m ├── task_4_2.m ├── task_4 (1).m ├── task_5b.m ├── task_5.m └── task_6.m ├── Gas Turbine System Performance Evaluation ├── Project_3.pdf ├── root_finder.m ├── READ_ME.md ├── task_3.m ├── task_2.m ├── task_1.m ├── task_2a.m ├── task_5b.m ├── task_5.m └── task_4.m ├── Solar Collector System Design and Analysis ├── project.pdf ├── README.md ├── task_1.m ├── task_4b_parallel.m ├── task_4b_series.m ├── task_2.m ├── task_5a.m ├── task_3.m ├── task_4a_parallel.m ├── task_4a.m └── task_4.m └── README.md /Horizontal Axis Wind Turbine Evaluation/task_4a.m: -------------------------------------------------------------------------------- 1 | P = 1.5468e+03; 2 | V = 12; 3 | I = P/V; -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/Read_Me.md: -------------------------------------------------------------------------------- 1 | Evaluate the operating characteristics of a horizontal axis wind turbine in a power generation system. 2 | 3 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_5A.fig: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deep-daya/Energy-Conversion-Principles-Projects/HEAD/Solar Hybrid Power Design and Analysis/task_5A.fig -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/Project2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deep-daya/Energy-Conversion-Principles-Projects/HEAD/Solar Hybrid Power Design and Analysis/Project2.pdf -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/Project_3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deep-daya/Energy-Conversion-Principles-Projects/HEAD/Gas Turbine System Performance Evaluation/Project_3.pdf -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/project_4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deep-daya/Energy-Conversion-Principles-Projects/HEAD/Horizontal Axis Wind Turbine Evaluation/project_4.pdf -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/project.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/deep-daya/Energy-Conversion-Principles-Projects/HEAD/Solar Collector System Design and Analysis/project.pdf -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/task_4b.m: -------------------------------------------------------------------------------- 1 | function [fract]=task_4b(I_L, I_cell, V_rev) 2 | V_L = V_rev - 0.11 - 0.041*I_L; 3 | V_cell = V_rev + 0.11 + 0.041*I_cell; 4 | fract = V_L/V_cell; 5 | end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Energy Conversion Principles Projects 2 | 1. Solar Collector System Design and Analysis 3 | 2. Solar Hybrid Power Design and Analysis 4 | 3. Horizontal Axis Wind Turbine Evaluation 5 | 4. Gas Turbine System Performance Evaluation 6 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/READ_ME.md: -------------------------------------------------------------------------------- 1 | The overarching purpose of this project was to analyze the performance of a concentrating 2 | photovoltaic (PV) system that also captures waste heat from the PV cell to produce power, a 3 | so-called hybrid power system in 6 steps. This system was proposed for a spacecraft designed to 4 | transport astronauts from the earth to the moon and back. 5 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_1.m: -------------------------------------------------------------------------------- 1 | T = 30; 2 | %linear curve fit to find the relationship b/t T and V_oc, 5 points are 3 | %estimated based on the graph provided 4 | 5 | T_p=[293;303;313;333;353]; 6 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 7 | T_pv = horzcat(T_p,ones(5,1)); 8 | co = T_pv\V_oc; 9 | V_L = [(T+273), 1]*co; 10 | 11 | %constants 12 | Kb= 1.38*10^-23; 13 | qe= 1.6*10^-19; 14 | x=V_L*qe/(Kb*(T+273)); 15 | I0_Iv = 1/(exp(x)-1); 16 | I0_Iv 17 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/root_finder.m: -------------------------------------------------------------------------------- 1 | function [T3_f, cp23] = root_finder(Qs, T2_r, n_dot_air) 2 | syms cp_23 T3 3 | eqn = [cp_23 == 28.11+ 0.1967*10^(-2)*(0.5*(T3+T2_r)) + 0.4802*10^(-5)*(0.5*(T3+T2_r))^2 - 1.966*10^(-9)*(0.5*(T3+T2_r))^3,T3 == Qs/(n_dot_air*cp_23)+T2_r]; 4 | v = solve(eqn, [cp_23, T3]); 5 | cp_23= vpa(v.cp_23); 6 | T3 = vpa(v.T3); 7 | p = find(T3 >800& T3 < 1500); 8 | T3_f = double(T3(p)); 9 | cp23 = double(cp_23(p)); 10 | end 11 | -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/README.md: -------------------------------------------------------------------------------- 1 | Designed a program to calculate the incident direct radiation per square meter of a solar collector for a specified time, latitude, day of year, solar azimuth angle while determining it's efficiency. Implemented the program to determine the specifications of a design target while including real-world factors such as shading, dust and cloud cover. Calculated the reduction in CO2 emissions from a natural gas plant if the collector was used. 2 | -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/task_1.m: -------------------------------------------------------------------------------- 1 | function [w_tur, eta]=task_1(rou, v1, alpha, Cl, n, Kh,sigma, rh, R,omega ) 2 | 3 | lambda = omega*R/v1; 4 | rh_bar= rh/R; 5 | a=2*R/3/lambda; 6 | b=1-rh_bar; 7 | 8 | syms r; 9 | w = Cl/3*(n*rou*lambda*Kh*(v1^2)/R) * ((r^2+a^2)^(0.5) *((r^2+a^2)*(lambda*v1/3/R*(1+sigma*rh_bar/b) - sigma*r*lambda*v1/4/(R^2)/b) + log(r+(r^2+a^2)^(0.5))*(2*sigma*R^2*v1)/(81*lambda^3*b))); 10 | w_b = 16/27*0.5*rou*v1^3*pi *r^2; 11 | 12 | %turbine work 13 | ans = subs(w,r, [rh R]); 14 | w_tur =double(ans(2)-ans(1)); 15 | 16 | %betz work 17 | ans1 = subs(w_b,r, [rh R]); 18 | w_betz = double(ans1(2)-ans1(1)); 19 | 20 | eta=w_tur/w_betz; 21 | 22 | c=rh:0.001:R; 23 | xi = alpha*pi/180 - atan(2*R./3./lambda./c); 24 | xi1=xi*180/pi; 25 | plot(c, xi1) 26 | xlabel('Radius (m)') 27 | ylabel('Setup Angle (Degrees)') 28 | title('Setup Angle vs Radius') 29 | 30 | 31 | 32 | end 33 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/READ_ME.md: -------------------------------------------------------------------------------- 1 | Analyzed the hybrid solar fossil-fuel gas turbine system, to construct a computer simulation of the performance of the system. Developed a program that found the value of the molar air-to-fuel ratio α that would result in a product temperature Tp for specified reactant temperature Tr. Designed a program to compute the exit condition from the compressor and the work required per kilogram of air using a constant cˆ p and cˆ v analysis. Derived relations for the mole fraction of each exhaust gas species as a function of molar air to fuel ratio α. Used this to design a program to compute cˆ p, prod for the product gas mixture as the mole-fraction weighted average of the cˆ p values for the individual species. Combined the steps to complete the simulation of the cycle and analyze its overall performance. Altered Qs input and gamma to see the change in efficiency, power input, and heat input. 2 | 3 | -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/task_1_corr.m: -------------------------------------------------------------------------------- 1 | function [w_tur, eta]=task_1(rou, v1, alpha, Cl, n, Kh,sigma, rh, R,omega ) 2 | 3 | lambda = omega*R/v1; 4 | rh_bar= rh/R; 5 | a=2*R/3/lambda; 6 | b=1-rh_bar; 7 | 8 | syms r; 9 | w = Cl/3*(n*rou*lambda*Kh*(v1^2)/R) * ((r^2+a^2)^(0.5) *((r^2+a^2)*(lambda*v1/3/R*(1+sigma*rh_bar/b) - sigma*r*lambda*v1/4/(R^2)/b) + log(r+(r^2+a^2)^(0.5))*(2*sigma*R^2*v1)/(81*lambda^3*b))); 10 | w_b = 16/27*0.5*rou*v1^3*pi *r^2; 11 | 12 | %turbine work 13 | ans = subs(w,r, [rh R]); 14 | w_tur =double(ans(2)-ans(1)); 15 | 16 | %betz work 17 | ans1 = subs(w_b,r, [rh R]); 18 | w_betz = double(ans1(2)-ans1(1)); 19 | 20 | eta=w_tur/w_betz; 21 | 22 | c=rh:0.001:R; 23 | xi = alpha*pi/180 - atan(2*R./3./lambda./c); 24 | xi1=xi*180/pi; 25 | plot(c, xi1) 26 | title ('Setup Angle vs. Radius'); 27 | xlabel('Radius (m)', 'FontWeight','bold'); 28 | ylabel('Setup Angle (degrees)', 'FontWeight','bold'); 29 | 30 | 31 | end 32 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_3.m: -------------------------------------------------------------------------------- 1 | function [y_h20, y_co2, y_n2, y_o2, cp_prod, cp_air] = task_3(Tp, gamma,alpha) 2 | 3 | %based on the equation given on page1 4 | n_ex = (3.76*alpha/4.76) + (alpha/4.76-3*gamma-2) + (2+2*gamma) + (1+2*gamma); 5 | y_h20 = (2+2*gamma) / n_ex; 6 | y_co2 = (1+2*gamma)/ n_ex; 7 | y_n2 = ((3.76*alpha)/4.76)/ n_ex; 8 | y_o2 = ((alpha/4.76)-3*gamma-2) / n_ex; 9 | 10 | %cp of each product 11 | cp_o2 = 25.48 + 1.520*10^(-2)*Tp - 0.7155*10^(-5)*(Tp)^2 + 1.312*10^(-9)*(Tp)^3; 12 | cp_h20 = 32.24 + 0.1923*10^(-2)*Tp + 1.0551*10^(-5)*(Tp)^2 - 3.595*10^(-9)*(Tp)^3; 13 | cp_co2 = 22.26 + 5.981*10^(-2)*Tp - 3.501*10^(-5)*(Tp)^2 + 7.469*10^(-9)*(Tp)^3; 14 | cp_n2 = 28.9 - 0.1571*10^(-2)*Tp + 0.8081*10^(-5)*(Tp)^2 - 2.873*10^(-9)*(Tp)^3; 15 | 16 | %cp of whole product 17 | cp_prod = y_h20*cp_h20 + y_co2*cp_co2 + y_n2*cp_n2 + y_o2*cp_o2; 18 | 19 | cp_air = 28.11+ 0.1967*10^(-2)*( Tp) + 0.4802*10^(-5)*( Tp)^2 - 1.966*10^(-9)*( Tp)^3; 20 | end 21 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_2.m: -------------------------------------------------------------------------------- 1 | function [T2_f, W] =task_2(T1,P1,P2, eta_comp) 2 | 3 | %guess T2=T2_g to be average, Tf was taken from task 1 4 | Tf=1900; 5 | T2_g=Tf; 6 | R=8.314; 7 | 8 | err=1; 9 | while err >0.2 10 | T_avg = 0.5*(T1+T2_g); 11 | cp = 28.11+ 0.1967*10^(-2)*(T_avg) + 0.4802*10^(-5)*(T_avg)^2 - 1.966*10^(-9)*(T_avg)^3; 12 | cv = cp-R; 13 | k= cp/cv; 14 | %first T2 to calculate difference 15 | T2 = T1* (1+((P2/P1)^((k-1)/k) -1)/eta_comp); 16 | %try to get second T2 for difference calculation 17 | T_avg_1 = 0.5*(T1+T2); 18 | cp_1 = 28.11+ 0.1967*10^(-2)*( T_avg_1) + 0.4802*10^(-5)*( T_avg_1)^2 - 1.966*10^(-9)*( T_avg_1)^3; 19 | cv_1 = cp_1-R; 20 | k_1= cp_1/cv_1; 21 | T2_1 = T1* (1+((P2/P1)^((k_1-1)/k_1) -1)/eta_comp); 22 | err= abs(T2-T2_1); 23 | if err <= 0.2 24 | break 25 | else 26 | T2_g = T2; 27 | end 28 | end 29 | T2_f = T2_g; 30 | H2= 0 + cp * (T2_f-T1)/(28.97); 31 | %W=H2-H1, and H1=0 32 | W=H2; 33 | 34 | end 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_2.m: -------------------------------------------------------------------------------- 1 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 2 | %same as task_1 3 | T_p=[293;303;313;333;353]; 4 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 5 | T_pv = horzcat(T_p,ones(5,1)); 6 | co = T_pv\V_oc; 7 | V_oc = [(T+273), 1]*co; 8 | %constants 9 | Kb= 1.38*10^-23; 10 | qe= 1.6*10^-19; 11 | L=V_oc*qe/(Kb*(T+273)); 12 | I0_Iv = 1/(exp(L)-1); 13 | A_pv = (Ly*Lz)/10000; 14 | %I_L = V_L / R_L; 15 | %Eta = V_L * I_L / (p * A_pv); 16 | % finding I_L 17 | P_0= Id*rc*A_pv; 18 | 19 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 20 | 21 | syms I_L 22 | 23 | fun= @(x) (x.^2)./(exp(x)-1); 24 | 25 | xmin = qe*Vg/(Kb* 5778); 26 | 27 | inte = integral(fun,xmin,Inf); 28 | 29 | phi_g = phi * 0.416 * inte; 30 | 31 | Iv = phi_g * qe * A_pv; 32 | 33 | I0 =Iv * I0_Iv; 34 | %solving for I_L 35 | eqn= (Kb*(T+273)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 36 | I_L_sol = solve(eqn,I_L); 37 | I_L = double(subs(I_L_sol)); 38 | %solving for V_L and then Efficiency 39 | V_L = I_L*R_L; 40 | Eta = V_L*I_L/ (Id*rc*A_pv); 41 | P = I_L*V_L; 42 | Q_pv = -V_L*I_L + P_0; 43 | end 44 | -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_1.m: -------------------------------------------------------------------------------- 1 | % Setting up variables and values 2 | t= 13; 3 | lambda=37.9; 4 | d= 120; 5 | zeta= 200; 6 | epsilon = 36; 7 | % Using equations 2, 3, 6, 7, 8, 9 and solving them to get different 8 | % parameters 9 | %Finding Hour angle 10 | alpha = 15*(t-12); 11 | %Finding Declination Angle 12 | del = 23.44*sind((360/365.25)*(d-80)); 13 | %Finding Zenith angle 14 | cos_zen_ang= sind(lambda)*sind(del)+ cosd(lambda)*cosd(del)*cosd(alpha); 15 | chi = acosd(cos_zen_ang); 16 | %finding Solar Azimuth angle 17 | tan_xi = sind(alpha) /((sind(lambda)*cosd(alpha)-cosd(lambda)*tand(del))); 18 | if alpha >= 0 && tan_xi >= 0 19 | xi = 180 + atand(tan_xi); 20 | elseif alpha >= 0 && tan_xi < 0 21 | xi = 360 + atand(tan_xi); 22 | elseif alpha < 0 && tan_xi >= 0 23 | xi = atand(tan_xi); 24 | elseif alpha<0 && tan_xi < 0 25 | xi = 180+ atand(tan_xi); 26 | end 27 | A = 1310; 28 | B = 0.18; 29 | %Finding Direct Normal Radiation 30 | I_dn = A*exp(-B/(sind(90-chi))); 31 | %Finding Direct Solar Flux per unit area 32 | Id = I_dn*(cos_zen_ang*cosd(epsilon)+sind(epsilon)*sind(chi)*cosd(xi - zeta)); 33 | Id -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_4b_parallel.m: -------------------------------------------------------------------------------- 1 | %Setting up the parameters, constants 2 | t_0 = 10; 3 | t_i = 16; 4 | T_i = 14; 5 | d =120; 6 | Ac = 3.25; 7 | alpha_c =0.85; 8 | tau_g = 0.89; 9 | h_convo = 7; 10 | del_g = 0.007; 11 | kg = 1.3; 12 | h_convi = 3.1; 13 | del_ins = .06; 14 | k_ins = 0.045; 15 | cp = 4186; 16 | m_max= (350*3.78541)/21600; % max m kg/s if the total flow is 350 gallons over 6 hrs 17 | zet = (0:20:360); 18 | eps = (0:10:180); 19 | T_out= []; 20 | comb = []; 21 | %Finding the T_out for different zeta and epsilon configurations 22 | for j= 1:length(zet) 23 | y(j)=zet(j); 24 | for k=1:length(eps) 25 | z(k)=eps(k); 26 | [T_out(:,end+1),Id_ncol] = task_4(t_0,t_i,d,y(j),z(k),T_i,m_max); 27 | comb(:,end+1) = [y(j),z(k),Id_ncol]; 28 | end 29 | end 30 | %Finding average temperature 31 | for i = 1:length(T_out(1,:)) 32 | T_avg(i) = sum(T_out(:,i))/length(T_out); 33 | end; 34 | %Finding closest avg temp to 65C 35 | I = find(T_avg<66 & T_avg>64); 36 | [M,L] = min(abs(T_avg(I)-65)); 37 | %Finding mass flow rate, zeta, eps 38 | m_total=(3*comb(3,I(L))*21600)/3.78541; 39 | zeta_parallel = comb(1,I(L)); 40 | eps_paralled = comb(2,I(L)); 41 | %returning max avg temp 42 | max(T_avg); -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_1.m: -------------------------------------------------------------------------------- 1 | function [alpha] = task_1(Tp, Tr, gamma) 2 | 3 | %the heat of formation from table, [kJ/kmol] 4 | h0_c3h8 =-103850; 5 | h0_ch4 = -74850; 6 | h0_o2 = 0; 7 | h0_h2o = -241820; 8 | h0_co2 = -393520; 9 | h0_n2 = 0; 10 | 11 | %specific heat from table, [kJ/kmol*K] 12 | T_avg = 0.5 * (Tr+Tp); 13 | cp_c3h8 = -4.04 + 30.48*10^(-2)*T_avg - 15.72*10^(-5)*(T_avg)^2 + 31.74*10^(-9)*(T_avg)^3; 14 | cp_ch4 = 19.89 + 5.024*10^(-2)*T_avg +1.269*10^(-5)*(T_avg)^2 - 11.01*10^(-9)*(T_avg)^3; 15 | cp_o2 = 25.48 + 1.520*10^(-2)*T_avg - 0.7155*10^(-5)*(T_avg)^2 + 1.312*10^(-9)*(T_avg)^3; 16 | cp_h2o = 32.24 + 0.1923*10^(-2)*T_avg + 1.055*10^(-5)*(T_avg)^2 - 3.595*10^(-9)*(T_avg)^3; 17 | cp_co2 = 22.26 + 5.981*10^(-2)*T_avg - 3.501*10^(-5)*(T_avg)^2 + 7.469*10^(-9)*(T_avg)^3; 18 | cp_n2 = 28.9 - 0.1571*10^(-2)*T_avg + 0.8081*10^(-5)*(T_avg)^2 - 2.873*10^(-9)*(T_avg)^3; 19 | 20 | %enthalpy 21 | h_c3h8 =h0_c3h8 + cp_c3h8 *(Tr-298.15); 22 | h_ch4 = h0_ch4 + cp_ch4 * (Tr-298.15); 23 | h_o2_i = h0_o2 + cp_o2 * (Tr-298.15); 24 | h_o2_o = h0_o2 + cp_o2 * (Tp-298.15); 25 | h_h2o = h0_h2o + cp_h2o * (Tp-298.15); 26 | h_co2 = h0_co2 + cp_co2 * (Tp-298.15); 27 | h_n2_i = h0_n2 + cp_n2 * (Tr-298.15); 28 | h_n2_o = h0_n2 + cp_n2 * (Tp-298.15); 29 | 30 | alpha = 4.76*(-gamma*h_c3h8 - (1-gamma)*h_ch4 - (3*gamma+2)*h_o2_o + (2+2*gamma)*h_h2o + (1+2*gamma)*h_co2)/(h_o2_i + 3.76*h_n2_i - 3.76*h_n2_o - h_o2_o); 31 | 32 | end 33 | -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_4b_series.m: -------------------------------------------------------------------------------- 1 | %setting up parameters. 2 | t_0 = 10; 3 | t_i = 16; 4 | T_i = 14; 5 | d =120; 6 | Ac = 3.25; 7 | alpha_c =0.85; 8 | tau_g = 0.89; 9 | h_convo = 7; 10 | del_g = 0.007; 11 | kg = 1.3; 12 | h_convi = 3.1; 13 | del_ins = .06; 14 | k_ins = 0.045; 15 | cp = 4186; 16 | m_max= (350*3.78541)/21600; % max m kg/s if the total flow is 350 gallons over 6 hrs 17 | t=linspace(t_0,t_i,216); 18 | zet = (0:20:360); 19 | eps = (0:10:180); 20 | T_out_ser = []; 21 | T_out_2 = []; 22 | T_out_3 = []; 23 | comb_2 = []; 24 | T_avg_2=[]; 25 | %FInding the temp out of the third 26 | %series arrangement 27 | for j= 1:length(zet) 28 | y(j)=zet(j); 29 | for k=1:length(eps) 30 | z(k)=eps(k); 31 | [T_out_ser(:,end+1),Id_ncol] = task_4(t_0,t_i,d,y(j),z(k),T_i,m_max); 32 | [T_out_2(:,end+1),Id_ncol_2] = task_4(t_0,t_i,d,y(j),z(k),T_out_ser(:,end),m_max); 33 | [T_out_3(:,end+1),Id_ncol_3] = task_4(t_0,t_i,d,y(j),z(k),T_out_2(:,end),m_max); 34 | comb_2(:,end+1) = [y(j),z(k),Id_ncol]; 35 | end; 36 | end; 37 | for i = 1:length(T_out_3(1,:)) 38 | T_avg_2(i) = sum(T_out_3(:,i))/length(T_out_3); 39 | end; 40 | %Finding closest temp to 65, mass flow rate and zeta, and epsilon. 41 | a= find(T_avg_2<66 & T_avg_2>64); 42 | [m,l] = min(abs(T_avg_2(a)-65)); 43 | m_total_ser=(comb_2(3,a(l))*21600)/3.78541; 44 | zeta_series = comb_2(1,a(l)); 45 | eps_series = comb_2(2,a(l)); 46 | %returning max temp 47 | max(T_avg_2); 48 | 49 | -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_2.m: -------------------------------------------------------------------------------- 1 | %Setting up parameters 2 | t_0= 10; 3 | t_i=16; 4 | lambda=37.9; 5 | d= 120; 6 | zeta= 200; 7 | epsilon = 36; 8 | %Setting up time as a per second change 9 | t = t_0:(1/3600):t_i; 10 | %Setting up Parameters from task 1 11 | for i = 1:length(t) 12 | alpha(i) = 15*(t(i)-12); 13 | end 14 | del = 23.44*sind((360/365.25)*(d-80)); 15 | cos_zen_ang = zeros(0,length(alpha)); 16 | chi = zeros(0,length(alpha)); 17 | tan_xi = zeros(0,length(alpha)); 18 | for i = 1:length(t) 19 | cos_zen_ang(i)= sind(lambda)*sind(del)+ cosd(lambda)*cosd(del)*cosd(alpha(i)); 20 | chi(i) = acosd(cos_zen_ang(i)); 21 | end 22 | for i = 1:length(t) 23 | tan_xi(i) = (sind(alpha(i))) /((sind(lambda)*cosd(alpha(i))-cosd(lambda)*tand(del))); 24 | end 25 | for i = 1:length(t) 26 | if alpha(i) > 0 && tan_xi(i) > 0 27 | xi(i) = 180 + atand(tan_xi(i)); 28 | elseif alpha(i) > 0 && tan_xi(i) < 0 29 | xi(i) = 360 + atand(tan_xi(i)); 30 | elseif alpha(i) < 0 && tan_xi(i) >0 31 | xi(i) = atand(tan_xi(i)); 32 | elseif alpha(i)<0 && tan_xi(i) < 0 33 | xi(i) = 180+ atand(tan_xi(i)); 34 | end 35 | end 36 | A = 1310; 37 | B = 0.18; 38 | for i = 1:length(chi) 39 | I_dn(i) = A*exp(-B/(sind(90-chi(i)))); 40 | end 41 | %Finding Direct solar flux per unit area per second 42 | for i = 1:length(t) 43 | Id_i(i) = I_dn(i)*(cos_zen_ang(i)*cosd(epsilon)+sind(epsilon).*sind(chi(i))*cosd(xi(i) - zeta)); 44 | end 45 | %Using the trapezoidal rule for finding the total Incident radiation 46 | Id_f = 0; 47 | for i = 1:length(Id_i)-1 48 | Id_f = ((((t_i-t_0)*3600)/length(t))*(((Id_i(i)) + Id_i(i+1))/2))+ Id_f; 49 | end 50 | Id_f -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_2a.m: -------------------------------------------------------------------------------- 1 | function [T2_f, W] =task_2a(T1,P1,P2, eta_comp, T_guess, gamma,n_prod,alpha) 2 | 3 | %guess T2=T2_g to be average, Tf was taken from task 1 4 | T2_g=T_guess; 5 | R=8.314; 6 | 7 | err=1; 8 | while err >0.2 9 | T_avg = 0.5*(T1+T2_g); 10 | [~, ~, ~, ~, cp_prod, ~] = task_3(T_avg, gamma,alpha); 11 | cp = cp_prod; 12 | cv = cp-R; 13 | k= cp/cv; 14 | %first T2 to calculate difference 15 | %T2 = T1* (1+((P1/P2)^((k-1)/k) -1)/eta_comp); 16 | T2= T1*(1+ eta_comp*((P1/P2)^((k-1)/k)-1)); 17 | err= abs(T2-T2_g); 18 | if err <= 0.2 19 | break 20 | else 21 | T2_g = T2; 22 | end 23 | end 24 | T2_f = T2_g; 25 | H2= 0 - cp * (T2_f-T1)*n_prod; 26 | %W=H2-H1, and H1=0 27 | W=H2; 28 | 29 | end 30 | function [y_h20, y_co2, y_n2, y_o2, cp_prod, cp_air] = task_3(Tp, gamma,alpha) 31 | 32 | %based on the equation given on page1 33 | n_ex = (3.76*alpha/4.76) + (alpha/4.76-3*gamma-2) + (2+2*gamma) + (1+2*gamma); 34 | y_h20 = (2+2*gamma) / n_ex; 35 | y_co2 = (1+2*gamma)/ n_ex; 36 | y_n2 = (3.76*alpha/4.76)/ n_ex; 37 | y_o2 = (alpha/4.76-3*gamma-2) / n_ex; 38 | 39 | %cp of each product 40 | cp_o2 = 25.48 + 1.520*10^(-2)*Tp - 0.7155*10^(-5)*(Tp)^2 + 1.312*10^(-9)*(Tp)^3; 41 | cp_h20 = 32.24 + 0.1923*10^(-2)*Tp + 1.0551*10^(-5)*(Tp)^2 - 3.595*10^(-9)*(Tp)^3; 42 | cp_co2 = 22.26 + 5.981*10^(-2)*Tp - 3.501*10^(-5)*(Tp)^2 + 7.469*10^(-9)*(Tp)^3; 43 | cp_n2 = 28.9 - 0.1571*10^(-2)*Tp + 0.8081*10^(-5)*(Tp)^2 - 2.873*10^(-9)*(Tp)^3; 44 | 45 | %cp of whole product 46 | cp_prod = y_h20*cp_h20 + y_co2*cp_co2 + y_n2*cp_n2 + y_o2*cp_o2; 47 | 48 | cp_air = 28.11+ 0.1967*10^(-2)*( Tp) + 0.4802*10^(-5)*( Tp)^2 - 1.966*10^(-9)*( Tp)^3; 49 | end -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_5a.m: -------------------------------------------------------------------------------- 1 | %Setting up parameters,constants 2 | t_0 = 11; 3 | t_i = 16; 4 | T_i = 16; 5 | d =1:14:365; 6 | Ac = 3.25; 7 | alpha_c =0.85; 8 | tau_g = 0.89; 9 | h_convo = 7; 10 | del_g = 0.007; 11 | kg = 1.3; 12 | h_convi = 3.1; 13 | del_ins = .06; 14 | k_ins = 0.045; 15 | cp = 4186; 16 | m_in = 0.0286; % mini m kg/s 17 | zet = (200); 18 | eps = 30; 19 | T_out_ser = []; 20 | T_out_3 = []; 21 | T_out_2 = []; 22 | T_avg_out = []; 23 | comb_2 = []; 24 | Id_ncol=[]; 25 | Id_ncol_1=[]; 26 | Id_ncol_2=[]; 27 | %Using series to find T_out_3 28 | for i= 1:length(d) 29 | [T_out_ser(:,end+1),Id_ncol(:,end+1)]= task_4(t_0,t_i,d(i),zet,eps,T_i,m_in); 30 | [T_out_2(:,end+1),Id_ncol_1(:,end+1)]= task_4(t_0,t_i,d(i),zet,eps,T_out_ser,m_in); 31 | [T_out_3(:,end+1),Id_ncol_2(:,end+1)]= task_4(t_0,t_i,d(i),zet,eps,T_out_2,m_in); 32 | end 33 | %Finding the total energy and lost energy for the 27 days 34 | for i = 1:length(Id_ncol) 35 | True_Energy(i)=(Id_ncol(i)+Id_ncol_1(i)+Id_ncol_2(i))*0.648; 36 | Lost_energy(i) =(Id_ncol(i)+Id_ncol_1(i)+Id_ncol_2(i))*0.352; 37 | end 38 | %Finding total energy lost for the year using trapezoidal rule 39 | Total_lost_energy = 0; 40 | for i =1:length(d)-1 41 | Total_lost_energy = ((365-1)/27)*(Lost_energy(i)+Lost_energy(i+1))/2+Total_lost_energy; 42 | end 43 | %Finding the amount of natural gas amount burned at 90% eff., and T_Avg 44 | Natural_gas = []; 45 | for i = 1:length(T_out_3(1,:)) 46 | T_avg_out(i) = sum(T_out_3(:,i))/length(T_out_3); 47 | Natural_gas(end+1)= (163.337*4186*(65-T_avg_out(i)))/(0.9*50050*1000); 48 | end 49 | Total_CH4 = 0; 50 | %Finding total amount burned over year 51 | for i =1:length(d)-1 52 | Total_CH4 = ((365-1)/27)*((Natural_gas(i+1)+Natural_gas(i))/2)+Total_CH4; 53 | end 54 | %Finding total cost of methane burned 55 | Total_cost = Total_CH4*9.45/(28.3168*.656) -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_3.m: -------------------------------------------------------------------------------- 1 | function [n_colll,Id] = task_3(Ac,cp,m,t_0,t_i,lambda,d, zeta,epsilon, alpha_c, tau_g, h_convo,del_g,kg,h_convi, del_ins, k_ins, T_i,T_a) 2 | %Setting up time and given variables 3 | t = t_0:1/3600:t_i; 4 | for i = 1:length(t) 5 | alpha(i) = 15*(t(i)-12); 6 | end 7 | del = 23.44*sind((360/365.25)*(d-80)); 8 | cos_zen_ang = zeros(0,length(alpha)); 9 | for i = 1:length(t) 10 | cos_zen_ang(i)= sind(lambda)*sind(del)+ cosd(lambda)*cosd(del)*cosd(alpha(i)); 11 | chi(i) = acosd(cos_zen_ang(i)); 12 | end 13 | for i = 1:length(t) 14 | tan_xi(i) = sind(alpha(i)) /((sind(lambda)*cosd(alpha(i))-cosd(lambda)*tand(del))); 15 | end 16 | for i = 1:length(t) 17 | if alpha(i) > 0 && tan_xi(i) > 0 18 | xi(i) = 180 + atand(tan_xi(i)); 19 | elseif alpha(i) > 0 && tan_xi(i) < 0 20 | xi(i) = 360 + atand(tan_xi(i)); 21 | elseif alpha(i) < 0 && tan_xi(i) >0 22 | xi(i) = atand(tan_xi(i)); 23 | elseif alpha(i)<0 && tan_xi(i) < 0 24 | xi(i) = 180+ atand(tan_xi(i)); 25 | end 26 | end 27 | A = 1310; 28 | B = 0.18; 29 | for i = 1:length(chi) 30 | I_dn(i) = A*exp(-B/(sind(90-chi(i)))); 31 | Id_i(i) = I_dn(i)*(cos_zen_ang(i)*cosd(epsilon)+sind(epsilon)*sind(chi(i))*cosd(xi(i) - zeta)); 32 | end 33 | %Finding the conductance, heat removal factors and collector efficiencies 34 | %per second 35 | U_loss = ((1/(h_convo*Ac) + del_g/(kg*Ac) + 1/(h_convi*Ac))^-1 + (1/(h_convo*Ac) + (del_ins/(k_ins*Ac)))^-1)/Ac; 36 | F_r = (1- exp(-Ac*U_loss/(m*cp)))/(Ac*U_loss/(m*cp)); 37 | Id = 0; 38 | for i = 1:length(t)-1 39 | Id = (((t_i-t_0)*3600/length(t))*(((Id_i(i)) + Id_i(i+1))/2))+Id; 40 | end 41 | n_coll = F_r*(tau_g *alpha_c - (U_loss./Id_i)*(T_i-T_a)); 42 | %Finding total energy absorbed in watts 43 | Id_ncol = 0; 44 | for i = 1:length(t)-1 45 | Id_ncol = (((t_i-t_0)*3600/length(t))*(((Id_i(i))*n_coll(i) + n_coll(i)*Id_i(i+1))/2))+Id_ncol; 46 | end 47 | n_colll = Id_ncol/Id; -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_4a_parallel.m: -------------------------------------------------------------------------------- 1 | %Setting up parameters as in previous tasks. 2 | t_0 = 10; 3 | t_i = 16; 4 | T_i = 16; 5 | d =120; 6 | Ac = 3.25; 7 | alpha_c =0.85; 8 | tau_g = 0.89; 9 | h_convo = 7; 10 | del_g = 0.007; 11 | kg = 1.3; 12 | h_convi = 3.1; 13 | del_ins = .06; 14 | k_ins = 0.045; 15 | cp = 4186; 16 | %Setting up data points for different m measurements. 17 | m_min = 0.0267; % mini m kg/s 18 | m_max= (350*3.78541)/21600; % max m kg/s if the total flow is 350 gallons over 6 hrs 19 | m_range= linspace(m_min,m_max,19); 20 | %Setting up data points for Zeta, Epsilon for loops 21 | zet = (0:20:360); 22 | eps = (0:10:180); 23 | T_out= []; 24 | comb = []; 25 | %parallel configuration 26 | %Three nested for loops to determine the T_out of the third collector 27 | for i = 1:length(m_range) 28 | x(i)=m_range(i)/3; 29 | for j= 1:length(zet) 30 | y(j)=zet(j); 31 | for k=1:length(eps) 32 | z(k)=eps(k); 33 | [T_out(:,end+1),Id_ncol] = task_4(t_0,t_i,d,y(j),z(k),T_i,x(i)); 34 | comb(:,end+1) = [y(j),z(k),x(i),Id_ncol]; 35 | end 36 | end 37 | end 38 | %finding the average temperatures 39 | for i = 1:length(T_out(1,:)) 40 | T_avg(i) = sum(T_out(:,i))/length(T_out); 41 | end; 42 | %Finding the closest temp to 65C 43 | I = find(T_avg<66 & T_avg>64); 44 | [M,L] = min(abs(T_avg(I)-65)); 45 | %Finding total mass flow rate, Zeta, Epsilon for the parallel configuration 46 | m_total=(3*comb(3,I(L))*21600)/3.78541; 47 | zeta_parallel = comb(1,I(L)); 48 | eps_paralled = comb(2,I(L)); 49 | %Plotting the Average Temp vs the 3 parameters changed 50 | subplot(2,2,1); 51 | plot(comb(1,:),T_avg,'.k') 52 | title('Average Temperature vs Zeta'); 53 | subplot(2,2,2); 54 | plot(comb(2,:),T_avg, '.k'); 55 | title('Average Temperature vs Epsilon'); 56 | subplot(2,2,[3,4]); 57 | plot(comb(3,:),T_avg,'.k'); 58 | title('Average Temperature vs Mass flow rate per collector'); 59 | -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_4a.m: -------------------------------------------------------------------------------- 1 | %Setting up parameters as in previous tasks. 2 | t_0 = 10; 3 | t_i = 16; 4 | T_i = 16; 5 | d =120; 6 | Ac = 3.25; 7 | alpha_c =0.85; 8 | tau_g = 0.89; 9 | h_convo = 7; 10 | del_g = 0.007; 11 | kg = 1.3; 12 | h_convi = 3.1; 13 | del_ins = .06; 14 | k_ins = 0.045; 15 | cp = 4186; 16 | %Setting up data points for different m measurements. 17 | m_min = 0.0267; % mini m kg/s 18 | m_max= (350*3.78541)/21600; % max m kg/s if the total flow is 350 gallons over 6 hrs 19 | m_range= linspace(m_min,m_max,19); 20 | %Setting up data points for Zeta, Epsilon for loops 21 | zet = (0:20:360); 22 | eps = (0:10:180); 23 | T_out_ser = []; 24 | T_out_2 = []; 25 | T_out_3 = []; 26 | comb_2 = []; 27 | %series arrangement 28 | %Three nested for loops to determine the T_out of the third collector 29 | for i = 1:length(m_range) 30 | x(i)=m_range(i); 31 | for j= 1:length(zet) 32 | y(j)=zet(j); 33 | for k=1:length(eps) 34 | z(k)=eps(k); 35 | [T_out_ser(:,end+1),Id_ncol] = task_4(t_0,t_i,d,y(j),z(k),T_i,x(i)); 36 | [T_out_2(:,end+1),Id_ncol_2] = task_4(t_0,t_i,d,y(j),z(k),T_out_ser(:,i),x(i)); 37 | [T_out_3(:,end+1),Id_ncol_3] = task_4(t_0,t_i,d,y(j),z(k),T_out_2(:,i),x(i)); 38 | comb_2(:,end+1) = [y(j),z(k),x(i),Id_ncol]; 39 | end; 40 | end; 41 | end; 42 | %finding the average temperatures 43 | for i = 1:length(T_out_3(1,:)) 44 | T_avg_2(i) = sum(T_out_3(:,i))/length(T_out_3); 45 | end; 46 | %Finding temperatures between 64 and 66 and finding the closest one to 65 47 | a= find(T_avg_2<66 & T_avg_2>64); 48 | [m,l] = min(abs(T_avg_2(a)-65)); 49 | %Using all the inforamation to find the total mass, zeta, and epsilon of 50 | %series configuration. 51 | m_total_ser=(comb_2(3,a(l))*21600)/3.78541; 52 | zeta_series = comb_2(1,a(l)); 53 | eps_series = comb_2(2,a(l)); 54 | %Plotting the Average temperature vs the 3 parameters changed 55 | figure; 56 | subplot(2,2,1); 57 | plot(comb_2(1,:),T_avg_2,'.k') 58 | title('Average Temperature vs Zeta'); 59 | subplot(2,2,2); 60 | plot(comb_2(2,:),T_avg_2, '.k'); 61 | title('Average Temperature vs Epsilon'); 62 | subplot(2,2,[3,4]); 63 | plot(comb_2(3,:),T_avg_2,'.k'); 64 | title('Average Temperature vs Mass flow rate per collector'); 65 | 66 | %end 67 | 68 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_3 (1).m: -------------------------------------------------------------------------------- 1 | %function [Z, Rlam_min, T_C, W,Q_H, Q_C ] = task_3(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 2 | %%%%%add I_l and v_l for this question 3 | alpha= 0.0017; 4 | lam_A= 0.032; 5 | lam_B= 0.021; 6 | rho_A=0.0020; 7 | rho_B=0.0030; 8 | n=12; 9 | R_L=0.1; 10 | T_H= 323; 11 | T_sat= 95; 12 | %part a and b 13 | Rlam_min = ((lam_A+rho_A)^0.5 + (lam_B+rho_B)^0.5)^2; 14 | Z= alpha^2 / Rlam_min; 15 | A_pv = .10^2; 16 | k_w = 6.5; 17 | t_w = 0.4; 18 | U_ev = 25; 19 | 20 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 21 | a = T_sat; 22 | b = T_H+1; 23 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 24 | R =@(m_max) R_L / (n * m_max); 25 | lam = @(R) Rlam_min / R; 26 | fQ_C =@(T_C) A_pv * (k_w/t_w + U_ev) * (T_C-T_sat); 27 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *((((1+m_max)^2 / m_max) * ((Z*T_H)^(-1))) + 1 + ((1/(2*m_max))*(1+(T_C/T_H))))^(-1); 28 | R_batt = @(R) n* R; 29 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 30 | fQ_H =@(W,Eta) W/Eta; 31 | Q_CTE = @(Q_H, W)Q_H - W; 32 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 33 | err = 1; 34 | while err > 10^(-5) 35 | %if a1 == a && b1 == b 36 | c=(a+b)/2; 37 | m_max_mat(:)= [m_max(a), m_max(b), m_max(c)]; 38 | R_mat(:) = [R(m_max_mat(1)),R(m_max_mat(2)),R(m_max_mat(3))]; 39 | lam_mat(:) = [lam(R_mat(1)),lam(R_mat(2)),lam(R_mat(3))]; 40 | Q_C_mat(:) = [fQ_C(a),fQ_C(b),fQ_C(c)]; 41 | Eta_mat(:)= [Eta(a,m_max_mat(1)),Eta(b,m_max_mat(2)),Eta(c,m_max_mat(3))]; 42 | R_batt_mat(:) = [R_batt(R(1)),R_batt(R(2)),R_batt(R(3))]; 43 | W_mat(:) = [fW(a, R_batt_mat(1)),fW(b, R_batt_mat(2)),fW(c, R_batt_mat(3))]; 44 | Q_H_mat(:)=[fQ_H(W_mat(1),Eta_mat(1)),fQ_H(W_mat(2),Eta_mat(2)),fQ_H(W_mat(3),Eta_mat(3))]; 45 | Q_CTE_mat(:) = [Q_CTE(Q_H_mat(1), W_mat(1)),Q_CTE(Q_H_mat(2), W_mat(2)),Q_CTE(Q_H_mat(3), W_mat(3))]; 46 | E_QC_mat(:)= [E_QC(Q_CTE_mat(1), Q_C_mat(1)),E_QC(Q_CTE_mat(2), Q_C_mat(2)),E_QC(Q_CTE_mat(3), Q_C_mat(3))]; 47 | if E_QC_mat(1) * E_QC_mat(3) < 0 48 | b=c; 49 | else 50 | a=c; 51 | end 52 | err = abs(E_QC_mat(3)); 53 | %else 54 | 55 | end 56 | 57 | T_C = c; 58 | W = W_c; 59 | Q_H = Q_H_c; 60 | Q_C = Q_C_c; 61 | 62 | %%%%%need to add task_2 63 | 64 | %end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_3_2.m: -------------------------------------------------------------------------------- 1 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L, I_L ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 2 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 3 | Z= alpha^2 / Rlam_min; 4 | A_pv = 0.1^2; 5 | k_w = 6.5; 6 | t_w = 0.4*10^-2; 7 | U_ev = 25; 8 | a = T_sat; 9 | b = T_H+1; 10 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 11 | R =@(m_max) R_L/(n * m_max); 12 | lam = @(R) Rlam_min / R; 13 | fQ_C =@(T_C) A_pv*(k_w/t_w + U_ev) * (T_C-T_sat); 14 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 15 | R_batt = @(R) n* R; 16 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 17 | fQ_H =@(W,Eta) W/Eta; 18 | Q_CTE = @(Q_H, W)Q_H - W; 19 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 20 | err = 1; 21 | while err > 10^(-5) 22 | c=(a+b)/2; 23 | m_max_a =m_max(a); 24 | m_max_b =m_max(b); 25 | m_max_c =m_max(c); 26 | R_a =R(m_max_a); 27 | R_b =R(m_max_b); 28 | R_c =R(m_max_c); 29 | lam_a = lam(R_a); 30 | lam_b = lam(R_b); 31 | lam_c = lam(R_c); 32 | Q_C_a =fQ_C(a); 33 | Q_C_b =fQ_C(b); 34 | Q_C_c =fQ_C(c); 35 | Eta_a =Eta(a, m_max_a); 36 | Eta_b =Eta(b, m_max_b); 37 | Eta_c =Eta(c, m_max_c); 38 | R_batt_a = R_batt(R_a); 39 | R_batt_b = R_batt(R_b); 40 | R_batt_c = R_batt(R_c); 41 | W_a =fW(a, R_batt_a); 42 | W_b =fW(b, R_batt_b); 43 | W_c =fW(c, R_batt_c); 44 | Q_H_a =fQ_H(W_a,Eta_a); 45 | Q_H_b =fQ_H(W_b,Eta_b); 46 | Q_H_c =fQ_H(W_c,Eta_c); 47 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 48 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 49 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 50 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 51 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 52 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 53 | if E_QC_a>0 && E_QC_c < 0 54 | b=c; 55 | else 56 | a=c; 57 | end 58 | err = abs(E_QC_c); 59 | end 60 | 61 | T_C = c; 62 | W = W_c; 63 | Q_H = Q_H_c; 64 | Q_C = Q_C_c; 65 | lam_batt = n*lam_c; 66 | R_batt_2 = R_batt_c; 67 | Eta_te = Eta_c; 68 | syms I_L V_L 69 | eqn1=V_L- (n*alpha*(T_H-T_C))-R_batt_2*I_L==0; 70 | eqn2= Q_H- n*alpha*I_L*T_H- lam_batt*(T_H-T_C)-0.5*((I_L)^2)*R_batt_2==0; 71 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L,I_L,'IgnoreAnalyticConstraints', true); 72 | V_L_2= double(subs(V_L_sol))>0; 73 | V_L = double(V_L_sol(double(subs(V_L_sol))>0)); 74 | I_L = double(I_L_sol(double(subs(I_L_sol))>0)); 75 | 76 | end -------------------------------------------------------------------------------- /Solar Collector System Design and Analysis/task_4.m: -------------------------------------------------------------------------------- 1 | function [T_out, Id_ncol] = task_4(t_0,t_i,d, zeta,epsilon, T_i,m) 2 | %Setting up parameters as in previous tasks 3 | lambda = 37.9; 4 | t = t_0:1/3600:t_i; 5 | for i = 1:length(t) 6 | T_a(i)= (7/6)*t(i)-(8/3); 7 | end 8 | Ac = 3.25; 9 | alpha_c =0.85; 10 | tau_g = 0.89; 11 | h_convo = 7; 12 | del_g = 0.007; 13 | kg = 1.3; 14 | h_convi = 3.1; 15 | del_ins = .06; 16 | k_ins = 0.045; 17 | cp = 4186; 18 | T_in = []; 19 | for i = 1:length(t) 20 | alpha(i) = 15*(t(i)-12); 21 | %Converting Tin to the same length as T_ambient for task 4 22 | end 23 | if length(T_i)==1 24 | for i =1:length(t) 25 | T_in(end+1) = T_i; 26 | end 27 | else 28 | T_in = T_i; 29 | end; 30 | del = 23.44*sind((360/365.25)*(d-80)); 31 | cos_zen_ang = zeros(0,length(alpha)); 32 | for i = 1:length(t) 33 | cos_zen_ang(i)= sind(lambda)*sind(del)+ cosd(lambda)*cosd(del)*cosd(alpha(i)); 34 | chi(i) = acosd(cos_zen_ang(i)); 35 | end 36 | for i = 1:length(t) 37 | tan_xi(i) = sind(alpha(i)) /((sind(lambda)*cosd(alpha(i))-cosd(lambda)*tand(del))); 38 | end 39 | for i = 1:length(t) 40 | if alpha(i) > 0 && tan_xi(i) > 0 41 | xi(i) = 180 + atand(tan_xi(i)); 42 | elseif alpha(i) > 0 && tan_xi(i) < 0 43 | xi(i) = 360 + atand(tan_xi(i)); 44 | elseif alpha(i) < 0 && tan_xi(i) >0 45 | xi(i) = atand(tan_xi(i)); 46 | elseif alpha(i)<0 && tan_xi(i) < 0 47 | xi(i) = 180+ atand(tan_xi(i)); 48 | end 49 | end 50 | A = 1310; 51 | B = 0.18; 52 | for i = 1:length(chi) 53 | I_dn(i) = A*exp(-B/(sind(90-chi(i)))); 54 | Id_i(i) = I_dn(i)*(cos_zen_ang(i)*cosd(epsilon)+sind(epsilon)*sind(chi(i))*cosd(xi(i) - zeta)); 55 | end 56 | U_loss = ((1/(h_convo*Ac) + del_g/(kg*Ac) + 1/(h_convi*Ac))^-1 + (1/(h_convo*Ac) + (del_ins/(k_ins*Ac)))^-1)/Ac; 57 | F_r = (1- exp(-Ac*U_loss/(m*cp)))/(Ac*U_loss/(m*cp)); 58 | Id = 0; 59 | for i = 1:length(t)-1 60 | Id = (((t_i-t_0)*3600/length(t))*(((Id_i(i)) + Id_i(i+1))/2))+Id; 61 | end 62 | for i =1: length(t) 63 | n_colli(i) = F_r*(tau_g *alpha_c - (U_loss./Id_i(i)).*(T_in(i)-T_a(i))); 64 | end 65 | Id_ncol = 0; 66 | for i = 1:length(t)-1 67 | Id_ncol = (((t_i-t_0)*3600/length(t))*(((Id_i(i))*n_colli(i) + n_colli(i+1)*Id_i(i+1))/2))+Id_ncol; 68 | end 69 | n_colll = Id_ncol/Id; 70 | %Finding T_out per second using equation 13 71 | for i = 1:length(t) 72 | T_out(i)= (Id_i(i)*n_colli(i)*Ac)/(cp*m)+ T_in(i); 73 | end 74 | %Finding T_avg 75 | T_out_avg = sum(T_out(:))/length(T_out); 76 | -------------------------------------------------------------------------------- /Horizontal Axis Wind Turbine Evaluation/task_3.m: -------------------------------------------------------------------------------- 1 | function [overall_des_R,overall_des_w_tur, overall_des_sigma, overall_des_eff]=task_3( rou, v1, alpha, Cl, n, omega) 2 | %setting R, sigma, and other variables 3 | R1=linspace(1,22,51); 4 | sigma1=linspace(0,1,51); 5 | Kh1 = 0.085*R1; 6 | rh1 = 0.1*R1; 7 | %Using task_1 to find W_tur and Efficiency for all different R and sigma 8 | for i = 1:length(R1) 9 | disp(i); 10 | for j = 1:length(sigma1) 11 | [w_tur(i,j),eta(i,j)]=task_1(rou, v1, alpha, Cl, n, Kh1(i),sigma1(j), rh1(i), R1(i),omega ); 12 | end 13 | end 14 | %finding a value closest to 1500W 15 | [a,b]= find(w_tur<1550 & w_tur>=1500); 16 | for l = 1:length(a) 17 | des_2_w_tur(l) = w_tur(a(l),b(l)); 18 | des_2_eff(l) = eta(a(l),b(l)); 19 | end 20 | [p,q] = max(des_2_eff); 21 | des_2_eff = p; 22 | des_2_w_tur = des_2_w_tur(q); 23 | %finding a value of efficiency closest to 1 24 | [c,d]= find(eta<1.00 &eta>0.98); 25 | for l = 1:length(c) 26 | des_1_w_tur(l) = w_tur(c(l),d(l)); 27 | des_1_eff(l) = eta(c(l),d(l)); 28 | end 29 | [e,f] = max(des_1_eff); 30 | des_1_eff = e; 31 | des_1_w_tur = des_1_w_tur(f); 32 | des_1_R= R1(c(f)); 33 | des_1_sigma = sigma1(d(f)); 34 | des_2_R = R1(a(q)); 35 | des_2_sigma = sigma1(b(q)); 36 | des_R = [des_1_R,des_2_R]; 37 | des_eff = [des_1_eff,des_2_eff]; 38 | des_w_tur = [des_1_w_tur,des_2_w_tur]; 39 | %choosing between two alternatives for min sigma 40 | [overall_des_sigma,index] = min([des_1_sigma,des_2_sigma]); 41 | overall_des_R= des_R(index); 42 | overall_des_w_tur = des_w_tur(index); 43 | overall_des_eff = des_eff(index); 44 | %plotting change in setup angle vs R 45 | des_ov_rh = overall_des_R*0.1; 46 | lambda = omega*overall_des_R/v1; 47 | des_ov_c = des_ov_rh:0.001:overall_des_R; 48 | des_ov_xi = alpha*pi/180 - atan(2*overall_des_R./3./lambda./des_ov_c); 49 | des_ov_xi1=des_ov_xi*180/pi; 50 | plot(des_ov_c, des_ov_xi1) 51 | xlabel('Radius (m)') 52 | ylabel('Setup Angle (Degrees)') 53 | title('Setup Angle vs Radius') 54 | 55 | end 56 | 57 | function [w_tur, eta]=task_1(rou, v1, alpha, Cl, n, Kh,sigma, rh, R,omega ) 58 | 59 | lambda = omega*R/v1; 60 | rh_bar= rh/R; 61 | a=2*R/3/lambda; 62 | b=1-rh_bar; 63 | 64 | syms r; 65 | w = Cl/3*(n*rou*lambda*Kh*(v1^2)/R) * ((r^2+a^2)^(0.5) *((r^2+a^2)*(lambda*v1/3/R*(1+sigma*rh_bar/b) - sigma*r*lambda*v1/4/(R^2)/b) + log(r+(r^2+a^2)^(0.5))*(2*sigma*R^2*v1)/(81*lambda^3*b))); 66 | w_b = 16/27*0.5*rou*v1^3*pi *r^2; 67 | 68 | %turbine work 69 | ans = subs(w,r, [rh R]); 70 | w_tur =double(ans(2)-ans(1)); 71 | 72 | %betz work 73 | ans1 = subs(w_b,r, [rh R]); 74 | w_betz = double(ans1(2)-ans1(1)); 75 | 76 | eta=w_tur/w_betz; 77 | 78 | %c=rh:0.001:R; 79 | %xi = alpha*pi/180 - atan(2*R./3./lambda./c); 80 | %xi1=xi*180/pi; 81 | %plot(c, xi1) 82 | 83 | 84 | end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_6b.m: -------------------------------------------------------------------------------- 1 | lamb_cont= 300; 2 | Id = 1080; 3 | rc = 15; 4 | Ly = 10 ; 5 | Lz = 10 ; 6 | Vg = 1.1; 7 | fg = 265 ; 8 | Rs = 0; 9 | R_L_pv = 0.0070; 10 | T_sat = 90.2 ; 11 | errr = 1; 12 | alpha= 0.0017; 13 | lam_A= 0.032; 14 | lam_B= 0.021; 15 | rho_A=0.0020; 16 | rho_B=0.0030; 17 | n=12; 18 | R_L=0.1; 19 | i =1; 20 | a1 = 95; 21 | b1= 350; 22 | P_sun= (Id*rc*(0.1)^2*0.95); 23 | while errr > 10^(-5) 24 | c1 = (a1+b1)/2; 25 | T_H(i,:)= [a1,c1,b1]; 26 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_te(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,1), T_sat); 27 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_te(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,2), T_sat); 28 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_te(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,3), T_sat); 29 | E_Q(i,:) = P_sun - Q_H(i,:); 30 | if E_Q(i,1)>0 && E_Q(i,2) < 0 31 | b1=c1; 32 | else 33 | a1=c1; 34 | end 35 | errr = abs(E_Q(i,2)); 36 | i = i+1; 37 | end 38 | T_H = T_H(i-1,2); 39 | 40 | [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat); 41 | T_C = T_C 42 | Q_H = Q_H 43 | V_L = V_L_te 44 | I_L_te = I_L_te 45 | W = W 46 | P_tot = W 47 | Eta = Eta_te 48 | Eta_tot = P_tot/ (Id*rc*(0.1^2)*0.95) 49 | 50 | 51 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 52 | %%%%%add I_l and v_l for this question 53 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 54 | Z= alpha^2 / Rlam_min; 55 | A_pv = 0.1^2; 56 | k_w = 6.5; 57 | t_w = 0.4*10^-2; 58 | U_ev = 25; 59 | 60 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 61 | a = T_sat; 62 | b = T_H+1; 63 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 64 | R =@(m_max) R_L/(n * m_max); 65 | lam = @(R) Rlam_min / R; 66 | fQ_C =@(T_C)A_pv* (k_w/t_w + U_ev) * (T_C-T_sat); 67 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 68 | R_batt = @(R) n* R; 69 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 70 | fQ_H =@(W,Eta) W/Eta; 71 | Q_CTE = @(Q_H, W)Q_H - W; 72 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 73 | err = 1; 74 | while err > 10^(-5) 75 | c=(a+b)/2; 76 | m_max_a =m_max(a); 77 | m_max_b =m_max(b); 78 | m_max_c =m_max(c); 79 | R_a =R(m_max_a); 80 | R_b =R(m_max_b); 81 | R_c =R(m_max_c); 82 | lam_a = lam(R_a); 83 | lam_b = lam(R_b); 84 | lam_c = lam(R_c); 85 | Q_C_a =fQ_C(a); 86 | Q_C_b =fQ_C(b); 87 | Q_C_c =fQ_C(c); 88 | Eta_a =Eta(a, m_max_a); 89 | Eta_b =Eta(b, m_max_b); 90 | Eta_c =Eta(c, m_max_c); 91 | R_batt_a = R_batt(R_a); 92 | R_batt_b = R_batt(R_b); 93 | R_batt_c = R_batt(R_c); 94 | W_a =fW(a, R_batt_a); 95 | W_b =fW(b, R_batt_b); 96 | W_c =fW(c, R_batt_c); 97 | Q_H_a =fQ_H(W_a,Eta_a); 98 | Q_H_b =fQ_H(W_b,Eta_b); 99 | Q_H_c =fQ_H(W_c,Eta_c); 100 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 101 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 102 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 103 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 104 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 105 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 106 | if E_QC_a>0 && E_QC_c < 0 107 | b=c; 108 | else 109 | a=c; 110 | end 111 | err = abs(E_QC_c); 112 | end 113 | 114 | T_C = c; 115 | W = W_c; 116 | Q_H = Q_H_c; 117 | Q_C = Q_C_c; 118 | lam_batt = n*lam_c; 119 | R_batt_2 = R_batt_c; 120 | Eta_te = Eta_c; 121 | syms I_L_te V_L_te 122 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 123 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 124 | %%%%%need to add task_2 125 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 126 | V_L_2= double(subs(V_L_sol))>0; 127 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 128 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 129 | 130 | end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_4_2.m: -------------------------------------------------------------------------------- 1 | lamb_cont= 300; 2 | Id = 1080; 3 | rc = 15; 4 | Ly = 10 ; 5 | Lz = 10 ; 6 | Vg = 1.1; 7 | fg = 265 ; 8 | Rs = 0; 9 | R_L_pv = 0.0070; 10 | T_sat = 90.2 ; 11 | errr = 1; 12 | alpha= 0.0017; 13 | lam_A= 0.032; 14 | lam_B= 0.021; 15 | rho_A=0.0020; 16 | rho_B=0.0030; 17 | n=12; 18 | R_L=0.1; 19 | i =1; 20 | a1 = 150; 21 | b1= 250; 22 | while errr > 10^(-5) 23 | c1 = (a1+b1)/2; 24 | T_pv(i,:)= [a1,c1,b1]; 25 | [P(i,1), Eta(i,1),Q_pv(i,1), V_L(i,1),I_L(i,1)]= task_2(R_L_pv, Ly,Lz, Id, rc,a1,Vg); 26 | [P(i,2), Eta(i,2),Q_pv(i,2), V_L(i,2),I_L(i,2)]= task_2(R_L_pv, Ly,Lz, Id, rc,c1,Vg); 27 | [P(i,3), Eta(i,3),Q_pv(i,3), V_L(i,3),I_L(i,3)]= task_2(R_L_pv, Ly,Lz, Id, rc,b1,Vg); 28 | T_H(i,:) = T_pv(i,:) - Q_pv(i,:)./lamb_cont; 29 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_te(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,1), T_sat); 30 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_te(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,2), T_sat); 31 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_te(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,3), T_sat); 32 | E_Q(i,:) = Q_pv(i,:) - Q_H(i,:); 33 | if E_Q(i,1)>0 && E_Q(i,2) < 0 34 | b1=c1; 35 | else 36 | a1=c1; 37 | end 38 | errr = abs(E_Q(i,2)); 39 | i = i+1; 40 | end 41 | ii= i; 42 | T_H = T_H(i-1,2) 43 | T_C= T_C(i-1,2) 44 | T_pv = T_pv(i-1,2) 45 | Eta_te = Eta_te(i-1,2) 46 | Eta= Eta(i-1,2) 47 | P = P(i-1,2) 48 | W= W(i-1,2) 49 | V_L= V_L(i-1,2) 50 | I_L = I_L(i-1,2) 51 | P_tot = P+W; 52 | Eta_tot = P_tot/ (Id*rc*(0.1^2)); 53 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 54 | T_p=[293;303;313;333;353]; 55 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 56 | T_pv = horzcat(T_p,ones(5,1)); 57 | co = T_pv\V_oc; 58 | V_oc = [(T), 1]*co; 59 | 60 | %constants 61 | Kb= 1.38*10^-23; 62 | qe= 1.6*10^-19; 63 | L=V_oc*qe/(Kb*(T)); 64 | I0_Iv = 1/(exp(L)-1); 65 | A_pv = (Ly*Lz)/10000; 66 | %I_L = V_L / R_L; 67 | %Eta = V_L * I_L / (p * A_pv); 68 | P_0= Id*rc*A_pv; 69 | 70 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 71 | 72 | syms I_L 73 | 74 | fun= @(x) (x.^2)./(exp(x)-1); 75 | 76 | xmin = qe*Vg/(Kb* 5778); 77 | 78 | inte = integral(fun,xmin,Inf); 79 | 80 | phi_g = phi * 0.416 * inte; 81 | 82 | Iv = phi_g * qe * A_pv; 83 | 84 | I0 =Iv * I0_Iv; 85 | 86 | eqn= (Kb*(T)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 87 | I_L_sol = solve(eqn,I_L); 88 | I_L = double(subs(I_L_sol)); 89 | V_L = I_L*R_L; 90 | Eta = V_L*I_L/ (Id*rc*A_pv); 91 | P = I_L*V_L; 92 | Q_pv = -V_L*I_L + P_0; 93 | end 94 | 95 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 96 | %%%%%add I_l and v_l for this question 97 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 98 | Z= alpha^2 / Rlam_min; 99 | A_pv = 0.1^2; 100 | k_w = 6.5; 101 | t_w = 0.4*10^-2; 102 | U_ev = 25; 103 | 104 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 105 | a = T_sat; 106 | b = T_H+1; 107 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 108 | R =@(m_max) R_L/(n * m_max); 109 | lam = @(R) Rlam_min / R; 110 | fQ_C =@(T_C) (k_w/t_w + U_ev) * (T_C-T_sat); 111 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 112 | R_batt = @(R) n* R; 113 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 114 | fQ_H =@(W,Eta) W/Eta; 115 | Q_CTE = @(Q_H, W)Q_H - W; 116 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 117 | err = 1; 118 | while err > 10^(-5) 119 | c=(a+b)/2; 120 | m_max_a =m_max(a); 121 | m_max_b =m_max(b); 122 | m_max_c =m_max(c); 123 | R_a =R(m_max_a); 124 | R_b =R(m_max_b); 125 | R_c =R(m_max_c); 126 | lam_a = lam(R_a); 127 | lam_b = lam(R_b); 128 | lam_c = lam(R_c); 129 | Q_C_a =fQ_C(a); 130 | Q_C_b =fQ_C(b); 131 | Q_C_c =fQ_C(c); 132 | Eta_a =Eta(a, m_max_a); 133 | Eta_b =Eta(b, m_max_b); 134 | Eta_c =Eta(c, m_max_c); 135 | R_batt_a = R_batt(R_a); 136 | R_batt_b = R_batt(R_b); 137 | R_batt_c = R_batt(R_c); 138 | W_a =fW(a, R_batt_a); 139 | W_b =fW(b, R_batt_b); 140 | W_c =fW(c, R_batt_c); 141 | Q_H_a =fQ_H(W_a,Eta_a); 142 | Q_H_b =fQ_H(W_b,Eta_b); 143 | Q_H_c =fQ_H(W_c,Eta_c); 144 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 145 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 146 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 147 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 148 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 149 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 150 | if E_QC_a>0 && E_QC_c < 0 151 | b=c; 152 | else 153 | a=c; 154 | end 155 | err = abs(E_QC_c); 156 | end 157 | 158 | T_C = c; 159 | W = W_c; 160 | Q_H = Q_H_c; 161 | Q_C = Q_C_c; 162 | lam_batt = n*lam_c; 163 | R_batt_2 = R_batt_c; 164 | Eta_te = Eta_c; 165 | syms I_L_te V_L_te 166 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 167 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 168 | %%%%%need to add task_2 169 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 170 | V_L_2= double(subs(V_L_sol))>0; 171 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 172 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 173 | 174 | end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_4 (1).m: -------------------------------------------------------------------------------- 1 | lamb_cont= 300; 2 | Id = 1080; 3 | rc = 15; 4 | Ly = 10 ; 5 | Lz = 10 ; 6 | Vg = 1.1; 7 | fg = 265 ; 8 | Rs = 0; 9 | R_L_pv = 0.0070; 10 | T_sat = 90.2 ; 11 | errr = 1; 12 | alpha= 0.0017; 13 | lam_A= 0.032; 14 | lam_B= 0.021; 15 | rho_A=0.0020; 16 | rho_B=0.0030; 17 | n=12; 18 | R_L=0.1; 19 | i =1; 20 | a1 = 150; 21 | b1= 250; 22 | while errr > 10^(-5) 23 | c1 = (a1+b1)/2; 24 | T_pv(i,:)= [a1,c1,b1]; 25 | [P(i,1), Eta(i,1),Q_pv(i,1), V_L(i,1),I_L(i,1)]= task_2(R_L_pv, Ly,Lz, Id, rc,a1,Vg); 26 | [P(i,2), Eta(i,2),Q_pv(i,2), V_L(i,2),I_L(i,2)]= task_2(R_L_pv, Ly,Lz, Id, rc,c1,Vg); 27 | [P(i,3), Eta(i,3),Q_pv(i,3), V_L(i,3),I_L(i,3)]= task_2(R_L_pv, Ly,Lz, Id, rc,b1,Vg); 28 | T_H(i,:) = T_pv(i,:) - Q_pv(i,:)./lamb_cont; 29 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_te(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,1), T_sat); 30 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_te(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,2), T_sat); 31 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_te(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H(i,3), T_sat); 32 | E_Q(i,:) = Q_pv(i,:) - Q_H(i,:); 33 | if E_Q(i,1)>0 && E_Q(i,2) < 0 34 | b1=c1; 35 | else 36 | a1=c1; 37 | end 38 | errr = abs(E_Q(i,2)); 39 | i = i+1; 40 | end 41 | ii= i; 42 | T_H = T_H(i-1,2) 43 | T_C= T_C(i-1,2) 44 | T_pv = T_pv(i-1,2) 45 | Eta_te = Eta_te(i-1,2) 46 | Eta= Eta(i-1,2) 47 | P = P(i-1,2) 48 | W= W(i-1,2) 49 | V_L= V_L(i-1,2) 50 | I_L = I_L(i-1,2) 51 | P_tot = P+W; 52 | Eta_tot = P_tot/ (Id*rc*(0.1^2)); 53 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 54 | T_p=[293;303;313;333;353]; 55 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 56 | T_pv = horzcat(T_p,ones(5,1)); 57 | co = T_pv\V_oc; 58 | V_oc = [(T), 1]*co; 59 | 60 | %constants 61 | Kb= 1.38*10^-23; 62 | qe= 1.6*10^-19; 63 | L=V_oc*qe/(Kb*(T)); 64 | I0_Iv = 1/(exp(L)-1); 65 | A_pv = (Ly*Lz)/10000; 66 | %I_L = V_L / R_L; 67 | %Eta = V_L * I_L / (p * A_pv); 68 | P_0= Id*rc*A_pv; 69 | 70 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 71 | 72 | syms I_L 73 | 74 | fun= @(x) (x.^2)./(exp(x)-1); 75 | 76 | xmin = qe*Vg/(Kb* 5778); 77 | 78 | inte = integral(fun,xmin,Inf); 79 | 80 | phi_g = phi * 0.416 * inte; 81 | 82 | Iv = phi_g * qe * A_pv; 83 | 84 | I0 =Iv * I0_Iv; 85 | 86 | eqn= (Kb*(T)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 87 | I_L_sol = solve(eqn,I_L); 88 | I_L = double(subs(I_L_sol)); 89 | V_L = I_L*R_L; 90 | Eta = V_L*I_L/ (Id*rc*A_pv); 91 | P = I_L*V_L; 92 | Q_pv = -V_L*I_L + P_0; 93 | end 94 | 95 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 96 | %%%%%add I_l and v_l for this question 97 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 98 | Z= alpha^2 / Rlam_min; 99 | A_pv = 0.1^2; 100 | k_w = 6.5; 101 | t_w = 0.4*10^-2; 102 | U_ev = 25; 103 | 104 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 105 | a = T_sat; 106 | b = T_H+1; 107 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 108 | R =@(m_max) R_L/(n * m_max); 109 | lam = @(R) Rlam_min / R; 110 | fQ_C =@(T_C) (k_w/t_w + U_ev) * (T_C-T_sat); 111 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 112 | R_batt = @(R) n* R; 113 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 114 | fQ_H =@(W,Eta) W/Eta; 115 | Q_CTE = @(Q_H, W)Q_H - W; 116 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 117 | err = 1; 118 | while err > 10^(-5) 119 | c=(a+b)/2; 120 | m_max_a =m_max(a); 121 | m_max_b =m_max(b); 122 | m_max_c =m_max(c); 123 | R_a =R(m_max_a); 124 | R_b =R(m_max_b); 125 | R_c =R(m_max_c); 126 | lam_a = lam(R_a); 127 | lam_b = lam(R_b); 128 | lam_c = lam(R_c); 129 | Q_C_a =fQ_C(a); 130 | Q_C_b =fQ_C(b); 131 | Q_C_c =fQ_C(c); 132 | Eta_a =Eta(a, m_max_a); 133 | Eta_b =Eta(b, m_max_b); 134 | Eta_c =Eta(c, m_max_c); 135 | R_batt_a = R_batt(R_a); 136 | R_batt_b = R_batt(R_b); 137 | R_batt_c = R_batt(R_c); 138 | W_a =fW(a, R_batt_a); 139 | W_b =fW(b, R_batt_b); 140 | W_c =fW(c, R_batt_c); 141 | Q_H_a =fQ_H(W_a,Eta_a); 142 | Q_H_b =fQ_H(W_b,Eta_b); 143 | Q_H_c =fQ_H(W_c,Eta_c); 144 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 145 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 146 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 147 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 148 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 149 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 150 | if E_QC_a>0 && E_QC_c < 0 151 | b=c; 152 | else 153 | a=c; 154 | end 155 | err = abs(E_QC_c); 156 | end 157 | 158 | T_C = c; 159 | W = W_c; 160 | Q_H = Q_H_c; 161 | Q_C = Q_C_c; 162 | lam_batt = n*lam_c; 163 | R_batt_2 = R_batt_c; 164 | Eta_te = Eta_c; 165 | syms I_L_te V_L_te 166 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 167 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 168 | %%%%%need to add task_2 169 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 170 | V_L_2= double(subs(V_L_sol))>0; 171 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 172 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 173 | 174 | end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_5b.m: -------------------------------------------------------------------------------- 1 | Id = 1080; 2 | Ly = 10 ; 3 | Lz = 10 ; 4 | Vg = 1.1; 5 | fg = 265 ; 6 | Rs = 0; 7 | rc_i = linspace(10,18,9); 8 | R_L_pv = 0.0070; 9 | T_sat = 90.2 ; 10 | errr = 1; 11 | alpha= 0.0017; 12 | lam_A= 0.032; 13 | lam_B= 0.021; 14 | rho_A=0.0020; 15 | rho_B=0.0030; 16 | n=12; 17 | R_L=0.1; 18 | i =1; 19 | a1 = 150; 20 | b1= 250; 21 | lamb_cont= 300; 22 | for l = 1:length(rc_i) 23 | rc = rc_i(l); 24 | disp(l); 25 | i=1; 26 | errr = 1; 27 | a1 = T_sat+1; 28 | b1= 383; 29 | while errr > 10^(-5) 30 | c1 = (a1+b1)/2; 31 | T_pv_i(i,:)= [a1,c1,b1]; 32 | [P(i,1), Eta(i,1),Q_pv(i,1), V_L(i,1),I_L(i,1)]= task_2(R_L_pv, Ly,Lz, Id, rc,a1,Vg); 33 | [P(i,2), Eta(i,2),Q_pv(i,2), V_L(i,2),I_L(i,2)]= task_2(R_L_pv, Ly,Lz, Id, rc,c1,Vg); 34 | [P(i,3), Eta(i,3),Q_pv(i,3), V_L(i,3),I_L(i,3)]= task_2(R_L_pv, Ly,Lz, Id, rc,b1,Vg); 35 | T_H_i(i,:) = T_pv_i(i,:) - Q_pv(i,:)./lamb_cont; 36 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_tee(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,1), T_sat); 37 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_tee(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,2), T_sat); 38 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_tee(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,3), T_sat); 39 | E_Q(i,:) = Q_pv(i,:) - Q_H(i,:); 40 | if E_Q(i,1)>0 && E_Q(i,2) < 0 41 | b1=c1; 42 | else 43 | a1=c1; 44 | end 45 | errr = abs(E_Q(i,2)); 46 | i = i+1; 47 | end 48 | T_H(1,l) = T_H_i(i-1,2); 49 | T_C(1,l)= T_C(i-1,2); 50 | T_pv(1,l) = T_pv_i(i-1,2); 51 | Eta_te(1,l) = Eta_tee(i-1,2); 52 | Eta_pv(1,l)= Eta(i-1,2); 53 | P_pv(1,l) = P(i-1,2); 54 | W_te(1,l)= W(i-1,2); 55 | V_L(1,l)= V_L(i-1,2); 56 | I_L(1,l) = I_L(i-1,2); 57 | P_tot(1,l) = P_pv(1,l)+W_te(1,l); 58 | Eta_tot(1,l) = P_tot(1,l)/ (Id*rc*(0.1^2)); 59 | V_L_te(1,l) = V_L_te(i-1,2); 60 | I_L_te(1,l) = I_L_te(i-1,2); 61 | end 62 | subplot(2,2,1) 63 | plot(rc_i,transpose(Eta_tot),'.'); 64 | title('Subplot 1: Total Efficiency vs Variations in Incident Radiation'); 65 | subplot(2,2,2) 66 | plot(rc_i,transpose(Eta_te),'.'); 67 | title('Subplot 1: Thermal Efficiency vs Variations in Incident Radiation'); 68 | subplot(2,2,3) 69 | plot(rc_i,transpose(Eta_pv),'.'); 70 | title('Subplot 1: PV Efficiency vs Variations in Incident Radiation'); 71 | subplot(2,2,4) 72 | plot(rc_i,transpose(P_tot), '.'); 73 | title('Subplot 1: Total Power vs Variations in Incident Radiation'); 74 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 75 | T_p=[293;303;313;333;353]; 76 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 77 | T_pv = horzcat(T_p,ones(5,1)); 78 | co = T_pv\V_oc; 79 | V_oc = [(T), 1]*co; 80 | 81 | %constants 82 | Kb= 1.38*10^-23; 83 | qe= 1.6*10^-19; 84 | L=V_oc*qe/(Kb*(T)); 85 | I0_Iv = 1/(exp(L)-1); 86 | A_pv = (Ly*Lz)/10000; 87 | %I_L = V_L / R_L; 88 | %Eta = V_L * I_L / (p * A_pv); 89 | P_0= Id*rc*A_pv; 90 | 91 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 92 | 93 | syms I_L 94 | 95 | fun= @(x) (x.^2)./(exp(x)-1); 96 | 97 | xmin = qe*Vg/(Kb* 5778); 98 | 99 | inte = integral(fun,xmin,Inf); 100 | 101 | phi_g = phi * 0.416 * inte; 102 | 103 | Iv = phi_g * qe * A_pv; 104 | 105 | I0 =Iv * I0_Iv; 106 | 107 | eqn= (Kb*(T)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 108 | I_L_sol = solve(eqn,I_L); 109 | I_L = double(subs(I_L_sol)); 110 | V_L = I_L*R_L; 111 | Eta = V_L*I_L/ (Id*rc*A_pv); 112 | P = I_L*V_L; 113 | Q_pv = -V_L*I_L + P_0; 114 | end 115 | 116 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 117 | %%%%%add I_l and v_l for this question 118 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 119 | Z= alpha^2 / Rlam_min; 120 | A_pv = 0.1^2; 121 | k_w = 6.5; 122 | t_w = 0.4*10^-2; 123 | U_ev = 25; 124 | 125 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 126 | a = T_sat; 127 | b = T_H+1; 128 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 129 | R =@(m_max) R_L/(n * m_max); 130 | lam = @(R) Rlam_min / R; 131 | fQ_C =@(T_C) (k_w/t_w + U_ev) * (T_C-T_sat); 132 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 133 | R_batt = @(R) n* R; 134 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 135 | fQ_H =@(W,Eta) W/Eta; 136 | Q_CTE = @(Q_H, W)Q_H - W; 137 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 138 | err = 1; 139 | while err > 10^(-5) 140 | c=(a+b)/2; 141 | m_max_a =m_max(a); 142 | m_max_b =m_max(b); 143 | m_max_c =m_max(c); 144 | R_a =R(m_max_a); 145 | R_b =R(m_max_b); 146 | R_c =R(m_max_c); 147 | lam_a = lam(R_a); 148 | lam_b = lam(R_b); 149 | lam_c = lam(R_c); 150 | Q_C_a =fQ_C(a); 151 | Q_C_b =fQ_C(b); 152 | Q_C_c =fQ_C(c); 153 | Eta_a =Eta(a, m_max_a); 154 | Eta_b =Eta(b, m_max_b); 155 | Eta_c =Eta(c, m_max_c); 156 | R_batt_a = R_batt(R_a); 157 | R_batt_b = R_batt(R_b); 158 | R_batt_c = R_batt(R_c); 159 | W_a =fW(a, R_batt_a); 160 | W_b =fW(b, R_batt_b); 161 | W_c =fW(c, R_batt_c); 162 | Q_H_a =fQ_H(W_a,Eta_a); 163 | Q_H_b =fQ_H(W_b,Eta_b); 164 | Q_H_c =fQ_H(W_c,Eta_c); 165 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 166 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 167 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 168 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 169 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 170 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 171 | if E_QC_a>0 && E_QC_c < 0 172 | b=c; 173 | else 174 | a=c; 175 | end 176 | err = abs(E_QC_c); 177 | end 178 | 179 | T_C = c; 180 | W = W_c; 181 | Q_H = Q_H_c; 182 | Q_C = Q_C_c; 183 | lam_batt = n*lam_c; 184 | R_batt_2 = R_batt_c; 185 | Eta_te = Eta_c; 186 | syms I_L_te V_L_te 187 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 188 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 189 | %%%%%need to add task_2 190 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 191 | V_L_2= double(subs(V_L_sol))>0; 192 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 193 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 194 | 195 | end -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_5.m: -------------------------------------------------------------------------------- 1 | rc = 15; 2 | Ly = 10 ; 3 | Lz = 10 ; 4 | Vg = 1.1; 5 | fg = 265 ; 6 | Rs = 0; 7 | Id_i = linspace(720,1080,12); 8 | R_L_pv = 0.0070; 9 | T_sat = 90.2 ; 10 | errr = 1; 11 | alpha= 0.0017; 12 | lam_A= 0.032; 13 | lam_B= 0.021; 14 | rho_A=0.0020; 15 | rho_B=0.0030; 16 | n=12; 17 | R_L=0.1; 18 | i =1; 19 | a1 = 150; 20 | b1= 250; 21 | lamb_cont= 300; 22 | for l = 1:length(Id_i) 23 | Id = Id_i(l); 24 | disp(l); 25 | i=1; 26 | errr = 1; 27 | a1 = T_sat+1; 28 | b1= 383; 29 | while errr > 10^(-5) 30 | c1 = (a1+b1)/2; 31 | T_pv_i(i,:)= [a1,c1,b1]; 32 | [P(i,1), Eta(i,1),Q_pv(i,1), V_L(i,1),I_L(i,1)]= task_2(R_L_pv, Ly,Lz, Id, rc,a1,Vg); 33 | [P(i,2), Eta(i,2),Q_pv(i,2), V_L(i,2),I_L(i,2)]= task_2(R_L_pv, Ly,Lz, Id, rc,c1,Vg); 34 | [P(i,3), Eta(i,3),Q_pv(i,3), V_L(i,3),I_L(i,3)]= task_2(R_L_pv, Ly,Lz, Id, rc,b1,Vg); 35 | T_H_i(i,:) = T_pv_i(i,:) - Q_pv(i,:)./lamb_cont; 36 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_tee(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,1), T_sat); 37 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_tee(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,2), T_sat); 38 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_tee(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,3), T_sat); 39 | E_Q(i,:) = Q_pv(i,:) - Q_H(i,:); 40 | if E_Q(i,1)>0 && E_Q(i,2) < 0 41 | b1=c1; 42 | else 43 | a1=c1; 44 | end 45 | errr = abs(E_Q(i,2)); 46 | i = i+1; 47 | end 48 | T_H(1,l) = T_H_i(i-1,2); 49 | T_C(1,l)= T_C(i-1,2); 50 | T_pv(1,l) = T_pv_i(i-1,2); 51 | Eta_te(1,l) = Eta_tee(i-1,2); 52 | Eta_pv(1,l)= Eta(i-1,2); 53 | P_pv(1,l) = P(i-1,2); 54 | W_te(1,l)= W(i-1,2); 55 | V_L(1,l)= V_L(i-1,2); 56 | I_L(1,l) = I_L(i-1,2); 57 | P_tot(1,l) = P_pv(1,l)+W_te(1,l); 58 | Eta_tot(1,l) = P_tot(1,l)/ (Id*rc*(0.1^2)); 59 | V_L_te(1,l) = V_L_te(i-1,2); 60 | I_L_te(1,l) = I_L_te(i-1,2); 61 | end 62 | subplot(2,2,1) 63 | plot(Id_i,transpose(Eta_tot),'.'); 64 | title('Subplot 1: Total Efficiency vs Variations in Incident Radiation'); 65 | xlabel('Incident Radiation (W/(m^2))') 66 | subplot(2,2,2) 67 | plot(Id_i,transpose(Eta_te),'.'); 68 | title('Subplot 2: Thermal Efficiency vs Variations in Incident Radiation'); 69 | subplot(2,2,3) 70 | plot(Id_i,transpose(Eta_pv),'.'); 71 | title('Subplot 3: PV Efficiency vs Variations in Incident Radiation'); 72 | subplot(2,2,4) 73 | plot(Id_i,transpose(P_tot), '.'); 74 | 75 | title('Subplot 4: Total Power vs Variations in Incident Radiation'); 76 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 77 | T_p=[293;303;313;333;353]; 78 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 79 | T_pv = horzcat(T_p,ones(5,1)); 80 | co = T_pv\V_oc; 81 | V_oc = [(T), 1]*co; 82 | 83 | %constants 84 | Kb= 1.38*10^-23; 85 | qe= 1.6*10^-19; 86 | L=V_oc*qe/(Kb*(T)); 87 | I0_Iv = 1/(exp(L)-1); 88 | A_pv = (Ly*Lz)/10000; 89 | %I_L = V_L / R_L; 90 | %Eta = V_L * I_L / (p * A_pv); 91 | P_0= Id*rc*A_pv; 92 | 93 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 94 | 95 | syms I_L 96 | 97 | fun= @(x) (x.^2)./(exp(x)-1); 98 | 99 | xmin = qe*Vg/(Kb* 5778); 100 | 101 | inte = integral(fun,xmin,Inf); 102 | 103 | phi_g = phi * 0.416 * inte; 104 | 105 | Iv = phi_g * qe * A_pv; 106 | 107 | I0 =Iv * I0_Iv; 108 | 109 | eqn= (Kb*(T)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 110 | I_L_sol = solve(eqn,I_L); 111 | I_L = double(subs(I_L_sol)); 112 | V_L = I_L*R_L; 113 | Eta = V_L*I_L/ (Id*rc*A_pv); 114 | P = I_L*V_L; 115 | Q_pv = -V_L*I_L + P_0; 116 | end 117 | 118 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 119 | %%%%%add I_l and v_l for this question 120 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 121 | Z= alpha^2 / Rlam_min; 122 | A_pv = 0.1^2; 123 | k_w = 6.5; 124 | t_w = 0.4*10^-2; 125 | U_ev = 25; 126 | 127 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 128 | a = T_sat; 129 | b = T_H+1; 130 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 131 | R =@(m_max) R_L/(n * m_max); 132 | lam = @(R) Rlam_min / R; 133 | fQ_C =@(T_C) A_pv* (k_w/t_w + U_ev) * (T_C-T_sat); 134 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 135 | R_batt = @(R) n* R; 136 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 137 | fQ_H =@(W,Eta) W/Eta; 138 | Q_CTE = @(Q_H, W)Q_H - W; 139 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 140 | err = 1; 141 | while err > 10^(-5) 142 | c=(a+b)/2; 143 | m_max_a =m_max(a); 144 | m_max_b =m_max(b); 145 | m_max_c =m_max(c); 146 | R_a =R(m_max_a); 147 | R_b =R(m_max_b); 148 | R_c =R(m_max_c); 149 | lam_a = lam(R_a); 150 | lam_b = lam(R_b); 151 | lam_c = lam(R_c); 152 | Q_C_a =fQ_C(a); 153 | Q_C_b =fQ_C(b); 154 | Q_C_c =fQ_C(c); 155 | Eta_a =Eta(a, m_max_a); 156 | Eta_b =Eta(b, m_max_b); 157 | Eta_c =Eta(c, m_max_c); 158 | R_batt_a = R_batt(R_a); 159 | R_batt_b = R_batt(R_b); 160 | R_batt_c = R_batt(R_c); 161 | W_a =fW(a, R_batt_a); 162 | W_b =fW(b, R_batt_b); 163 | W_c =fW(c, R_batt_c); 164 | Q_H_a =fQ_H(W_a,Eta_a); 165 | Q_H_b =fQ_H(W_b,Eta_b); 166 | Q_H_c =fQ_H(W_c,Eta_c); 167 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 168 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 169 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 170 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 171 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 172 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 173 | if E_QC_a>0 && E_QC_c < 0 174 | b=c; 175 | else 176 | a=c; 177 | end 178 | err = abs(E_QC_c); 179 | end 180 | 181 | T_C = c; 182 | W = W_c; 183 | Q_H = Q_H_c; 184 | Q_C = Q_C_c; 185 | lam_batt = n*lam_c; 186 | R_batt_2 = R_batt_c; 187 | Eta_te = Eta_c; 188 | syms I_L_te V_L_te 189 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 190 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 191 | %%%%%need to add task_2 192 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 193 | V_L_2= double(subs(V_L_sol))>0; 194 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 195 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 196 | 197 | end -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_5b.m: -------------------------------------------------------------------------------- 1 | function [Power, Heat, T5_f, alpha, W_c, W_t, n_comp,T3, T2_r,cp_23]= task_5b(~) 2 | Qs= 0; 3 | gamma= [0,0.125,0.25,0.375,0.5]; 4 | P1= 101; 5 | T1=298; 6 | P2=500; 7 | T4=1600; 8 | 9 | eff_comp=0.85; 10 | eff_turb=0.85; 11 | eps_regen=0.75; 12 | for l = 1:length(gamma) 13 | i = 1; 14 | T5_f(1,l) =1000; 15 | alpha_stoich = 4.76*(2+3*gamma(l)); 16 | alpha(i,l) = alpha_stoich; 17 | while i<4 18 | m_prod(i,l) = 28.014*3.76*alpha(i,l)/4.76 + 15.9999*2 *(alpha(i,l)/4.76 - 3*gamma(l) -2)+18.01528*(2+2*gamma(l))+44.01*(1+2*gamma(l)); 19 | m_air = 6; 20 | n_dot_air(i,l)= m_air/28.97; 21 | n_prod(i,l) = 3.76*alpha(i,l)/4.76 + (alpha(i,l)/4.76 - 3*gamma(l) -2)+(2+2*gamma(l))+(1+2*gamma(l)); 22 | n_dot_prod(i,l)= m_air/(m_prod(i,l)/n_prod(i,l)); 23 | [T2_final(i,l),W(i,l),cp_2(i,l)] = task_2(T1,P1,P2,eff_comp,1900); 24 | [T5_f(i+1,l), W_5(i,l),cp_5(i,l)] =task_2a(T4,P1,P2, eff_turb,T5_f(i,l), gamma(l),alpha(i,l)); 25 | T_avg_25= 0.5*(T2_final(i,l)+T5_f(i,l)); 26 | [y_h20(i,l), y_co2(i,l), y_n2(i,l), y_o2(i,l), cp_prod(i,l), cp_air(i,l)] = task_3(T_avg_25, gamma(l),alpha(i,l)); 27 | ncp_min = min(cp_prod(i,l)*n_dot_prod(i,l), cp_air(i,l)*n_dot_prod(i,l)); 28 | T2_r(i,l) = T2_final(i,l)+ (ncp_min* eps_regen* (T5_f(i,l)- T2_final(i,l)))/(n_dot_air(i,l)*cp_air(i,l)); 29 | %disp(i); 30 | %disp(n_dot_air(i,l)); 31 | [T3(i,l), cp_23(i,l)] = root_finder(Qs,T2_r(i,l),n_dot_air(i,l)); 32 | %cp_23(i,l) = 28.11+ 0.1967*10^(-2)*((T2_r(i,l))) + 0.4802*10^(-5)*((T2_r(i,l)))^2 - 1.966*10^(-9)*((T2_r(i,l)))^3; 33 | %T3(i,l) = Qs/(n_dot_air(i,l)*cp_23(i,l))+T2_r(i,l); 34 | i = i+1; 35 | alpha(i,l)= task_1(T4, T3(i-1,l), gamma(l)); 36 | end 37 | alpha_f(1,l) = alpha(3,l); 38 | W_t(1,l) = n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l)); 39 | W_c(1,l) = n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1); 40 | Power(1,l)= n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l))- n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1); 41 | [~, ~, ~, ~, cp_burn, ~] = task_3(.5*(T3(i-1,l)+T4), gamma(l),alpha(3,l)); 42 | Heat(1,l) =(n_dot_prod(3,l)*cp_burn*(T4-T3(i-1,l))); 43 | n_comp(1,l) = (n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l))- n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1))/(Heat(1,l)); 44 | end 45 | end 46 | 47 | function [T2_f, W,cp] =task_2(T1,P1,P2, eta_comp, T_guess) 48 | 49 | %guess T2=T2_g to be average, Tf was taken from task 1 50 | T2_g=T_guess; 51 | R=8.314; 52 | 53 | err=1; 54 | while err >0.2 55 | T_avg = 0.5*(T1+T2_g); 56 | cp = 28.11+ 0.1967*10^(-2)*(T_avg) + 0.4802*10^(-5)*(T_avg)^2 - 1.966*10^(-9)*(T_avg)^3; 57 | cv = cp-R; 58 | k= cp/cv; 59 | %first T2 to calculate difference 60 | T2 = T1* (1+((P2/P1)^((k-1)/k) -1)/eta_comp); 61 | %try to get second T2 for difference calculation 62 | T_avg_1 = 0.5*(T1+T2); 63 | cp_1 = 28.11+ 0.1967*10^(-2)*( T_avg_1) + 0.4802*10^(-5)*( T_avg_1)^2 - 1.966*10^(-9)*( T_avg_1)^3; 64 | cv_1 = cp_1-R; 65 | k_1= cp_1/cv_1; 66 | T2_1 = T1* (1+((P2/P1)^((k_1-1)/k_1) -1)/eta_comp); 67 | err= abs(T2-T2_1); 68 | if err <= 0.2 69 | break 70 | else 71 | T2_g = T2; 72 | end 73 | end 74 | T2_f = T2_g; 75 | H2= 0 + cp * (T2_f-T1)/(28.97); 76 | %W=H2-H1, and H1=0 77 | W=H2; 78 | 79 | end 80 | function [T2_f, W,cp] =task_2a(T1,P1,P2, eta_comp, T_guess, gamma,alpha) 81 | %guess T2=T2_g to be average, Tf was taken from task 1 82 | T2_g=T_guess; 83 | R=8.314; 84 | 85 | err=1; 86 | while err >0.2 87 | T_avg = 0.5*(T1+T2_g); 88 | [~, ~, ~, ~, cp_prod, ~] = task_3(T_avg, gamma,alpha); 89 | cp = cp_prod; 90 | cv = cp-R; 91 | k= cp/cv; 92 | %first T2 to calculate difference 93 | T2 = T1* (1+((P1/P2)^((k-1)/k) -1)*eta_comp); 94 | err= abs(T2-T2_g); 95 | if err <= 0.2 96 | break 97 | else 98 | T2_g = T2; 99 | end 100 | end 101 | T2_f = T2_g; 102 | H2= 0 + cp * (T1-T2_f)/(28.97); 103 | %W=H2-H1, and H1=0 104 | W=H2; 105 | 106 | end 107 | 108 | 109 | function [y_h20, y_co2, y_n2, y_o2, cp_prod, cp_air] = task_3(Tp, gamma,alpha) 110 | 111 | %based on the equation given on page1 112 | n_ex = (3.76*alpha/4.76) + (alpha/4.76-3*gamma-2) + (2+2*gamma) + (1+2*gamma); 113 | y_h20 = (2+2*gamma) / n_ex; 114 | y_co2 = (1+2*gamma)/ n_ex; 115 | y_n2 = (3.76*alpha/4.76)/ n_ex; 116 | y_o2 = (alpha/4.76-3*gamma-2) / n_ex; 117 | 118 | %cp of each product 119 | cp_o2 = 25.48 + 1.520*10^(-2)*Tp - 0.7155*10^(-5)*(Tp)^2 + 1.312*10^(-9)*(Tp)^3; 120 | cp_h20 = 32.24 + 0.1923*10^(-2)*Tp + 1.0551*10^(-5)*(Tp)^2 - 3.595*10^(-9)*(Tp)^3; 121 | cp_co2 = 22.26 + 5.981*10^(-2)*Tp - 3.501*10^(-5)*(Tp)^2 + 7.469*10^(-9)*(Tp)^3; 122 | cp_n2 = 28.9 - 0.1571*10^(-2)*Tp + 0.8081*10^(-5)*(Tp)^2 - 2.873*10^(-9)*(Tp)^3; 123 | 124 | %cp of whole product 125 | cp_prod = y_h20*cp_h20 + y_co2*cp_co2 + y_n2*cp_n2 + y_o2*cp_o2; 126 | cp_air = 28.11+ 0.1967*10^(-2)*( Tp) + 0.4802*10^(-5)*( Tp)^2 - 1.966*10^(-9)*( Tp)^3; 127 | end 128 | 129 | function [alpha] = task_1(Tp, Tr, gamma) 130 | 131 | 132 | %the heat of formation from table, [kJ/kmol] 133 | h0_c3h8 =-103850; 134 | h0_ch4 = -74850; 135 | h0_o2 = 0; 136 | h0_h2o = -241820; 137 | h0_co2 = -393520; 138 | h0_n2 = 0; 139 | 140 | %specific heat from table, [kJ/kmol*K] 141 | T_avg = 0.5 * (Tr+Tp); 142 | cp_c3h8 = -4.04 + 30.48*10^(-2)*T_avg - 15.72*10^(-5)*(T_avg)^2 + 31.74*10^(-9)*(T_avg)^3; 143 | cp_ch4 = 19.89 + 5.024*10^(-2)*T_avg +1.269*10^(-5)*(T_avg)^2 - 11.01*10^(-9)*(T_avg)^3; 144 | cp_o2 = 25.48 + 1.520*10^(-2)*T_avg - 0.7155*10^(-5)*(T_avg)^2 + 1.312*10^(-9)*(T_avg)^3; 145 | cp_h2o = 32.24 + 0.1923*10^(-2)*T_avg + 1.055*10^(-5)*(T_avg)^2 - 3.595*10^(-9)*(T_avg)^3; 146 | cp_co2 = 22.26 + 5.981*10^(-2)*T_avg - 3.501*10^(-5)*(T_avg)^2 + 7.469*10^(-9)*(T_avg)^3; 147 | cp_n2 = 28.9 - 0.1571*10^(-2)*T_avg + 0.8081*10^(-5)*(T_avg)^2 - 2.873*10^(-9)*(T_avg)^3; 148 | 149 | %enthalpy 150 | h_c3h8 =h0_c3h8 + cp_c3h8 *(Tr-298.15); 151 | h_ch4 = h0_ch4 + cp_ch4 * (Tr-298.15); 152 | h_o2_i = h0_o2 + cp_o2 * (Tr-298.15); 153 | h_o2_o = h0_o2 + cp_o2 * (Tp-298.15); 154 | h_h2o = h0_h2o + cp_h2o * (Tp-298.15); 155 | h_co2 = h0_co2 + cp_co2 * (Tp-298.15); 156 | h_n2_i = h0_n2 + cp_n2 * (Tr-298.15); 157 | h_n2_o = h0_n2 + cp_n2 * (Tp-298.15); 158 | 159 | alpha = 4.76*(-gamma*h_c3h8 - (1-gamma)*h_ch4 - (3*gamma+2)*h_o2_o + (2+2*gamma)*h_h2o + (1+2*gamma)*h_co2)/(h_o2_i + 3.76*h_n2_i - 3.76*h_n2_o - h_o2_o); 160 | 161 | end 162 | 163 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_5.m: -------------------------------------------------------------------------------- 1 | function [Power, Heat, T5_f, alpha, W_c, W_t, n_comp,T3, T2_r,cp_23]= task_5(~) 2 | Qs= [0,500,1000,1500,2000,2500,3000]; 3 | gamma= 0.25; 4 | P1= 101; 5 | T1=298; 6 | P2=500; 7 | T4=1600; 8 | alpha_stoich = 4.76*(2+3*gamma); 9 | eff_comp=0.85; 10 | eff_turb=0.85; 11 | eps_regen=0.75; 12 | for l = 1:length(Qs) 13 | i = 1; 14 | T5_f(1,l) =1000; 15 | alpha(1,l) = alpha_stoich; 16 | while i<4 17 | m_prod(i,l) = 28.014*3.76*alpha(i,l)/4.76 + 15.9999*2 *(alpha(i,l)/4.76 - 3*gamma -2)+18.01528*(2+2*gamma)+44.01*(1+2*gamma); 18 | m_air = 6; 19 | n_dot_air(i,l)= m_air/28.97; 20 | n_prod(i,l) = 3.76*alpha(i,l)/4.76 + (alpha(i,l)/4.76 - 3*gamma -2)+(2+2*gamma)+(1+2*gamma); 21 | n_dot_prod(i,l)= m_air/(m_prod(i,l)/n_prod(i,l)); 22 | [T2_final(i,l),W(i,l),cp_2(i,l)] = task_2(T1,P1,P2,eff_comp,1900); 23 | [T5_f(i+1,l), W_5(i,l),cp_5(i,l)] =task_2a(T4,P1,P2, eff_turb,T5_f(i,l), gamma,alpha(i,l)); 24 | T_avg_25= 0.5*(T2_final(i,l)+T5_f(i,l)); 25 | [y_h20(i,l), y_co2(i,l), y_n2(i,l), y_o2(i,l), cp_prod(i,l), cp_air(i,l)] = task_3(T_avg_25, gamma,alpha(i,l)); 26 | ncp_min = min(cp_prod(i,l)*n_dot_prod(i,l), cp_air(i,l)*n_dot_prod(i,l)); 27 | T2_r(i,l) = T2_final(i,l)+ (ncp_min* eps_regen* (T5_f(i,l)- T2_final(i,l)))/(n_dot_air(i,l)*cp_air(i,l)); 28 | %disp(i); 29 | %disp(n_dot_air(i,l)); 30 | %[T3(i,l), cp_23(i,l)] = root_finder(Qs(l),T2_r(i,l),n_dot_air(i,l)); 31 | cp_23(i,l) = 28.11+ 0.1967*10^(-2)*((T2_r(i,l))) + 0.4802*10^(-5)*((T2_r(i,l)))^2 - 1.966*10^(-9)*((T2_r(i,l)))^3; 32 | T3(i,l) = Qs(l)/(n_dot_air(i,l)*cp_23(i,l))+T2_r(i,l); 33 | i = i+1; 34 | alpha(i,l)= task_1(T4, T3(i-1,l), gamma); 35 | end 36 | alpha_f(1,l) = alpha(3,l); 37 | W_t(1,l) = n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l)); 38 | W_c(1,l) = n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1); 39 | Power(1,l)= n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l))- n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1); 40 | [~, ~, ~, ~, cp_burn, ~] = task_3(.5*(T3(i-1,l)+T4), gamma,alpha(3,l)); 41 | Heat(1,l) =(n_dot_prod(3,l)*cp_burn*(T4-T3(i-1,l))); 42 | n_comp(1,l) = (n_dot_prod(3,l)*cp_5(3,l)*(T4-T5_f(3,l))- n_dot_air(3,l)*cp_2(3,l)*(T2_final(3,l)-T1))/(Heat(1,l)+Qs(l)); 43 | end 44 | subplot(2,2,1) 45 | plot(Qs, Power ) 46 | xlabel('Q_{solar} (KW)') 47 | ylabel('Power Output(KW)') 48 | subplot(2,2,3) 49 | plot(Qs, Heat) 50 | xlabel('Q_{solar} (KW)') 51 | ylabel('Heat Input in combustor (KW)') 52 | subplot(2,2,2) 53 | plot(Qs, n_comp) 54 | xlabel('Q_{solar} (KW)') 55 | ylabel('Overall Efficiency') 56 | subplot(2,2,4) 57 | plot(Qs, alpha_f) 58 | xlabel('Q_{solar} (KW)') 59 | ylabel('{\alpha}') 60 | 61 | end 62 | 63 | function [T2_f, W,cp] =task_2(T1,P1,P2, eta_comp, T_guess) 64 | 65 | %guess T2=T2_g to be average, Tf was taken from task 1 66 | T2_g=T_guess; 67 | R=8.314; 68 | 69 | err=1; 70 | while err >0.2 71 | T_avg = 0.5*(T1+T2_g); 72 | cp = 28.11+ 0.1967*10^(-2)*(T_avg) + 0.4802*10^(-5)*(T_avg)^2 - 1.966*10^(-9)*(T_avg)^3; 73 | cv = cp-R; 74 | k= cp/cv; 75 | %first T2 to calculate difference 76 | T2 = T1* (1+((P2/P1)^((k-1)/k) -1)/eta_comp); 77 | %try to get second T2 for difference calculation 78 | T_avg_1 = 0.5*(T1+T2); 79 | cp_1 = 28.11+ 0.1967*10^(-2)*( T_avg_1) + 0.4802*10^(-5)*( T_avg_1)^2 - 1.966*10^(-9)*( T_avg_1)^3; 80 | cv_1 = cp_1-R; 81 | k_1= cp_1/cv_1; 82 | T2_1 = T1* (1+((P2/P1)^((k_1-1)/k_1) -1)/eta_comp); 83 | err= abs(T2-T2_1); 84 | if err <= 0.2 85 | break 86 | else 87 | T2_g = T2; 88 | end 89 | end 90 | T2_f = T2_g; 91 | H2= 0 + cp * (T2_f-T1)/(28.97); 92 | %W=H2-H1, and H1=0 93 | W=H2; 94 | 95 | end 96 | function [T2_f, W,cp] =task_2a(T1,P1,P2, eta_comp, T_guess, gamma,alpha) 97 | %guess T2=T2_g to be average, Tf was taken from task 1 98 | T2_g=T_guess; 99 | R=8.314; 100 | 101 | err=1; 102 | while err >0.2 103 | T_avg = 0.5*(T1+T2_g); 104 | [~, ~, ~, ~, cp_prod, ~] = task_3(T_avg, gamma,alpha); 105 | cp = cp_prod; 106 | cv = cp-R; 107 | k= cp/cv; 108 | %first T2 to calculate difference 109 | T2 = T1* (1+((P1/P2)^((k-1)/k) -1)*eta_comp); 110 | err= abs(T2-T2_g); 111 | if err <= 0.2 112 | break 113 | else 114 | T2_g = T2; 115 | end 116 | end 117 | T2_f = T2_g; 118 | H2= 0 + cp * (T1-T2_f)/(28.97); 119 | %W=H2-H1, and H1=0 120 | W=H2; 121 | 122 | end 123 | 124 | 125 | function [y_h20, y_co2, y_n2, y_o2, cp_prod, cp_air] = task_3(Tp, gamma,alpha) 126 | 127 | %based on the equation given on page1 128 | n_ex = (3.76*alpha/4.76) + (alpha/4.76-3*gamma-2) + (2+2*gamma) + (1+2*gamma); 129 | y_h20 = (2+2*gamma) / n_ex; 130 | y_co2 = (1+2*gamma)/ n_ex; 131 | y_n2 = (3.76*alpha/4.76)/ n_ex; 132 | y_o2 = (alpha/4.76-3*gamma-2) / n_ex; 133 | 134 | %cp of each product 135 | cp_o2 = 25.48 + 1.520*10^(-2)*Tp - 0.7155*10^(-5)*(Tp)^2 + 1.312*10^(-9)*(Tp)^3; 136 | cp_h20 = 32.24 + 0.1923*10^(-2)*Tp + 1.0551*10^(-5)*(Tp)^2 - 3.595*10^(-9)*(Tp)^3; 137 | cp_co2 = 22.26 + 5.981*10^(-2)*Tp - 3.501*10^(-5)*(Tp)^2 + 7.469*10^(-9)*(Tp)^3; 138 | cp_n2 = 28.9 - 0.1571*10^(-2)*Tp + 0.8081*10^(-5)*(Tp)^2 - 2.873*10^(-9)*(Tp)^3; 139 | 140 | %cp of whole product 141 | cp_prod = y_h20*cp_h20 + y_co2*cp_co2 + y_n2*cp_n2 + y_o2*cp_o2; 142 | cp_air = 28.11+ 0.1967*10^(-2)*( Tp) + 0.4802*10^(-5)*( Tp)^2 - 1.966*10^(-9)*( Tp)^3; 143 | end 144 | 145 | function [alpha] = task_1(Tp, Tr, gamma) 146 | 147 | 148 | %the heat of formation from table, [kJ/kmol] 149 | h0_c3h8 =-103850; 150 | h0_ch4 = -74850; 151 | h0_o2 = 0; 152 | h0_h2o = -241820; 153 | h0_co2 = -393520; 154 | h0_n2 = 0; 155 | 156 | %specific heat from table, [kJ/kmol*K] 157 | T_avg = 0.5 * (Tr+Tp); 158 | cp_c3h8 = -4.04 + 30.48*10^(-2)*T_avg - 15.72*10^(-5)*(T_avg)^2 + 31.74*10^(-9)*(T_avg)^3; 159 | cp_ch4 = 19.89 + 5.024*10^(-2)*T_avg +1.269*10^(-5)*(T_avg)^2 - 11.01*10^(-9)*(T_avg)^3; 160 | cp_o2 = 25.48 + 1.520*10^(-2)*T_avg - 0.7155*10^(-5)*(T_avg)^2 + 1.312*10^(-9)*(T_avg)^3; 161 | cp_h2o = 32.24 + 0.1923*10^(-2)*T_avg + 1.055*10^(-5)*(T_avg)^2 - 3.595*10^(-9)*(T_avg)^3; 162 | cp_co2 = 22.26 + 5.981*10^(-2)*T_avg - 3.501*10^(-5)*(T_avg)^2 + 7.469*10^(-9)*(T_avg)^3; 163 | cp_n2 = 28.9 - 0.1571*10^(-2)*T_avg + 0.8081*10^(-5)*(T_avg)^2 - 2.873*10^(-9)*(T_avg)^3; 164 | 165 | %enthalpy 166 | h_c3h8 =h0_c3h8 + cp_c3h8 *(Tr-298.15); 167 | h_ch4 = h0_ch4 + cp_ch4 * (Tr-298.15); 168 | h_o2_i = h0_o2 + cp_o2 * (Tr-298.15); 169 | h_o2_o = h0_o2 + cp_o2 * (Tp-298.15); 170 | h_h2o = h0_h2o + cp_h2o * (Tp-298.15); 171 | h_co2 = h0_co2 + cp_co2 * (Tp-298.15); 172 | h_n2_i = h0_n2 + cp_n2 * (Tr-298.15); 173 | h_n2_o = h0_n2 + cp_n2 * (Tp-298.15); 174 | 175 | alpha = 4.76*(-gamma*h_c3h8 - (1-gamma)*h_ch4 - (3*gamma+2)*h_o2_o + (2+2*gamma)*h_h2o + (1+2*gamma)*h_co2)/(h_o2_i + 3.76*h_n2_i - 3.76*h_n2_o - h_o2_o); 176 | 177 | end 178 | 179 | -------------------------------------------------------------------------------- /Gas Turbine System Performance Evaluation/task_4.m: -------------------------------------------------------------------------------- 1 | function [Power, Heat, T5_f, alpha_f, W_c, W_t, n_comp,Work_Class, Heat_Class, n_class]= task_4(~) 2 | P1= 101; 3 | T1=298; 4 | P2=500; 5 | T4=1600; 6 | gamma= .25; 7 | alpha_stoich = 4.76*(2+3*gamma); 8 | Qs=0; 9 | eff_comp=0.85; 10 | eff_turb=0.85; 11 | eps_regen=0.75; 12 | i = 1; 13 | T5_f(1,:) =1000; 14 | alpha(1,:) = alpha_stoich; 15 | while i<4 16 | m_prod(i,:) = 28.014*3.76*alpha(i,:)/4.76 + 15.9999*2 *(alpha(i,:)/4.76 - 3*gamma -2)+18.01528*(2+2*gamma)+44.01*(1+2*gamma); 17 | m_air = 6; 18 | n_dot_air(i,:)= m_air/28.97; 19 | n_prod(i,:) = 3.76*alpha(i,:)/4.76 + (alpha(i,:)/4.76 - 3*gamma -2)+(2+2*gamma)+(1+2*gamma); 20 | n_dot_prod(i,:)= m_air/(m_prod(i,:)/n_prod(i,:)); 21 | [T2_final(i,:),W(i,:),cp_2(i,:)] = task_2(T1,P1,P2,eff_comp,1900); 22 | [T5_f(i+1,:), W_5(i,:),cp_5(i,:)] =task_2a(T4,P1,P2, eff_turb,T5_f(i,:), gamma,alpha(i,:)); 23 | T_avg_25= 0.5*(T2_final(i,:)+T5_f(i,:)); 24 | [y_h20(1,:), y_co2(i,:), y_n2(i,:), y_o2(i,:), cp_prod(i,:), cp_air(i,:)] = task_3(T_avg_25, gamma,alpha(i,:)); 25 | ncp_min = min(cp_prod(i,:)*n_dot_prod(i,:), cp_air(i,:)*n_dot_prod(i,:)); 26 | T2_r(i,:) = T2_final(i,:)+ (ncp_min* eps_regen* (T5_f(i,:)- T2_final(i,:)))/(n_dot_air(i,:)*cp_air(i,:)); 27 | [T3, cp_23] = root_finder(Qs,T2_r(i,:),n_dot_air(i,:)); 28 | i = i+1; 29 | alpha(i,:)= task_1(T4, T3, gamma); 30 | end 31 | 32 | alpha_f = alpha(3,:); 33 | W_t = n_dot_prod(3,:)*cp_5(3,:)*(T4-T5_f(3,:)); 34 | W_c = n_dot_air(3,:)*cp_2(3,:)*(T2_final(3,:)-T1); 35 | Power= n_dot_prod(3,:)*cp_5(3,:)*(T4-T5_f(3,:))- n_dot_air(3,:)*cp_2(3,:)*(T2_final(3,:)-T1); 36 | [~, ~, ~, ~, cp_burn, ~] = task_3(.5*(T3+T4), gamma,alpha(3,:)); 37 | Heat =(n_dot_prod(3,:)*cp_burn*(T4-T3))+ Qs; 38 | 39 | k=(28.11/(28.11-8.314)+ (28.3369/(28.3369-8.314)))/2; 40 | 41 | Work_Class =(eff_turb*(1-(P1/P2)^((k-1)/k))- (1/eff_comp)*(T1/T4)*((P2/P1)^((k-1)/k)-1)); 42 | Heat_Class = (1-eps_regen*(1-eff_turb+eff_turb*((P1/P2)^((k-1)/k)))-(1-eps_regen)*(T1/T4)*(1-(1/eff_comp)+(1/eff_comp)*(P2/P1)^((k-1/k)))); 43 | n_comp = (n_dot_prod(3,:)*cp_5(3,:)*(T4-T5_f(3,:))- n_dot_air(3,:)*cp_2(3,:)*(T2_final(3,:)-T1))/(n_dot_prod(3,:)*cp_burn*(T4-T3)); 44 | n_class = (eff_turb*(1-(P1/P2)^((k-1)/k))- (1/eff_comp)*(T1/T4)*((P2/P1)^((k-1)/k)-1))/(1-eps_regen*(1-eff_turb+eff_turb*((P1/P2)^((k-1)/k)))-(1-eps_regen)*(T1/T4)*(1-(1/eff_comp)+(1/eff_comp)*(P2/P1)^((k-1/k)))); 45 | end 46 | function [T2_f, W,cp] =task_2(T1,P1,P2, eta_comp, T_guess) 47 | 48 | %guess T2=T2_g to be average, Tf was taken from task 1 49 | T2_g=T_guess; 50 | R=8.314; 51 | 52 | err=1; 53 | while err >0.2 54 | T_avg = 0.5*(T1+T2_g); 55 | cp = 28.11+ 0.1967*10^(-2)*(T_avg) + 0.4802*10^(-5)*(T_avg)^2 - 1.966*10^(-9)*(T_avg)^3; 56 | cv = cp-R; 57 | k= cp/cv; 58 | %first T2 to calculate difference 59 | T2 = T1* (1+((P2/P1)^((k-1)/k) -1)/eta_comp); 60 | %try to get second T2 for difference calculation 61 | T_avg_1 = 0.5*(T1+T2); 62 | cp_1 = 28.11+ 0.1967*10^(-2)*( T_avg_1) + 0.4802*10^(-5)*( T_avg_1)^2 - 1.966*10^(-9)*( T_avg_1)^3; 63 | cv_1 = cp_1-R; 64 | k_1= cp_1/cv_1; 65 | T2_1 = T1* (1+((P2/P1)^((k_1-1)/k_1) -1)/eta_comp); 66 | err= abs(T2-T2_1); 67 | if err <= 0.2 68 | break 69 | else 70 | T2_g = T2; 71 | end 72 | end 73 | T2_f = T2_g; 74 | H2= 0 + cp * (T2_f-T1)/(28.97); 75 | %W=H2-H1, and H1=0 76 | W=H2; 77 | 78 | end 79 | function [T2_f, W,cp] =task_2a(T1,P1,P2, eta_comp, T_guess, gamma,alpha) 80 | %guess T2=T2_g to be average, Tf was taken from task 1 81 | T2_g=T_guess; 82 | R=8.314; 83 | 84 | err=1; 85 | while err >0.2 86 | T_avg = 0.5*(T1+T2_g); 87 | [~, ~, ~, ~, cp_prod, ~] = task_3(T_avg, gamma,alpha); 88 | cp = cp_prod; 89 | cv = cp-R; 90 | k= cp/cv; 91 | %first T2 to calculate difference 92 | T2 = T1* (1+((P1/P2)^((k-1)/k) -1)*eta_comp); 93 | err= abs(T2-T2_g); 94 | if err <= 0.2 95 | break 96 | else 97 | T2_g = T2; 98 | end 99 | end 100 | T2_f = T2_g; 101 | H2= 0 + cp * (T1-T2_f)/(28.97); 102 | %W=H2-H1, and H1=0 103 | W=H2; 104 | 105 | end 106 | 107 | 108 | function [y_h20, y_co2, y_n2, y_o2, cp_prod, cp_air] = task_3(Tp, gamma,alpha) 109 | 110 | %based on the equation given on page1 111 | n_ex = (3.76*alpha/4.76) + (alpha/4.76-3*gamma-2) + (2+2*gamma) + (1+2*gamma); 112 | y_h20 = (2+2*gamma) / n_ex; 113 | y_co2 = (1+2*gamma)/ n_ex; 114 | y_n2 = (3.76*alpha/4.76)/ n_ex; 115 | y_o2 = (alpha/4.76-3*gamma-2) / n_ex; 116 | 117 | %cp of each product 118 | cp_o2 = 25.48 + 1.520*10^(-2)*Tp - 0.7155*10^(-5)*(Tp)^2 + 1.312*10^(-9)*(Tp)^3; 119 | cp_h20 = 32.24 + 0.1923*10^(-2)*Tp + 1.0551*10^(-5)*(Tp)^2 - 3.595*10^(-9)*(Tp)^3; 120 | cp_co2 = 22.26 + 5.981*10^(-2)*Tp - 3.501*10^(-5)*(Tp)^2 + 7.469*10^(-9)*(Tp)^3; 121 | cp_n2 = 28.9 - 0.1571*10^(-2)*Tp + 0.8081*10^(-5)*(Tp)^2 - 2.873*10^(-9)*(Tp)^3; 122 | 123 | %cp of whole product 124 | cp_prod = y_h20*cp_h20 + y_co2*cp_co2 + y_n2*cp_n2 + y_o2*cp_o2; 125 | cp_air = 28.11+ 0.1967*10^(-2)*( Tp) + 0.4802*10^(-5)*( Tp)^2 - 1.966*10^(-9)*( Tp)^3; 126 | end 127 | 128 | function [alpha] = task_1(Tp, Tr, gamma) 129 | 130 | 131 | %the heat of formation from table, [kJ/kmol] 132 | h0_c3h8 =-103850; 133 | h0_ch4 = -74850; 134 | h0_o2 = 0; 135 | h0_h2o = -241820; 136 | h0_co2 = -393520; 137 | h0_n2 = 0; 138 | 139 | %specific heat from table, [kJ/kmol*K] 140 | T_avg = 0.5 * (Tr+Tp); 141 | cp_c3h8 = -4.04 + 30.48*10^(-2)*T_avg - 15.72*10^(-5)*(T_avg)^2 + 31.74*10^(-9)*(T_avg)^3; 142 | cp_ch4 = 19.89 + 5.024*10^(-2)*T_avg +1.269*10^(-5)*(T_avg)^2 - 11.01*10^(-9)*(T_avg)^3; 143 | cp_o2 = 25.48 + 1.520*10^(-2)*T_avg - 0.7155*10^(-5)*(T_avg)^2 + 1.312*10^(-9)*(T_avg)^3; 144 | cp_h2o = 32.24 + 0.1923*10^(-2)*T_avg + 1.055*10^(-5)*(T_avg)^2 - 3.595*10^(-9)*(T_avg)^3; 145 | cp_co2 = 22.26 + 5.981*10^(-2)*T_avg - 3.501*10^(-5)*(T_avg)^2 + 7.469*10^(-9)*(T_avg)^3; 146 | cp_n2 = 28.9 - 0.1571*10^(-2)*T_avg + 0.8081*10^(-5)*(T_avg)^2 - 2.873*10^(-9)*(T_avg)^3; 147 | 148 | %enthalpy 149 | h_c3h8 =h0_c3h8 + cp_c3h8 *(Tr-298.15); 150 | h_ch4 = h0_ch4 + cp_ch4 * (Tr-298.15); 151 | h_o2_i = h0_o2 + cp_o2 * (Tr-298.15); 152 | h_o2_o = h0_o2 + cp_o2 * (Tp-298.15); 153 | h_h2o = h0_h2o + cp_h2o * (Tp-298.15); 154 | h_co2 = h0_co2 + cp_co2 * (Tp-298.15); 155 | h_n2_i = h0_n2 + cp_n2 * (Tr-298.15); 156 | h_n2_o = h0_n2 + cp_n2 * (Tp-298.15); 157 | 158 | alpha = 4.76*(-gamma*h_c3h8 - (1-gamma)*h_ch4 - (3*gamma+2)*h_o2_o + (2+2*gamma)*h_h2o + (1+2*gamma)*h_co2)/(h_o2_i + 3.76*h_n2_i - 3.76*h_n2_o - h_o2_o); 159 | 160 | end 161 | function [T3_f, cp23] = root_finder(Qs, T2_r, n_dot_air) 162 | syms cp_23 T3 163 | eqn = [cp_23 == 28.11+ 0.1967*10^(-2)*(0.5*(T3+T2_r)) + 0.4802*10^(-5)*(0.5*(T3+T2_r))^2 - 1.966*10^(-9)*(0.5*(T3+T2_r))^3,T3 == Qs/(n_dot_air*cp_23)+T2_r]; 164 | v = solve(eqn, [cp_23, T3]); 165 | cp_23= vpa(v.cp_23); 166 | T3 = vpa(v.T3); 167 | p = find(T3 >800& T3 < 1500); 168 | T3_f = double(T3(p)); 169 | cp23 = double(cp_23(p)); 170 | end 171 | 172 | -------------------------------------------------------------------------------- /Solar Hybrid Power Design and Analysis/task_6.m: -------------------------------------------------------------------------------- 1 | Id = 1080; 2 | Ly = 10 ; 3 | Lz = 10 ; 4 | Vg = 1.1; 5 | fg = 265 ; 6 | Rs = 0; 7 | rc_i = linspace(10,18,9); 8 | R_L_pv = 0.0070; 9 | T_sat = 90.2 ; 10 | errr = 1; 11 | alpha= 0.0017; 12 | lam_A= 0.032; 13 | n_k = linspace(8,16,9); 14 | lam_B= 0.021; 15 | rho_A=0.0020; 16 | rho_B=0.0030; 17 | R_L=0.1; 18 | i =1; 19 | a1 = 150; 20 | b1= 250; 21 | lamb_cont= 300; 22 | for k = 1:length(rc_i) 23 | rc = rc_i(k); 24 | disp(k); 25 | for l = 1:length(n_k) 26 | n = n_k(l); 27 | i=1; 28 | disp(l); 29 | errr = 1; 30 | a1 = T_sat+1; 31 | b1= 383; 32 | while errr > 10^(-5) 33 | c1 = (a1+b1)/2; 34 | T_pv_i(i,:)= [a1,c1,b1]; 35 | [P(i,1), Eta(i,1),Q_pv(i,1), V_L(i,1),I_L(i,1)]= task_2(R_L_pv, Ly,Lz, Id, rc,a1,Vg); 36 | [P(i,2), Eta(i,2),Q_pv(i,2), V_L(i,2),I_L(i,2)]= task_2(R_L_pv, Ly,Lz, Id, rc,c1,Vg); 37 | [P(i,3), Eta(i,3),Q_pv(i,3), V_L(i,3),I_L(i,3)]= task_2(R_L_pv, Ly,Lz, Id, rc,b1,Vg); 38 | T_H_i(i,:) = T_pv_i(i,:) - Q_pv(i,:)./lamb_cont; 39 | [Z(i,1), Rlam_min(i,1), T_C(i,1),Eta_tee(i,1), W(i,1),Q_H(i,1), Q_C(i,1), V_L_te(i,1), I_L_te(i,1) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,1), T_sat); 40 | [Z(i,2), Rlam_min(i,2), T_C(i,2),Eta_tee(i,2), W(i,2),Q_H(i,2), Q_C(i,2), V_L_te(i,2), I_L_te(i,2) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,2), T_sat); 41 | [Z(i,3), Rlam_min(i,3), T_C(i,3),Eta_tee(i,3), W(i,3),Q_H(i,3), Q_C(i,3), V_L_te(i,3), I_L_te(i,3) ] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H_i(i,3), T_sat); 42 | E_Q(i,:) = Q_pv(i,:) - Q_H(i,:); 43 | if E_Q(i,1)>0 && E_Q(i,2) < 0 44 | b1=c1; 45 | else 46 | a1=c1; 47 | end 48 | errr = abs(E_Q(i,2)); 49 | i = i+1; 50 | end 51 | T_H(k,l) = T_H_i(i-1,2); 52 | T_C(k,l)= T_C(i-1,2); 53 | T_pv(k,l) = T_pv_i(i-1,2); 54 | Eta_te(k,l) = Eta_tee(i-1,2); 55 | Eta_pv(k,l)= Eta(i-1,2); 56 | P_pv(k,l) = P(i-1,2); 57 | W_te(k,l)= W(i-1,2); 58 | V_L(k,l)= V_L(i-1,2); 59 | I_L(k,l) = I_L(i-1,2); 60 | P_tot(k,l) = P_pv(1,l)+W_te(1,l); 61 | Eta_tot(k,l) = P_tot(1,l)/ (Id*rc*(0.1^2)); 62 | V_L_te(k,l) = V_L_te(i-1,2); 63 | I_L_te(k,l) = I_L_te(i-1,2); 64 | end 65 | end 66 | [R,C]= find(P_tot<=50 & P_tot>= 20); 67 | for j = 1:length(R); 68 | P_new_tot(j)= P_tot(R(j),C(j)); 69 | T_pv_new(j) = T_pv(R(j),C(j)); 70 | Eta_new_tot(j) = Eta_tot(R(j),C(j)); 71 | end 72 | T_P_tot = vertcat(P_new_tot,T_pv_new, n_k(C),rc_i(R),Eta_new_tot); 73 | [X,Y] = meshgrid(rc_i,n_k); 74 | subplot(2,2,1) 75 | plot(rc_i,P_tot); 76 | title('Subplot 1: Total Power vs Variations in Concentration Ratio'); 77 | xlabel('Concentration Ratios') 78 | ylabel('Total Power (W)') 79 | legendCell = cellstr(num2str(n_k', 'n=%-d')); 80 | legend(legendCell, 'Location', 'southeast') 81 | subplot(2,2,2) 82 | plot(rc_i,Eta_tot); 83 | xlabel('Concentration Ratios') 84 | ylabel('Total Efficiency') 85 | legendCell = cellstr(num2str(n_k', 'n=%-d')); 86 | legend(legendCell, 'Location', 'southeast') 87 | title('Subplot 2: Total Efficiency vs Variations in Concentration Ratio'); 88 | subplot(2,2,[3,4]) 89 | plot(rc_i,T_pv); 90 | xlabel('Concentration Ratios') 91 | ylabel('Temperature of the PV Cell (K)') 92 | legendCell = cellstr(num2str(n_k', 'n=%-d')); 93 | legend(legendCell, 'Location', 'southeast') 94 | title('Subplot 3: T_PV vs Variations in Concentration Ratio'); 95 | surf(X,Y,Eta_tot) 96 | rotate3d on 97 | surf(X,Y,Eta_tot) 98 | rotate3d on 99 | xlabel('Concentration Ratios') 100 | ylabel('Thermoelectric Pairs') 101 | zlabel('Total Efficiency') 102 | title('Total Efficiency vs Concentration ratio vs No. of Thermoelectric Pairs') 103 | surf(X,Y,P_tot) 104 | rotate3d on 105 | xlabel('Concentration Ratios') 106 | ylabel('Thermoelectric Pairs') 107 | zlabel('Total Power') 108 | title('Total Power vs Concentration ratio vs No. of Thermoelectric Pairs') 109 | surf(X,Y,T_pv) 110 | rotate3d on 111 | xlabel('Concentration Ratios') 112 | ylabel('Thermoelectric Pairs') 113 | zlabel('Temperature of Photovoltaic Cell (K)') 114 | title('T_pv vs Concentration ratio vs No. of Thermoelectric Pairs') 115 | function [P, Eta,Q_pv, V_L,I_L] = task_2(R_L, Ly, Lz, Id,rc,T, Vg) 116 | T_p=[293;303;313;333;353]; 117 | V_oc=[0.39;0.37;0.35;0.32;0.27]; 118 | T_pv = horzcat(T_p,ones(5,1)); 119 | co = T_pv\V_oc; 120 | V_oc = [(T), 1]*co; 121 | 122 | %constants 123 | Kb= 1.38*10^-23; 124 | qe= 1.6*10^-19; 125 | L=V_oc*qe/(Kb*(T)); 126 | I0_Iv = 1/(exp(L)-1); 127 | A_pv = (Ly*Lz)/10000; 128 | %I_L = V_L / R_L; 129 | %Eta = V_L * I_L / (p * A_pv); 130 | P_0= Id*rc*A_pv; 131 | 132 | phi = (Id*rc*2.404*15)/(pi^4*Kb*(5778)); 133 | 134 | syms I_L 135 | 136 | fun= @(x) (x.^2)./(exp(x)-1); 137 | 138 | xmin = qe*Vg/(Kb* 5778); 139 | 140 | inte = integral(fun,xmin,Inf); 141 | 142 | phi_g = phi * 0.416 * inte; 143 | 144 | Iv = phi_g * qe * A_pv; 145 | 146 | I0 =Iv * I0_Iv; 147 | 148 | eqn= (Kb*(T)/qe)*log(((Iv- I_L)/I0)+1)- I_L*R_L==0; 149 | I_L_sol = solve(eqn,I_L); 150 | I_L = double(subs(I_L_sol)); 151 | V_L = I_L*R_L; 152 | Eta = V_L*I_L/ (Id*rc*A_pv); 153 | P = I_L*V_L; 154 | Q_pv = -V_L*I_L + P_0; 155 | end 156 | 157 | function [Z, Rlam_min, T_C,Eta_te, W,Q_H, Q_C, V_L_te, I_L_te] = task_3_2(alpha, lam_A, lam_B, rho_A, rho_B, n, R_L, T_H, T_sat) 158 | %%%%%add I_l and v_l for this question 159 | Rlam_min = ((lam_A*rho_A)^0.5 + (lam_B*rho_B)^0.5)^2; 160 | Z= alpha^2 / Rlam_min; 161 | A_pv = 0.1^2; 162 | k_w = 6.5; 163 | t_w = 0.4*10^-2; 164 | U_ev = 25; 165 | 166 | % guess T_C = (T_H + T_sat)/2 = (323+95)/2 = 209 K 167 | a = T_sat; 168 | b = T_H+1; 169 | m_max =@(T_C) (1 + 0.5*(T_H+T_C)*Z)^0.5; 170 | R =@(m_max) R_L/(n * m_max); 171 | lam = @(R) Rlam_min / R; 172 | fQ_C =@(T_C) A_pv*(k_w/t_w + U_ev) * (T_C-T_sat); 173 | Eta =@(T_C, m_max) ((T_H-T_C) / T_H) *(((1+m_max)^2 / m_max) * (Z*T_H)^(-1) + 1 + (1/(2*m_max))*(1+T_C/T_H))^(-1); 174 | R_batt = @(R) n* R; 175 | fW =@(T_C, R_batt) (n^2 * alpha^2 * (T_H-T_C)^2 * R_L )/ ((R_L + R_batt)^2); 176 | fQ_H =@(W,Eta) W/Eta; 177 | Q_CTE = @(Q_H, W)Q_H - W; 178 | E_QC =@(Q_CTE, Q_C) Q_CTE - Q_C; 179 | err = 1; 180 | while err > 10^(-5) 181 | c=(a+b)/2; 182 | m_max_a =m_max(a); 183 | m_max_b =m_max(b); 184 | m_max_c =m_max(c); 185 | R_a =R(m_max_a); 186 | R_b =R(m_max_b); 187 | R_c =R(m_max_c); 188 | lam_a = lam(R_a); 189 | lam_b = lam(R_b); 190 | lam_c = lam(R_c); 191 | Q_C_a =fQ_C(a); 192 | Q_C_b =fQ_C(b); 193 | Q_C_c =fQ_C(c); 194 | Eta_a =Eta(a, m_max_a); 195 | Eta_b =Eta(b, m_max_b); 196 | Eta_c =Eta(c, m_max_c); 197 | R_batt_a = R_batt(R_a); 198 | R_batt_b = R_batt(R_b); 199 | R_batt_c = R_batt(R_c); 200 | W_a =fW(a, R_batt_a); 201 | W_b =fW(b, R_batt_b); 202 | W_c =fW(c, R_batt_c); 203 | Q_H_a =fQ_H(W_a,Eta_a); 204 | Q_H_b =fQ_H(W_b,Eta_b); 205 | Q_H_c =fQ_H(W_c,Eta_c); 206 | Q_CTE_a = Q_CTE(Q_H_a, W_a); 207 | Q_CTE_b = Q_CTE(Q_H_b, W_b); 208 | Q_CTE_c = Q_CTE(Q_H_c, W_c); 209 | E_QC_a =E_QC(Q_CTE_a, Q_C_a); 210 | E_QC_b =E_QC(Q_CTE_b, Q_C_b); 211 | E_QC_c =E_QC(Q_CTE_c, Q_C_c); 212 | if E_QC_a>0 && E_QC_c < 0 213 | b=c; 214 | else 215 | a=c; 216 | end 217 | err = abs(E_QC_c); 218 | end 219 | 220 | T_C = c; 221 | W = W_c; 222 | Q_H = Q_H_c; 223 | Q_C = Q_C_c; 224 | lam_batt = n*lam_c; 225 | R_batt_2 = R_batt_c; 226 | Eta_te = Eta_c; 227 | syms I_L_te V_L_te 228 | eqn1=V_L_te- (n*alpha*(T_H-T_C))-R_batt_2*I_L_te==0; 229 | eqn2= Q_H- n*alpha*I_L_te*T_H- lam_batt*(T_H-T_C)-0.5*((I_L_te)^2)*R_batt_2==0; 230 | %%%%%need to add task_2 231 | [V_L_sol, I_L_sol] = solve([eqn1,eqn2],V_L_te,I_L_te,'IgnoreAnalyticConstraints', true); 232 | V_L_2= double(subs(V_L_sol))>0; 233 | V_L_te = double(V_L_sol(double(subs(V_L_sol))>0)); 234 | I_L_te = double(I_L_sol(double(subs(I_L_sol))>0)); 235 | 236 | end --------------------------------------------------------------------------------