1 / 29

Thermodynamic Control Volume

Thermodynamic 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. Thermodynamic Control Volume.

masao
Download Presentation

Thermodynamic Control Volume

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Thermodynamic 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

  2. Thermodynamic Control Volume Control volume: First Law for Open Systems Connector: heat transfer Connector: convective flow M, U Mass- and Energy Balances

  3. Step One: Connectors • Two transported quantities: mass & energy • flow variable • flow variable • Potential variable for mass flow: pressure • For bi-directional flow: specific enthalpy h

  4. Step One: Connectors connector SimpleFlow SIunits.Pressure p; SIunits.SpecificEnthalpy h; flow SIunits.MassFlowRate mdot; flow SIunits.Power q_conv; end SimpleFlow;

  5. Thermodynamic Control Volume Constitutive Laws: Ideal Gas Law

  6. Ideal 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 p*V = M*R*T; cv = cp - R; u = cv*T; end PureIdealGas;

  7. Thermodynamic Control Volume Constitutive Laws: physical properties for H2

  8. Hydrogen Properties partial model H2cp "cp, for NASA coefficients" SIunits.SpecificHeatCapacity cp; SIunits.Temperature T(min=200, max=1000); // range of validity of polynomial replaceable IdealGasData data; equation cp = data.R*(1/(T*T)*(data.a[1] + T*(data.a[2] + T*(1.*data.a[3] + T*(data.a[4] + T*(data.a[5] + T*(data.a[6] + data.a[7]*T) )))))); end H2cp;

  9. Boundary Conditions Given fixed inflow, Infinite Reservoir with fixed pressure at outflow Turbulent pressure drop

  10. Boundary Conditions I model SimpleReservoir parameter SIunits.Temperature T0=300; parameter SIunits.Pressure p0=1.0e5; parameter SIunits.SpecificHeatCapacity cp0=H2cp_init(T0); FlowA a; equation a.p = p0; a.h = cp0*T0; end SimpleReservoir;

  11. Boundary Conditions II model FlowSource parameter SIunits.MassFlowRate mdot_fix=1.0; parameter SIunits.Temperature T0=300; parameter SIunits.SpecificHeatCapacity cp0=H2cp_init(T0); FlowB b; equation b.mdot = -mdot_fix; b.q_conv = -mdot_fix*cp0*T0; end FlowSource;

  12. Turbulent Flow Resistance model SimplePressureDrop parameter SIunits.Pressure dp0=1.0e3; parameter SIunits.MassFlowRate mdot0=0.1; FlowA a; FlowB b; protected SIunits.Pressure dp; equation dp = a.p - b.p; a.mdot = if dp > 0 then sqrt(dp/dp0) else -sqrt(-dp/dp0); a.q_conv = if dp > 0 then a.h*a.mdot else b.h*a.mdot; b.mdot = -a.mdot; b.q_conv = -a.q_conv; end SimplePressureDrop;

  13. Turbulent Flow Resistance Will this model work for reversing flows?

  14. Thermodynamic Control Volume Control volume: First Law for Open Systems Connector: heat transfer Connector: convective flow M, U Mass- and Energy Balances

  15. Thermodynamic Control Volume model SimpleControlVolume parameter SIunits.Temperature T0=300.0; parameter SIunits.Pressure p0=1.0e5; parameter SIunits.Volume V0=1.0; extends H2(M(start=p0*V0/(data.R*T0)),T(start=T0)); SIunits.InternalEnergy U(start=p0*V0*(H2cp_init(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 = M*u; V = V0; a.p = p; b.p = p; a.h = cp*T; b.h = a.h; end SimpleControlVolume1;

  16. The Modelica Model 1 to 1 representation of physical model

  17. How 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?

  18. Numerical Considerations • What kind of equation system do we get? • Probable difficulties with initial values? • Numerical robustness guaranteed?

  19. Numerical Considerations • Case I: • Internal energy U and mass M are the states • Initial Values for mass and internal energy? Non-linear equation!

  20. Numerical 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 

  21. Thermodynamic Control Volume model SimpleControlVolume parameter SIunits.Temperature T0=300.0; parameter SIunits.Pressure p0=1.0e5; parameter SIunits.Volume V0=1.0; extends H2(M(start=p0*V0/(data.R*T0)),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 = M*u; V = V0; a.p = p; b.p = p; a.h = cp*T; b.h = a.h; dT = der(T); end SimpleControlVolume1;

  22. Numerical Considerations • Case II: • What about initial values?Much easier with T as a State than with U!

  23. Thermodynamic Control Volume model SimpleControlVolume parameter SIunits.Temperature T0=300.0; parameter SIunits.Pressure p0=1.0e5; parameter SIunits.Volume V0=1.0; extends H2(p(start=p0,fixed=true),T(start=T0,fixed=true)); SIunits.InternalEnergy U(fixed=false); Real dp, dT; FlowA a; FlowB b; equation der(M) = a.mdot + b.mdot; der(U) = a.q_conv + b.q_conv; U = M*u; V = V0; a.p = p; b.p = p; a.h = cp*T; b.h = a.h; dT = der(T); dp = der(p); end SimpleControlVolume1;

  24. Numerical 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

  25. Reversing Flows Consider this almost trivial system • Switch of Blower after 1 s • Control Volumes cools down due to heat loss

  26. Reversing 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

  27. Reversing Flows: Demo • Open “SimpleExamples.mo” • run scripts BackFlow.mos, NoBackFlow.mos • Important details for start up simulations etc.

  28. ThermoFlow 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

  29. Conclusions • Easy to build physical models with Modelica • Start with basic conservation equations • Define connectors • Numerical aspects important for robustness • Use model Libraries!

More Related