- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Fluid library
Fluid library
Fluid library
I have been using modelica Fluid library for some time now and was quite happy with it being able to handle the continuous compression processes that i normally want to simulate. Results seemed plausible so far even to the point of allowing heat dissipation where needed. However recently i came across an odd finding which for me looks like either i may not have understood the basic underlying physics or something is wrong with the Media model or i'm just using it in the wrong way.
I simplified my model (see below) to finally only contain two instances of ClosedVolume-model (same volume 100m³, same initial temperature 293K but differing initial pressure 3 MPa vs. 0.1 MPa) connected through an instance of ValveCompressible-model (Kv 50, no leakage) which opens after 5sec of simulation time. All heat transfers disabled (at least i think so), medium is N2 from IdealGases.
Now if one simulates this the pressure trends look convincing and end up at an equalized pressure of 1.55 MPa. But the temperature trend suggest that a significant heat up (up to 343 K) is to be expected within the previously low-pressure vessel, while the high-pressure vessel will cool down (to 243 K).
The cool down in high-pressure vessel seams reasonable (as there is only out-flowing fluid it should be an adiabatic expansion). And indeed 293K*(3/1.55)^((1-1.4)/1.4) yields exactly 243 K. So for this it looks all fine.
However things seem to break apart (most probably because of a wrong understanding on my side) for the low-pressure vessel as i would expect its temperature to be dominated by the cooler gas after the mixing even if one assumes that there will be a compression of the small amount of gas that was already in the low pressure vessel.
Now i'm not sure: Is my expectation of seeing a cool down in both vessels wrong or is there some issue with the internal energy equations?
Best regards
Eric
Model-Code:
model VolumePurging
package Medium = Modelica.Media.IdealGases.SingleGases.N2;
Modelica.Fluid.Vessels.ClosedVolume SourceVolume(redeclare package Medium = Medium, T_start = 293, V = 100, nPorts = 1, p_start = 3e6, use_portsData = false) annotation(
Placement(visible = true, transformation(origin = {-70, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Valves.ValveCompressible ValveCompressible(redeclare package Medium = Medium, CvData = Modelica.Fluid.Types.CvTypes.Kv,Fxt_full = 0.55, Kv = 50, dp_nominal = 2.9e+11, dp_start = 2.9e6, leakageOpening = 0, m_flow_nominal = 3, p_nominal = 3e6) annotation(
Placement(visible = true, transformation(origin = {0, -50}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Blocks.Sources.Step step1(startTime = 5) annotation(
Placement(visible = true, transformation(origin = {-70, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
Modelica.Fluid.Vessels.ClosedVolume PurgedVolume(redeclare package Medium = Medium,T_start = 293, V = 100, nPorts = 1, p_start = 0.1e6, use_portsData = false) annotation(
Placement(visible = true, transformation(origin = {50, -30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
connect(ValveCompressible.port_b, PurgedVolume.ports[1]) annotation(
Line(points = {{10, -50}, {50, -50}, {50, -40}, {50, -40}, {50, -40}}, color = {0, 127, 255}));
connect(ValveCompressible.opening, step1.y) annotation(
Line(points = {{0, -42}, {0, 30}, {-58, 30}}, color = {0, 0, 127}));
connect(SourceVolume.ports[1], ValveCompressible.port_a) annotation(
Line(points = {{-70, -40}, {-70, -50}, {-10, -50}}, color = {0, 127, 255}, thickness = 0.5));
annotation(
experiment(StartTime = 0, StopTime = 350, Tolerance = 1e-06, Interval = 0.1));
end VolumePurging;
Re: Fluid library
I'm still trying to identify where my error lays.
Is it even correct to assume that the gas in high pressure volume will cool down in every case? I remember dimly that if i expand ideal gas against vacuum i should actually expect to see no temperature change at all as the gas is not doing any work. Which sounds reasonable. However if i reduce the pressure in the low pressure vessel to (almost) zero i'm still getting the same cool down and heat up effects. So does this prove the model to be wrong? I suspect that i'm still missing something very basic here.
I tried to dig a little into the problem and found that the h_outflow-variables at valve ports differ by what looks like a static offset, which - if i take the heat capacity of nitrogen - matches exactly what i see as heat-up in the transferred mass. This considerable offset however seems odd, as my understanding up to now was, that the valve model assumes an isenthalpic process. This also happens if i replace the valve model by a generic resistance (dp=a*V²...) model. So this seems not to be a valve issue.
If i would have to assume that what i see is correct then the only explanation that would be kind of soundful is that within the throttle a good portion of the stored energy from high pressure volume is transformed into heat as result of friction effects. However if i check the model of generic resistance i don't see anything that would back up this theory.
Re: Fluid library
OK seems it's quite normal and to be expected that the h_outflow-values differ. This is because they are stream variables thus - if i got this right - they tell me how much energy is going to be transfered if the fluid is going forward or backwards through the throttle. If i have flow only in forward direction then only port_b h_outflow is relevant - and this one develops as is to be expected (slowly decreasing with the temperature in the high pressure vessel). At least one lesson learned.
I have tried to derive a solution of the equalization process by hand. I hope it is valid to look at it like a combination of the following three distinct processes:
(1) Adiabatic expansion of the volume in the high pressure vessel into the low pressure vessel (assuming no mixing takes place - say there is a piston)
(2) Adiabatic compression of the volume in low pressure vessel
(3) Mixing of the two portions in the formerly low pressure vessel after they have reached the same pressure (so they will have different temperature in the beginning but we should end up with a mass weighted mean of the temperature).
I think assuming adiabatic changes here is valid, as one can assume that the work done by the expansion in (1) is fully consumed by the work to be done for the compression in (2) and no heat exchange to the surrounding takes place. In (3) i'm not sure if i have forgotten something related to the mixing - but as i'm talking about ideal gases i would assume that the enthalpy does not change.
After combining the mass balances, mixing rules, ideal gas equations and adiabatic changes i end up with a solution that suggests (initial conditions as mentioned in the first post) that the equalized pressure should be 1,28MPa with the formerly high-pressure vessel temperature at 230K and the low-pressure vessel temperature at 255 K.
So right now i get the feeling that i can't be that wrong in assuming that the low-pressure vessel shouldn't heat up during the equalization.
Which leaves me at a loss - does this mean the media model gives wrong results for change of enthalpy, do i need to enforce something else in the model to account for the fact that i'm dealing with a closed system and not a transport process?
Re: Fluid library
This topic can be considered closed. Why? Well i think because i was indeed wrong from the beginning - i'll leave my personal debate here for public shaming.
I thought a little more about the process itself. If I forget for an instance that the system is about gases but assume instead that we have two identical springs with a different preloading in the beginning. If I remove the fixation the springs will start to oszillate (with a frequency depending on the mass that is shifted in between) and - if one allows for friction - the complete energy that was previously stored in the static preloading will finally dissipate into heat. So if i keep this in mind the situation comes clear - i have static energy stored in the high pressure volume and the system is not in equilibrium at beginning. During the equalization i allow the system to get into equilibrium and by this in force that part of energy that is not stored as a pressure difference anymore to dissipate into the low pressure volume (which seems to happen kind of implicitely as the model does not really compute kinetic energy).
So i was wrong at the point where i reduced the problem to a sequence of adiabatic state changes. Now that i look at it this way its obvious because what happens during the equalization process is for sure not reversable (i'll have to invest work and move around some heat to get the high and low pressure states back). I suppose i simply forgot of the second law of thermodynamics here.
I'm intrigued that modelica after all helped me to reinvent the wheel. I still can't remember that i have ever seen a real pipe getting hot during the pre-pressurizing but this may at the end be only related to the heat capacity of the pipe walls.
Re: Fluid library
eric_hd,
I'm glad you found a solution to your problem and appreciate you sharing it with the community
Thanks,
BR,
Rene Just Nielsen
- justnielsen
- 40 Posts
Re: Fluid library
Thanks for the support. I'll just round up that topic with an "aftermath".
Modelica simulation told me, that for my system (100m³,T1_start=T2_start=293K,p1_start=3MPa,p2_start=0.1MPa) i would have to expect a final pressure of p1_end=p2_end=1.55MPa and temperatures T1_end=243K and T2_end=370K. Why can i trust this?
Well it's actually so simple it's a shame:
Ideal gas law states: p*V=m*R*T
This simply means:
p1_end*V1+p2_end*V2 = m1_start*R*T1_start+m2_start*R*T2_start
This simplifies with p1_end=p2_end, V1=V2, T1_start=T2_start to:
p1_end = (m1_start+m2_start)*R*T1_start/(2*V)=(p1_start+p2_start)/2
Inserting initial values we get 1.55MPa.
Now I was at least at one point correct - the expansion in high pressure vessel is adiabatic (at least for that part of mass that stays inside this vessel).
T1_end = T1_start * (p1_end / p1_start)^((kappa-1)/kappa)
Inserting initial values we get 242.6K.
As V1 is constant and p1_end is reduced also the mass in the high pressure vessel must change
m1_end = p1_end*V1/(R*T1_end)
Inserting the values we get 2152.5kg
Again ideal gas law:
m1_end*R*T1_end+m2_end*R*T2_end=(m1_start+m2_start)*R*T1_start
With mass balance m_ges = m1_start+m2_start = 3565 kg and R removed:
m1_end*T1_end + (m_ges-m1_end)*T2_end = m_ges*T1_start
Rearranged for T2_end:
T2_end = (m_ges*T1_start-m1_end*T1_end)/(m_ges-m1_end)
Inserting the values we get 369.8K.
So everything checks out and i can rest in peace knowing that the Fluid library is doing fine. :-)
Re: Fluid library
I couldn't help myself but continue playing around a little with my vessel model by adding some port data (putting ports at 0m height with a diameter 0.1m). This resulted in the model computing also kinetic energy terms at the ports which are now also taken into consideration of the energy balances.
Interesting observation is, that it now looks like that there is nothing in the model that enforces constant overall energy balance if kinetic energy terms exist.
More specifically: Due to the high pressure the outlet velocity at high pressure vessel is mostly quite low - thus the total energy loss from this vessel is nearly the same as for having not defined a port dimension(E-term is nearly zero). On the other side the velocity for low pressure vessel is significant especially in the beginning. Therefore the energy stored in that vessel is visibly higher at the end of equalization. This results in an increased overall inner energy that can be seen has a higher temperature & pressure, which - i suspect - is clearly not right.
I see that the stream connectors connect the variables of mass flow and enthalpy and no information about velocity states is transfered. Thus i get the feeling that the kinetic energy should normally be part of that spec. enthalpy and the port data in the vessel should be used more or less like an orifice / general flow resistance instead of contributing kinetic energy terms. Is there any place better than this forum where i should discuss library specifics like this?
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Fluid library