Create a model to solve an energy balance

Hi, I am trying to use MATLAB to create a model that can solve a set of equations. I have attached an image of the equations I am trying to solve. Essentially, there are 3 unknowns, Tout, Tp & Tg.
I wanted to ask which would be the best way to solve this on MATLAB, i have tried to use matrices but the temperatures I am getting are very high. Is there any other method that could be used to solve these equations?
Kind regards

11 Comments

Can you attach the data? What values are known and what are uknown?
Hi darova
I have attached the data I have, those highlighted in yellow need to be determined iteratively which is where I keep going wrong.
Regards
Did you try fsolve?
i haven't used fsolve in MATLAB before, I tried using matrices however that didn't work for me.
You can't use matrices because you have nonlinear equations
Yes I am aware that was one of the mistakes I was making. Is there any tutorial or example I could follow that would show me how to use the fsolve in a case similar to this?
MATLAB has good help page
Or just solve example
syms Tm Tp Tg hg hrpg
eq1 = ag*I + hg*(Tg-Tm) + hrpg*(Tp-Tg) - ...
eq2 = hg*A*(Tm-Tg) + ...
eqs = [eq1 eq2 .. eq6];
vars = symvar(eqs);
S = solve(eqs,vars);
Thank you for your response, I have tried that but it doesn't output any values? Or am i missing something?
clc
syms Tm Tp Tg Tout hrgs hrpg
I = 750; %Solar radiation
Ta = 330; %ambient temperature
Tin = Ta; %inlet temperature
m = 0.02; %mass flowrate
cp = 1; %specific heat capacity of air
ag = 0.01; %glass absorption
taug = 0.91; %glass transmissivity
ap = 0.95; %plate absorption
Eg = 0.96; %glass emittance
Ep = 0.3; %plate emittance
Sigma = 5.67E-8; %Boltzman constant
L = 0.2; %Collector Length
W = 1.2; %Collector Width
A=L*W; %Collector Area
hw = 5;
hp = 10;
hg = 10;
eq1 = ag*I + hg*(Tg-Tm) + hrpg*(Tp-Tg) - (hw+hrgs)*(Tg-Ta)
eq2 = hg*A*(Tm-Tg)+ m*cp*(Tout-Tin)-A*hp*(Tp-Tm)
eq3 = hp*(Tp-Tm)+hrpg*(Tp-Tg)--ap*taug*I
eq4 = 2*Tm-Tin-Tout
eq5 = hrpg - (Sigma*((Tp^2)+(Tg^2))*(Tp+Tg))/((1/Ep)+(1/Eg)-1)
eq6 = hrgs - Sigma*Eg*((Tg^4)-(Ta^4))/(Tg-Ta)
eqs = [eq1 eq2 eq3 eq4 eq5 eq6];
vars = symvar(eqs);
S = solve(eqs,vars);
Again, thank you!
with regards to this line: [Tg Tout Tp Tm hrpg hrgs] = deal(x(1),x(2),x(3),x(4),x(5),x(6));
is this the order in which the answers are outputted? i.e. Tg = Value 1, Tout = Value 2
Yes
Experiment with x0 (initial guess) for different outputs

Sign in to comment.

Answers (2)

Hi, I get two solutions:
No. 1 2
tg -328.861557610457 -549.471818197512
tm 1.72830356360143 -541.712011528394
hrpg -0.00727597589137702 -11.1180945451184
tp 326.846969797053 -548.48073838475
hrgs 0.0134500837438822 -4.90776624779464
tout -326.543392872797 -1413.42402305679

5 Comments

Hi Alex, thank you for your response.
Unfortunately those solutions are not accurate for this model. For the model to be correct, the output temperatures should be in the range of 300-350 and not negative.
Kind regards
if parameter tm is in the range of 300-350, then the result should be:
tm: 330.8818199199
tg: 330.390690546287
hrpg: 2.43454558766769
tp: 331.387646292175
hrgs: 7.83839735511287
tout: 331.7636398398
Feval:
3.02957658959713E-12
7.26019244723375E-12
1.32972655109143E-9
0
7.17292891749821E-12
-2.30926389122033E-14
Hi, I have found a mistake in my model, which is perhaps why you're getting different results.
eq1 should read as ag*I + hg*(Tg-Tm) + hrpg*(Tp-Tg) + (hw+hrgs)*(Tg-Ta)
Perhaps this may provide some accurate values?
then the result will be:
tm: 330.112356511329
tg: 329.614806294714
hrpg: 2.41746002404232
tp: 330.611779336469
hrgs: 7.81080204482525
tout: 330.224713022658
Feval:
9.35251875944232E-12
-6.95421498164706E-12
-1.83834281131112E-10
-5.6843418860808E-14
-3.1827873669954E-12
-3.30402372128447E-13
Hi, Could you show me how you coded this?

Sign in to comment.

Afaf
Afaf on 15 Dec 2024
% Consts mcp_g2 = 1 * 800; alpha_g = 0.35; tau_g = 0.35; A = 1.20; G = 910; hc2 = 4.4; Tab = 30; hc1_g1_g2 = 3.8; hcl = 13.8; Ag2 = 1; sigma = 5.669e-6; S = 0.18; Tam = 30; Tg1 = 300; Eg1 = 0.35; Eg2 = 0.35;
% Time span and initial condition (chat gbtعشان تتوجد حلول المعادلة الحل دا % اقترحو(مكن تكون اي قيمة ما فارقة م t_span = [0 200]; % Simulation time in seconds Tg2_0 = 300; % Initial guess for Tg2
% the differential equation dTg2_dt = @(t, Tg2) (1 / mcp_g2) * (alpha_g * tau_g * A * G + hc2 * A * (Tab - Tg2) + hc1_g1_g2 * A * (Tg1 - Tg2) + Ag2 * sigma * ((Tg1^4 - Tg2^4)) / (1 / Eg1 + 1 / Eg2 - 1) + (Tab^2 + Tab^2) * (Tg1 + Tab) * (Tab - Tg2) * sigma * S / (1 / Eg1 + 1 / Eg2 - 1));
% Solve the ODE [t, Tg2] = ode45(dTg2_dt, t_span, Tg2_0);
% Plot of results figure; plot(t, Tg2, 'LineWidth', 2); xlabel('Time (s)'); ylabel('Temperature (K)'); title('Temperature vs Time'); grid on;

1 Comment

Whay are the best Method to solve the differental equations of solar energy system by using Matlab and How to creat the Design modle of solar cooker by using Matlab Sumiulk

Sign in to comment.

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 30 Mar 2020

Commented:

on 15 Dec 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!