• No results found

5. The ThermoFluid Library

5.7 Partial Components

equa-tions. Not many equations are actually implemented inThermoFluid, but the most important pressure drop equations are available. Pressure drop and heat transfer equations are implemented as replaceable compo-nents. For them it would be an enormous improvement in the ease-of-use if Modelica tools would implement the choices annotation, described in Chapter 3. The code for pressure drops and heat transfer laws for a pipe model from theThermoFluid-library is illustrated in the following listing.

model PipeDS"Distributed base pipe model"

extends ControlVolumes.Volume2PortDS_ph( . . .//some modifications omitted

redeclare model PressureLoss= PressureDrop.PressureLossD (dp0=char.dp0, mdot0=char.mdot0));

replaceable TransferLaws.Basic HeatRes

(n=n,Aheatloss=geo.Aheat) extends TransferLaws.Ideal . . .//further code omitted

equation

connect(q,heat.q);

connect(q,HeatRes.qb);

connect(qa,HeatRes.qa);

end PipeDS;

Listing 5.3 Pressure Loss and Heat Transfer Models in a Pipe.

The pipe model inherits from a general distributed control volume. The PressureLoss model that has been declared in the base class is exchanged with a more suitable one via the redeclare command. A replaceable heat transfer law is added to the model. The replaceable heat transfer law is declared and connected to HeatAndMass - object via a heat flow connector q . The code shows also how to propagate parameters into sub-components.

5.7 Partial Components

Partial components are models which are almost complete for use in sim-ulation, but some details of the behavior need to be specified by the user in order to make the model complete and well-defined. Partially defined models are a logical consequence of using inheritance and collecting com-mon behavioral parts of a group of similar models in a superclass. The Modelica language and object oriented design supply a rich repertoire of possibilities to define an almost complete model. Common means to leave parts of the model unspecified are:

Chapter 5. The ThermoFluid Library

pipe Heat exchanger

shell side

Plug flow reactor Long adiabatic

Discretized Control Volume

Figure 5.9 Selection of partial models as base classes.

A model without default values for structural parameters. Structural parameters have an influence on the number of equations or the structure of the equation system, they have to be assigned a value before the model is compiled. The assignment of values to structural parameters is a requirement if the equation system is manipulated symbolically before compilation.

• Incomplete models simply do not implement all equations that are needed for a complete model. This is the most common way of cre-ating partial models. For the convenience of the model developers that have to fill in the gaps, the model should contain as much of the final model as possible.

• A model with replaceable components or class parameters where the default class of the component or class parameter is a partial model.

Before the class can be used, the default has to be redeclared to a model which is complete.

• Combinations of the above are also partial models.

Mathematical modeling of systems offers an incredibly broad spectrum of possibilities for modeling the same system in different ways. Nonethe-less, there are some basic properties of the system that all dynamic models should include. Using a control volume as an example it is obvious that most models of technical equipment that contain a fluid have to fulfill a mass and an energy balance. On the other hand, there is an rich diver-sity of physical properties and heat transfer equations that can be used together with that model. Consequently, a partial control volume that does

5.7 Partial Components either not define the variable parts or declares replaceable placeholders, is a model that has a high likelihood of being reused. The main idea is thus to define partial models at branching points where as much com-mon behavior as possible is included in the model, but parts which would exclude a group of other models to use the same code should not be in-cluded see Figure 5.9. There are many ways to define such classes, but with modeling experience in an application domain it is not difficult to select common features for partial models.

The packages for partial models in PartialComponents are:

Package ControlVolumes includes lumped and distributed control volume models. Missing or replaceable parts are a geometry pa-rameterization, a physical property model, pressure loss and heat transfer models.

ThreePorts are lumped control volumes with three BaseFlow con-nectors which are mainly used for flow junctions or splitters. The unspecified parts are the same as for control volumes.

Package Reservoirs implements thermodynamic reservoirs. They do not include property calculations. Including a property model in reservoirs is strictly speaking not necessary, but it simplifies the parameterization for model users.

Package Turbines provides turbine stage models that usually need further assembly, see Section 5.8, and do not implement equations for the efficiency.

Package Pumps includes base classes for simple pumps and inter-faces for controlling them. Missing details are pump characteristics and fluid property calculations.

Compressors have some base classes for compressors. The com-pressor package needs more work for a practical implementation of base classes for compressors.

Package Valves contains base classes for isentropic and isenthalpic throttles. Medium specific isentropic enthalpies are unspecified.

Package Sensors implements common code for sensor models, ex-cluding the characteristic behavior of specific sensor types e. g., the typical first order dynamics of thermocouples.

The emphasis of theThermoFluidlibrary has been on the dynamic be-havior of fluids. Most of the work has been spent on all types of control vol-umes, while the models for equipment have been kept simple. The partial components for flow equipment, e. g., pumps, compressors and turbines,

Chapter 5. The ThermoFluid Library



PPPPPPPPP

Figure 5.10 Example system using a heat exchanger consisting of two pipes, a wall and 4 connectors. In order to simulate it, all flow connectors are connected to reservoirs as boundary conditions.

cover only a fraction of the models that would be useful for a comprehen-sive process engineering or power plant modeling library. ThermoFluid contains standard cases for simple models which cover the basic needs for system models.