Title: Thermodynamic Control Volume
1Thermodynamic Control Volume
- Build a simple model from scratch
- Based on physical principles
- Demonstrate typical model design trade off
- Simplicity vs range of validity
- Simplicity vs numerical robustness
- Dynamic vs static
2Thermodynamic Control Volume
- Control volume First Law for Open Systems
Connector heat transfer
Connector convective flow
M, U
Mass- and Energy Balances
3Step One Connectors
- Two transported quantities mass energy
- flow variable
- flow variable
- Potential variable for mass flow pressure
- For bi-directional flow specific enthalpy h
4Step One Connectors
- connector SimpleFlow
- SIunits.Pressure p
- SIunits.SpecificEnthalpy h
- flow SIunits.MassFlowRate mdot
- flow SIunits.Power q_conv
- end SimpleFlow
5Thermodynamic Control Volume
- Constitutive Laws Ideal Gas Law
6Ideal Gas Law
partial model PureIdealGas "Ideal Gas Law"
SIunits.SpecificHeatCapacity cv, cp, R
SIunits.SpecificEnergy u SIunits.Temperature
T SIunits.Pressure p SIunits.Volume V
SIunits.Mass M equation pV MRT
cv cp - R u cvT end PureIdealGas
7Thermodynamic Control Volume
- Constitutive Laws physical properties for H2
8Hydrogen Properties
partial model H2cp "cp, for NASA coefficients"
SIunits.SpecificHeatCapacity cp
SIunits.Temperature T(min200, max1000) //
range of validity of polynomial replaceable
IdealGasData data equation cp
data.R(1/(TT)(data.a1
T(data.a2 T(1.data.a3
T(data.a4 T(data.a5 T(data.a6
data.a7T) )))))) end H2cp
9Boundary Conditions
- Given fixed inflow,
- Infinite Reservoir with fixed pressure at outflow
Turbulent pressure drop
10Boundary Conditions I
- model SimpleReservoir
- parameter SIunits.Temperature T0300
- parameter SIunits.Pressure p01.0e5
- parameter SIunits.SpecificHeatCapacity
- cp0H2cp_init(T0)
- FlowA a
- equation
- a.p p0
- a.h cp0T0
- end SimpleReservoir
11Boundary Conditions II
model FlowSource parameter
SIunits.MassFlowRate mdot_fix1.0 parameter
SIunits.Temperature T0300 parameter
SIunits.SpecificHeatCapacity
cp0H2cp_init(T0) FlowB b equation
b.mdot -mdot_fix b.q_conv
-mdot_fixcp0T0 end FlowSource
12Turbulent Flow Resistance
model SimplePressureDrop parameter
SIunits.Pressure dp01.0e3 parameter
SIunits.MassFlowRate mdot00.1 FlowA a
FlowB b protected SIunits.Pressure dp
equation dp a.p - b.p a.mdot if dp
gt 0 then sqrt(dp/dp0)
else -sqrt(-dp/dp0) a.q_conv if dp gt 0
then a.ha.mdot else
b.ha.mdot b.mdot -a.mdot b.q_conv
-a.q_conv end SimplePressureDrop
13Turbulent Flow Resistance
Will this model work for reversing flows?
14Thermodynamic Control Volume
- Control volume First Law for Open Systems
Connector heat transfer
Connector convective flow
M, U
Mass- and Energy Balances
15Thermodynamic Control Volume
- model SimpleControlVolume
- parameter SIunits.Temperature T0300.0
- parameter SIunits.Pressure p01.0e5
- parameter SIunits.Volume V01.0
- extends H2(M(startp0V0/(data.RT0)),T(start
T0)) - SIunits.InternalEnergy U(startp0V0(H2cp_ini
t(T0) - - data.R)/data.R)
- FlowA a FlowB b
- equation
- der(M) a.mdot b.mdot
- der(U) a.q_conv b.q_conv
- U Mu
- V V0
- a.p p b.p p
- a.h cpT b.h a.h
- end SimpleControlVolume1
16The Modelica Model
- 1 to 1 representation of physical model
17How to Structure the Code?
- Reusable Code
- Top level physical objects
- Separate
- Medium specific functions for hydrogen
- Constitutive equations, the ideal gas law
- Mass and energy balances
- Functions or Classes?
18Numerical Considerations
- What kind of equation system do we get?
- Probable difficulties with initial values?
- Numerical robustness guaranteed?
19Numerical Considerations
- Case I
- Internal energy U and mass M are the
states - Initial Values for mass and internal energy?
Non-linear equation!
20Numerical Considerations
- Case II
- can we avoid the non-linear system of equations?
- Function cp(T) is causing the problem? Choose T
as a State instead of U - Let Dymola do the rewriting ?
21Thermodynamic Control Volume
- model SimpleControlVolume
- parameter SIunits.Temperature T0300.0
- parameter SIunits.Pressure p01.0e5
- parameter SIunits.Volume V01.0
- extends H2(M(startp0V0/(data.RT0)),T(start
T0)) - SIunits.InternalEnergy U
- Real dT
- FlowA a FlowB b
- equation
- der(M) a.mdot b.mdot
- der(U) a.q_conv b.q_conv
- U Mu
- V V0
- a.p p b.p p
- a.h cpT b.h a.h
- dT der(T)
- end SimpleControlVolume1
22Numerical Considerations
- Case II
- What about initial values?Much easier with T as
a State than with U!
23Thermodynamic Control Volume
- model SimpleControlVolume
- parameter SIunits.Temperature T0300.0
- parameter SIunits.Pressure p01.0e5
- parameter SIunits.Volume V01.0
- extends H2(p(startp0,fixedtrue),T(startT0,f
ixedtrue)) - SIunits.InternalEnergy U(fixedfalse)
- Real dp, dT
- FlowA a FlowB b
- equation
- der(M) a.mdot b.mdot
- der(U) a.q_conv b.q_conv
- U Mu
- V V0
- a.p p b.p p
- a.h cpT b.h a.h
- dT der(T) dp der(p)
- end SimpleControlVolume1
24Numerical Considerations
- Case III
- Eliminate the need for extra functions or
calculations for initial conditions - Make pressure p and Temperature T the states
- easy initial conditions
- measurements available? System identification
- Let Dymola do the rewriting again
25Reversing Flows
- Consider this almost trivial system
- Switch of Blower after 1 s
- Control Volumes cools down due to heat loss
26Reversing Flows
- A system that handles reversing flows works
- If the pressure drop is ,
the system will fail for numerical reasons - Why? Look at the numerical details
27Reversing Flows Demo
- Open SimpleExamples.mo
- run scripts BackFlow.mos, NoBackFlow.mos
- Important details for start up simulations etc.
28ThermoFlow Library Goals
- Supply basic dynamic flow models
- Take care of initialization
- Consider numerical efficiency
- General numerical robustness important
- Allowing reversing flows a must
- Basic set of physical properties
29Heat exchanger group
- Discuss wanted level of detail
- What types of heat exchangers are needed?
- Identify alternatives, take into account for
object structure - Look at examples in Components/Water/HeatExchange
rs - Check for available models in PartialComponents
- Start coding geometry parameterization,
graphical composition, parameter propagation
30Conclusions
- Easy to build physical models with Modelica
- Start with basic conservation equations
- Define connectors
- Numerical aspects important for robustness
- Use model Libraries!