n2 adiabatic

advertisement
2.141, Assignment#5 – 21 November, 2002
Matter-Transport and Convection
Will Booth
W. Booth
08/18/04
1 Nomenclature
Arabic
Surface area of tank 1
Surface area of tank 2
Valve (throat) cross-sectional area
Coefficient of discharge for air expansion on valve exit
Specific heat of air at constant volume
Diameter of tank 1
Diameter of tank 2
Diameter of valve (throat)
Heat transfer coefficient (tank → environment)
Length of tank 1
Length of tank 2
Molecular weight of air
Mass of air in tank 1
Mass of air in tank 2
Pressure in tank 1
Pressure in tank 2
Universal gas constant
Total entropy of tank 1
Total entropy of tank 2
Entropy flux to the environment from tank 1
Entropy flux to the environment from tank 2
Entropy flux across valve
Temperature of tank 1
Temperature of tank 2
Ambient temperature
Volume of tank 1
Volume of tank 2
Greek
ratio of specific heats (Cp / Cv)
density in tank 1
density in tank 2
W. Booth
08/18/04
2 Results
Part 1 – Bond graph and state equation derivation
The bond graph for the two-tank / valve system is shown below. State variables S1, N1, S2, N2 are chosen.
Figure 2-1: Bond graph for 2-tank system with throttling through a valve and heat transfer to
environment.
State equations are derived as follows:
Looking at the throttling process with respect to the throat, relative to the upstream
conditions:
Following the logic outlined in the notes, the non-bulk flow terms can be neglected, because
we are satisfying continuity with:
i.e. no leakage. Therefore, the remaining terms in a power balance are the "flow work rate",
and the "kinetic energy transport rate", to use the suggested terminology.
Thus, a power balance from input to throat is:
W. Booth
08/18/04
where the units of ρ are [lb-mol / in3] and the units of Mair are [1 / mol]. Subscript ' u' denotes
upstream parameters, and subscript 't' denotes parameters at the throat.
Cancelling mass flow rates, and assuming there is negligible upstream velocity, re-arranging,
gives:
i.e. in terms of molar mass, the mass flow-rate at the throat is:
and making the suggested assumption that all the flow work goes into speeding up the flow,
and not compressing the air:
where the units of N are [lb-mol] and the units
of P are [psi]
A problem arises, since from the ideal gas law:
Therefore, to get mass flow, we require Pu > Pt , which implies Tu > Tt , and therefore, uu >
ut , and hu > ht which disagrees with the common assumption that throttling is isenthalpic.
To reconcile this inconsistency, it is recognised that we measure the flow, pressure and
temperature downstream of the throttle, therefore mixing will occur between throat-flow and
the downstream gas. If this mixing is assumed to occur at constant pressure, and continues
until Tu = Td then, the process will be isenthalpic, as commonly assumed.
To determine equations for entropy flux, per the definition of specific entropy:
therefore
The entropy flux in a particular tank is, given the sign conventions in the system bond graph
(in terms of total entropy)
i.e. the entropy flux is equal to the specific entropy multiplied by the mass flux minus the
change in entropy due to heat transfer to the environment.
Specifically:
and
W. Booth
08/18/04
Choosing state variables, S1, N1, S2, and N2 , the above equations are 2 of the state
equations, and the other 2 are the equations for mass flowrate through the throttle above,
where
since all the mass which leaves tank 1 arrives in tank 2 (assumption of no leakage)
But, to determine the heat lost to the environment and the pressure in each tank, we need an
expression for the temperature of each tank, which can be derived as follows:
Recalling the expression of the 1st law from assignment 3:
(specific quantities)
Therefore, in terms of total quantities:
(since the tank is of fixed volume)
From the definition of internal energy:
(where M is the molar weight, and N has units of lb-mol)
So:
Therefore:
(where Ti is the initial temperature, and S i is the reference
entropy)
The pressure in the chamber can be calculated from the ideal gas law, since we are
assuming that we can model air as an ideal gas, therefore:
(where Ru is the universal gas constant)
and since the volume of each tank is fixed:
An attempt at linearization of the equations for the 3-port capacitor with the mechanical work port closed, is
shown in Appendix A. This system could then be coupled with the linearized four port resistor model shown in
the class notes, to provide some insight to the system. I could not successfully linearize the capacitor model,
however, because the cross-partial terms representing the couple between domains weren’t equal, therefore not
satisfying Maxwell’s reciprocity conditions.
Part 2a – Simulation results
Matlab m-files for all the simulations are contained in Appendix B. Results for simulations with h=0, 0.0001,
0.001,0.01 and 1 ft-lbf / sec-in -R are shown in Figure 2-2. I used values for h suggested in the problem
statement(directly in ft-lbf/sec-in -R as opposed to BTU/sec-R), but when multiplied by the surface area of the
tanks, the result is approximately equivalent hence the results show the range of responses intended by the
suggested values.
2
2
W. Booth
08/18/04
Figure 2-2: Simulation results for part 2a with various values of h
One aspect of note, regarding the simulation, came about in discussion of this problem set with Tom Bowers.
He had found that the solution of the problem was more efficient and less noisy when using a stiff ODE solver,
like ode15s, rather than a non-stiff solver like ode45. Matlab does not offer a definition of “stiffness”, so I went
looking on the web for a definition of a stiff vs. non-stiff system. One reference indicates there is no exact
definition of stiffness, but that when using Runge-Kutta solvers of order 4 or 5, symptoms of stiffness are
non-efficient numerical solution (small time steps) and oscillations in the response. In addition, if I had been
able to linearize my system equations, I could have plotted the eigenvalues for the initial time, and then at some
later time, and looked to see that
they move significantly, indicating the system is stiff.
When I solve my system equations with no heat transfer (h = 0) and using ode45, and vary the relative tolerance
I get the following results:
whereas with ode15s solver:
W. Booth
08/18/04
These results, suggest symptoms of a stiff problem, and the plot of ode45 results for the first two values of
relative tolerance shows that when the tolerance is large, the response is oscillatory, whereas if the tolerance is
much reduced, the solver is less efficient, but produces a smooth response.
Figure 2-3: Simulation results for ode45 solver with different relative tolerances
The initial conditions of the system are shown in the Table 2-1, with corresponding units given in section 1.
Table 2-1: Table of initial conditions
For the adiabatic process (h=0), by definition there is no heat loss to the environment, therefore, the initial
pressure difference between the two tanks drives mass flow from left to right, until the pressures are in
equilibrium, at which point there is no further changes. The mass of air in tank 1 remains greater than the mass
in tank 2, whereas the temperature in tank 2 is greater than the temperature in tank 1, i.e., N 1 > N2, and T1 < T2.
What tank 1 loses in pressure, it must also lose in temperature, from the ideal gas law. Comparing the
equilibrium conditions in Table 2-2 with the initial conditions in Table 2-1, the total entropy decrease in tank 1,
is equal to the total entropy increase in tank 2. As expected, the ideal system conserves entropy.
Part 2b & 2c – Transient Overshoot and Tank Equilibrium Conditions
Figure 2-2 shows that as the heat transfer between the tanks and the environment increases, the following
occurs:
1. Settling time of pressure transient increases
2. Temperatures settle to ambient (if h ≠ 0) and settle faster as h increases.
3. Total entropy of the tanks return to their initial values (while the entropy of the environment increases)
4. Mass of air in the two tanks equalizes, as the tank temperatures reduce to ambient
W. Booth
08/18/04
I had not expected results 1,3 or 4. I expected the pressure transients to settle independent of the heat transfer
coefficient. The reason this is not the case, is because of the coupling between the pressure, temperature and
mass flowrate, i.e. the fact that this is a 3-port capacitor. The pressure difference between the tanks dominates
the initial response, but thereafter, it is the heat transfer to the environment, which governs the settling time of
the system. Some of the initial entropy produced is lost to the environment, therefore the temperature of tank 2
does not initially increase as rapidly as in the adiabatic case, nor does tank 1’s temperature decrease as rapidly.
Therefore, the pressure difference between the two tanks is maintained for longer, until the response is governed
primarily by the heat transfer to the environment, and thus, the pressure difference can only decay as quickly as
the pressure difference (see settling times for h=0.001 and h=0.01 in Table 2-3.
The pressure difference between the two tanks is plotted in Figure 2-4.
Figure 2-4: Pressure difference between tanks 1 and 2
Given that the “R” elements all have temperature in, entropy flow rate out (i.e. “conductance”) causality on both ports, and
through-power flow, these elements guarantee satisfaction of the 2nd law of thermodynamics. It is not the absolute value of
entropy which can never decrease, it is the rate of entropy production that must never decrease, therefore my initial surprise
that the entropy of tank 1 initially decreases and subsequently returns to its initial value is expected. This is due to the fact
that when T1 > Tamb then the entropy of tank 1 will decrease (disregarding mass transfer for the time being), but if T1 <
Tamb the entropy of tank 1 will increase.
An interesting result occurs when the heat transfer coefficient is low, i.e. h=0.0001 ft-lbf/sec-in2-R. The pressure difference
decays to the adiabatic equilibrium condition of ~17.5psi almost as quickly as the adiabatic case itself, i.e. the settling time
for the initial temperature/entropy and pressure/mass transients is 22sec. After which, the heat drain to the environment
causes the pressure in both tanks to decay to the isothermal equilibrium conditions (for h=1) over a much longer timer
(>600sec). At first glance, there is no pressure difference to cause this final mass flow to equilibrium. However, the gradual
entropy generation as the temperature reduces to ambient, decreases the pressure more in tank 2 than in tank 1 (since T2 >
T1) which results in mass flow between tank 1 and tank 2, tending to equalize the masses of air in both tanks. This is as
expected, since at equilibrium, even though not shown in Figure 2-2, both tanks will be at the same temperature and
pressure.
W. Booth
08/18/04
This case (h=0.0001) is the perfect example of the 2-stage process alluded to earlier, since the stages are distinct.
The first stage is mass flow due to significant pressure differences between the tanks. The second stage is
gradual change of tank temperature to ambient, and the equalization of air masses in each tank, due to heat loss
to the environment. The time constant of the second stage is much longer than the time constant of the first
stage, hence the prolonged pressure settling times as the heat transfer coefficient increases (see Table 2-3).
The temperature and entropy overshoot is a result of the trade-off between the time constants of the 2 processes,
the initial mass flow due to significant pressure differences between the tanks and the subsequent change in tank
temperatures due to heat transfer to the environment. In the extreme cases for h=0 (adiabatic) or h=1
(isothermal), there is no overshoot, since there is only a single process, due to mass flow as a result of ∆P.
As the heat transfer coefficient increases to isothermal conditions (h=1) the temperature and entropy transients
will tend to settle faster, and in the isothermal limit, there is no transient since temperature and entropy in each
tank are always equal to their initial conditions.
The following shows the equilibrium conditions for the mass, temperature, pressure and entropy in each tank at
the end of the transients, for the various heat transfer coefficients (with units given in section 1).
Table 2-2: Table of equilibrium conditions
Temperature /
Entropy
settling time
[seconds]
Pressure /
Mass settling
time
[seconds]
Table 2-3: Table of approximate settling times
????????????DO STUDY WITH T1 = T2 < TAMB ?????
????????????OR T1 < T2 = TAMB = 100°F ????????
Part 3 – Tank 1 = Constant Pressure Supply
Tank 1 is now given dimensions of 40” diameter and 60” length, to simulate a constant pressure supply. The results
are shown in Figure 2-5. The pressure of tank 1 is more or less constant, as desired, and its temperature does not
change from its initial condition. The entropy and mass of the air in tank 1 are significantly greater than that in tank
2 therefore, only results for tank 2 are plotted. The results show that the qualitative response of tank 2 is identical to
that shown in Figure 2-2, except that the tank equilibrium pressure is now = to the supply pressure (20psia) since the
supply pressure does not change.
The state equations assume knowledge of the initial entropy of the supply air, as well as its initial pressure, so both
these quantities must be specified in order to determine the transient response of the system.
W. Booth
08/18/04
Figure 2-5: Simulations for Tank1 = constant-pressure supply
Part 4 – Model heat transfer across the valve
Adding heat transfer across the valve, introduces an additional R element into the bond graph, shown in Figure
2-6.
My initial calculations for a heat transfer coefficient, kA/L for a 0.005” coating of cadmium on a one meter
longinterconnecting tube, set kA/L = 2.062E-5 ft-lbf/sec-R.
Initial simulations with this value of kA/L gave no change in the transient response, because the entropy change
dueto heat transfer across the valve was minimal, even without heat transfer to the environment. Therefore, to
show the effects of heat transfer across the valve, kA/L was artificially inflated by a factor of 10 , and the
simulation results are shown in Figure 2-7. As expected, even with no heat transfer to the environment, the
temperatures in the two tanks will equilibrate over time.
4
The pressure transient shows an interesting response, due to the slow changing temperature and tank air mass
responses.
W. Booth
08/18/04
Figure 2-6: System bond graph with added model of heat transfer across the valve
W. Booth
08/18/04
Figure 2-7: Simulations with heat transfer across valve (kA/L = 2.062E-1 ft-lbf/sec-R), and h=0 (no heat
transfer to environment)
Part 5 – Choked flow
Using the following more accurate equations for subsonic flow:
and the following equation for choked flow:
The system equations are modified, and the results, for P 1 (init) = 200psi are shown in Figure 2-8. 200psi was
chosen as representative of choked flow, since P d / P1 < 0.528. The results are not very satisfactory, because:
1) The ode15s solver no longer converged, so I had to resort to ode45, which gives oscillatory response at
Equilibrium
2) More importantly, the temperature of tank 2 can get incredibly high, if there is no heat transfer to the
environment, therefore there will be a large temperature differential across the valve due to the high pressures
involved, even without considering the effects of the shock. Thus I conclude that I need a better model of the
heat transfer across the valve, because the one for the cadmium-coated interconnecting pipe did not give me an
accurate coefficient of heat transfer.
W. Booth
08/18/04
Figure 2-8: Simulations for choked flow, with P1 (init) = 200psia
References:
Hogan, N. 2.141 Lecture Notes MIT. Fall, 2002.
Massey, B.S. Mechanics of Fluids 6th ed. London: Chapman & Hall, 1992.
Rogers, G.F.C and Mayhew, Y.R. Thermodynamic and Transport Properties of Fluids 5 th ed. Oxford:
Blackwell,1995.
http://thermal.sdsu.edu/testcenter/indexjavaapplets.html
W. Booth
08/18/04
APPENDIX A: Linearization of multi-port capacitor equations
Given the 3-port capacitor, with the mechanical port closed, we must choose a
causal-assignment to determine the form of the linearized equations, hence, choose form as
above, with S and N as inputs, and T and G as outputs on each port, respectively. Hence,
the form we are looking for is the following:
(evaluated at So , No operating point)
The expression for T is as used in the analysis. The expression for G is as follows:
where T(S) and P(S):
Evaluating the matrix of partials:
substituting for dT/dS and evaluating dP/dS and factoring common factor, gives:
substituting for dT/dN and evaluating dP/dN and factoring common factor, gives:
Therefore, it appears that my linear model does not satisfy Maxwell’s reciprocity conditions, because dG/dS
does not equal dT/dN.
I thought I had kept track of all my variables in terms of the state variables, S, and N, but I still do not see where
I have made my mistake?
W. Booth
08/18/04
APPENDIX B: Matlab M-Files
%Assignment #5 -- 2.141
%due: 21 Nov 02
W.Booth
%Assumptions:
% 1) ...
% 2) ...
global T1_init N1_init S1_init M_air Cv_air V_tank1 V_tank2 R_universal T2_init N2_init S2_init At h Asurf1
Asurf2 Tamb Question gamma_air Cd
%Change as required, to simulate various parts of problem.
Question = 5
%given
D_tank2 = 10; %in
L_tank2 = 30; %in
if Question == 3
D_tank1 = 40; %in
L_tank1 = 60; %in
else
D_tank1 = 10; %in
L_tank1 = 30; %in
end
if Question ~= 5
P1_init = 20; %lbf/in^2
else
P1_init = 200; %lbf/in^2
end
P2_init = 14.7; %lbf/in^2
T1_init = 70 + 459.67; %R -- need calc. in absolute temperature
T2_init = 70 + 459.67;
Tamb = 70 + 459.67;
Dt = 0.1; %in
%known
R_universal = 1545; %ft-lbf/lb-mol-R -- p.26 of Rogers' and Mayhew's "Thermodynamic & Transport Prop. of
Fluids"
M_air = 28.94; %1/mol -- http://www.rwc.uc.edu/koehler/biophys/8a.html
gamma_air = 1.4; %p.16 of Rogers and Mayhew
Cd = 0.5 ; %discharge coefficient
%calculations
V_tank1 = (1/4)*pi*(D_tank1^2)*L_tank1; %in^3
V_tank2 = (1/4)*pi*(D_tank2^2)*L_tank2; %in^3
At = (1/4)*pi*(Dt^2); %in^2 -- throttle area
Asurf1 = pi*D_tank1*L_tank1; %in^2 -- surface area of tank
Asurf2 = pi*D_tank2*L_tank2; %in^2 -- surface area of tank
Cv_air = R_universal/(gamma_air-1); %ft-lbf/lb-mol-R
%initial conditions
N1_init = P1_init *V_tank1/ ( 12 * R_universal *T1_init);
%lb-mol = lbf/(in^2)*(in^3)/ ((in/ft)*(ft-lbf/lb-mol-R)*R )
W. Booth
08/18/04
N2_init = P2_init*V_tank2/(12*R_universal*T2_init); %lb-mol
%Found values of specific entropy for initial conditions at
% http://thermal.sdsu.edu/testcenter/indexjavaapplets.html
%to calc. total entropy must multiply by initial mass in tank 1 (m1 = M_air * N1), hence:
S1_init = 1256.7 * M_air * N1_init;
%ft-lbf/R = %ft-lbf/lb-R * (1/mol)* (lb-mol)
S2_init = 1273.1*M_air*N2_init;
%matrix of initial conditions:
init = [N1_init T1_init P1_init S1_init N2_init T2_init P2_init S2_init];
if Question == 5
tMAX=150; %run for less time b/c numerical problems with divide by zero ~200sec ??
else
tMAX=600; %seconds
end
colour1=['b' 'g' 'r' 'c' 'k']';
hv=[0 0.0001 0.001 0.01 1]'; %heat transfer coefficients
%tab = [];
%matrix of equilibrium conditions
equil = [];
%Run model for various heat transfer coefficients
for i=1:length(hv),
%Run model with various ODESET parameters (see CODE REFERENCE [1] below)
%rtol=[ 1.e-3 1.e-5 1.e-7 ];
%for i=1:length(rtol),
%op=odeset('RelTol',rtol(i),'Stats','on');
%legend('ode45, RelTol=1.e-3 (tank1)','ode45, RelTol=1.e-3 (tank2)',...
% 'ode45, RelTol=1.e-5 (tank1)','ode45, RelTol=1.e-5 (tank2)')
h = hv(i);
%h = hv(1)
clear N1 S1 N2 S2 T1 P1 T2 P2 choked
%execute model:
%tic;
if Question ~= 5
[t,X]=ode15s(@throttling,[0 tMAX],[N1_init S1_init N2_init S2_init]);%,op);
else %ode15s could not converge with choked flow, therefore use ode45
[t,X]=ode45(@throttling,[0 tMAX],[N1_init S1_init N2_init S2_init]);%,op);
end
%tt = toc;
%tab = [ tab ; rtol(i) tt ]
N1=X(:,1); %molar mass of air in tank 1
S1=X(:,2); %entropy of tank 1
N2=X(:,3); %molar mass of air in tank 2
S2=X(:,4); %entropy of tank 2
W. Booth
08/18/04
T1=T1_init.*exp(((S1-S1_init).*M_air)./(M_air.*N1.*Cv_air));
P1 = 12*N1.*R_universal.*T1./V_tank1;
T2=T2_init.*exp(((S2-S2_init).*M_air)./(M_air.*N2.*Cv_air));
P2 = 12*N2.*R_universal.*T2./V_tank2;
Pdiff = P1-P2;
%equilibrium conditions, assuming tMAX > settling time
equil = [equil ; h N1(length(t)) T1(length(t)) P1(length(t)) S1(length(t)) N2(length(t)) T2(length(t)) P2(length(t))
S2(length(t)) Pdiff(length(t))];
%1=choked, 0=not choked
choked=zeros(length(P1));
choked=(P2<=0.528*P1);
if (Question == 5)
num_sub_plots = 5;
else
num_sub_plots = 4;
end
subplot(num_sub_plots,1,1),plot(t,P1,colour1(i),t,P2,strcat(colour1(i),':')),ylabel('Pressure [psi]'),axis([0 t(length(t))
P2_init P1_init]),hold on
subplot(num_sub_plots,1,2),plot(t,T1,colour1(i),t,T2,strcat(colour1(i),':')),ylabel('Temp [degR]'),hold on
subplot(num_sub_plots,1,3),plot(t,S1,colour1(i),t,S2,strcat(colour1(i),':')),ylabel('Entropy [ft-lbf/R]'),hold on
if (Question == 3); axis([0 t(length(t)) 120 140]), ylabel('Entropy of tank2 [ft-lbf/R]'); end
subplot(num_sub_plots,1,4),plot(t,N1,colour1(i),t,N2,strcat(colour1(i),':')),ylabel('Mass [lb-mol]'),xlabel('Time
[sec]'),hold on
if (Question == 3); axis([0 t(length(t)) 3.5e-3 5e-3 ]),ylabel('Mass of tank 2 [lb-mol]'); end
if (Question == 5)
subplot(num_sub_plots,1,4),xlabel('')
subplot(num_sub_plots,1,5),plot(t,choked,colour1(i)),ylabel('Choked [1=YES / 0=NO]'),xlabel('Time
[sec]'),axis([0 t(length(t)) -1 2]),hold on
End
figure(2)
plot(t,Pdiff,colour1(i)),ylabel('Delta P = P1-P2 [psi]'),xlabel('Time [sec]'),hold on,grid
end %of heat transfer coeff. for-loop
figure(1)
legend(strcat('h = ',num2str(hv(1)),' -- tank1'),...
strcat('h = ',num2str(hv(1)),' -- tank2'),...
strcat('h = ',num2str(hv(2)),' -- tank1'),...
strcat('h = ',num2str(hv(2)),' -- tank2'),...
strcat('h = ',num2str(hv(3)),' -- tank1'),...
strcat('h = ',num2str(hv(3)),' -- tank2'),...
strcat('h = ',num2str(hv(4)),' -- tank1'),...
strcat('h = ',num2str(hv(4)),' -- tank2'),...
strcat('h = ',num2str(hv(5)),' -- tank1'),...
strcat('h = ',num2str(hv(5)),' -- tank2'))
if Question == 5
legend off %legend doesn't print properly ?
end
W. Booth
08/18/04
figure(2)
legend(strcat('h = ',num2str(hv(1))),...
strcat('h = ',num2str(hv(2))),...
strcat('h = ',num2str(hv(3))),...
strcat('h = ',num2str(hv(4))),...
strcat('h = ',num2str(hv(5))))
%CODE REFERENCE [1]
%CODE TO VARY ODESET PARAMETERS AND LOOK AT STIFFNESS OF DIFF'L EQUATIONS
%FROM PAPER ON STIFF DIFF'L EQUATIONS FROM
http://www.maths.uq.edu.au/~gac/math3201/mn_ode2.pdf
%tab = [ ] ;
%for atol=[ 1.e-5 1.e-7 1.e-9 ]
%op=odeset('reltol',1.e-15,'abstol',atol,'stats','on');
%tic ;
%[t,Y]=ode23('rob',[0,1],[1;0;0],op);
%tt = toc ;
%tab = [ tab ; abstol tt ]
%end
W. Booth
08/18/04
%throttling.m -- for use with ode45 function
function xdot=throttling(t,x)
global T1_init N1_init S1_init M_air Cv_air V_tank1 V_tank2 R_universal T2_init N2_init S2_init At h Asurf1
Asurf2 Tamb Question gamma_air Cd
%x = [N1 S1 N2 S2]'
xdot=zeros(4,1); %column vector of derivatives
N1=x(1);
S1=x(2);
N2=x(3);
S2=x(4);
%"1" stands for left tank, initially at higher pressure, "2" stands for right tank
%calculating temp from M.Cv.N.dT = T.dS (similar to assign #3)
%Units on S-S0 is ft-lbf/R (total entropy), so need to multiply by M_air (1/mol) so (S-S0)/N*Cv expression is
unitless
T1=T1_init*exp(((S1-S1_init)*M_air)/(M_air*N1*Cv_air));
%calculating pressure from ideal gas law: PV = N*Ru*T
P1 = 12*N1*R_universal*T1/V_tank1;
%calculating density from definition: ro = N/V
ro1 = N1/V_tank1;
%same for tank 2
T2=T2_init*exp(((S2-S2_init)*M_air)/(M_air*N2*Cv_air));
P2 = 12*N2*R_universal*T2/V_tank2;
ro2 = N2/V_tank2;
if (Question ~=5)
if (P1 >= P2) %If P1 > P2, then flow is passing from left to right, and equations are as derived in notes:
N1dot = -At * sqrt(2*ro1*(P1-P2)/M_air); %mass flow leaving tank 1
N2dot = -N1dot; %same mass flow arrives at tank 2
else %P2 > P1 and flow is reversed, hence, N1dot is +ve and N2dot is -ve
N1dot = At * sqrt(2*ro1*(P2-P1)/M_air); %mass flow arriving at tank 1
N2dot = -N1dot; %same mass flow leaves tank 2
end
else %QUESTION 5
if (P1 >=P2) %If P1 > P2, then flow is passing from left to right
if (P2 <= 0.528*P1) %Subsonic flow -- better model
N1dot = -Cd * At * sqrt((2*gamma_air/(gamma_air-1))*ro1*(1/M_air)*P1*(((P2/P1)^(2/gamma_air))((P2/P1)^((gamma_air+1)/gamma_air))));
N2dot = -N1dot;
else %CHOKED FLOW
W. Booth
08/18/04
N1dot = -Cd * At * ((2/(gamma_air+1))^(1/(gamma_air-1))) *
sqrt((2*gamma_air/(gamma_air+1))*ro1*(1/M_air)*P1);
N2dot = -N1dot;
end
else %P2 > P1 and flow is reversed, hence N1dot is +ve and N2dot is –ve
if (P1 <= 0.528*P2) %Subsonic flow -- better model
N1dot = Cd * At * sqrt((2*gamma_air/(gamma_air-1))*ro2*(1/M_air)*P2*(((P1/P2)^(2/gamma_air))((P1/P2)^((gamma_air+1)/gamma_air))));
N2dot = -N1dot;
else %CHOKED FLOW
N1dot = Cd * At * ((2/(gamma_air+1))^(1/(gamma_air-1))) *
sqrt((2*gamma_air/(gamma_air+1))*ro2*(1/M_air)*P2);
N2dot = -N1dot;
end
end
end
%entropy flux to environment due to convective heat transfer:
Sdot_env1 = h * Asurf1 * (T1-Tamb)/T1 ;
Sdot_env2 = h * Asurf2 * (T2-Tamb)/T2 ;
%entropy flux between tanks (across valve):
Sdot_vlv1 = 2.062E-5*(T1-T2)/T1; %assuming 0.005" covering of Cadmium on 1m long interconnecting tube
%conductivity of cadmium = 96.9J/m-sec-K
Sdot_vlv2 = 2.062E-5*(T1-T2)/T2; %Sdot_vlv1 and Sdot_vlv2 will both be >0 if T1>T2, but Sdot_vlv1 >
Sdot_vlv2
%i.e. entropy lost at valve by tank 1 is > entropy gained at valve by tank 2
%irrespective of flow direction, the entropy fluxes can be defined:
if (Question ~= 4)
S1dot = (S1/N1)*N1dot-Sdot_env1;
S2dot = (S2/N2)*N2dot-Sdot_env2;
elseif (Question == 4)
S1dot = (S1/N1)*N1dot-Sdot_env1-Sdot_vlv1;
S2dot = (S2/N2)*N2dot-Sdot_env2+Sdot_vlv2;
end
%assigning state variable derivates to xdot-vector:
xdot(1)=N1dot;
xdot(2)=S1dot;
xdot(3)=N2dot;
xdot(4)=S2dot;
Download