Sunteți pe pagina 1din 35

Thermolib

Thermodynamic Systems Library, Release 5.4

Simulation toolbox for the Design and Development


of Thermodynamic Systems in MATLAB/Simulink

GETTING STARTED

Thermolib-GS / 5.4 / 5.4.0


Thermolib Getting Started

How to contact EUtech Scientific Engineering GmbH:


Address: EUtech Scientific Engineering GmbH
Dennewartstrae 25-27
D-52068 Aachen
Germany
Phone: +49(0)-241-963-2380
Fax: +49(0)-241-963-2389
Email: support@thermolib.de
Web : www.eutech-scientific.de

EUtech Scientific Engineering GmbH is a


MathWorks Connections Partner.

Thermolib Getting Started, December 2016


Copyright 2004 2016 by EUtech Scientific Engineering GmbH, Germany.
The software described in this document is furnished under a license agreement. The software may be used or
copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced
in any form without prior written consent from EUtech Scientific Engineering GmbH.

Trademarks
MATLAB / Simulink are registered trademarks of The MathWorks, Inc.
Excel is a registered trademark of Microsoft Corporation.

2016 EUtech Scientific Engineering GmbH I


Thermolib Getting Started Table of Contents

TABLE OF CONTENTS

1 INTRODUCING THERMOLIB ............................................................. 5


1.1 PRODUCT OVERVIEW .............................................................................................................. 5
1.1.1 Product Definition................................................................................................ 5
1.1.2 Thermolib - Important Features .......................................................................... 5
1.1.3 Assumptions and Limitations ............................................................................. 6
1.2 RUNNING A DEMO MODEL ....................................................................................................... 6
1.2.1 What the Model Represents ................................................................................ 6
1.2.2 What the Model Illustrates .................................................................................. 7
1.2.3 Opening the Model .............................................................................................. 7
1.2.4 Running the Model and analyzing the Results .................................................. 8
1.2.5 Modifying the Model ...........................................................................................10
1.3 WHAT CAN YOU DO WITH THERMOLIB? ....................................................................................11
1.3.1 Modeling thermodynamic systems with Simulink ...........................................11
1.3.2 Thermolib blockset - and its Structure .............................................................12
1.3.3 Flow Bus representing Media Flows .................................................................14
1.3.4 Thermal Masses ..................................................................................................15
1.3.5 Chemical Reactions ............................................................................................16
1.3.6 Sources and Sinks ..............................................................................................17
1.3.7 Thermodynamic Balancing ................................................................................17
1.3.8 MATLAB functions .............................................................................................18
1.3.9 Pressure feedback ..............................................................................................19
1.4 ESSENTIAL STEPS TO BUILD A THERMOLIB MODEL ...................................................................24
1.5 LEARNING MORE ...................................................................................................................25
1.5.1 Using the MATLAB Help system .......................................................................25
1.5.2 Bibliography ........................................................................................................26

2 SIMPLE MODELS.......................................................................... 26
2.1 MODELING A CARNOT CYCLE .................................................................................................26
2.2 PRESSURE FEEDBACK DEMO .................................................................................................27

2016 EUtech Scientific Engineering GmbH II


Thermolib Getting Started Table of Contents

2.3 COMPLETE COMBINED CYCLE POWER PLANT ..........................................................................31

3 RELATED PRODUCTS ................................................................... 32


3.1 REQUIRED PRODUCTS............................................................................................................32
3.2 RECOMMENDED PRODUCTS ....................................................................................................33
3.3 OTHER RELATED PRODUCTS ..................................................................................................33

4 REFERENCES .............................................................................. 34

2016 EUtech Scientific Engineering GmbH III


Thermolib Getting Started List of Figures

LIST OF FIGURES
Figure 1: Gas turbine example before simulation run ......................................................... 8
Figure 2: Gas turbine example after simulation run and detail showing a thermal efficiency of
about 27%.............................................................................................................. 9
Figure 3: Gas turbine example with improved efficiency of about 32 %. ........................... 11
Figure 4: Main "layers" of Thermolib blockset ................................................................. 12
Figure 5: Accessing signals on the Thermolib Flow Bus with a standard Bus Selector ......... 15
Figure 6: Parameter Mask of Equilibrium Reactor (Detail) ................................................ 16
Figure 7: Flow Display blocks shows physical properties with units ................................... 17
Figure 8: A mass balance automatically created with th_ExportBalance command ............. 18
Figure 9: T-s Diagram for water with an isobare ............................................................. 19
Figure 10: Example "DemoPressureValve" demonstrates the forward flow method ............ 20
Figure 11: Pressure at output varies with valve position, while mass flow is constant ......... 21
Figure 12: DemoPressureValveWithPF with the pressure feedback signals (green goto/from
blocks). Pump operates on constant RPM, while valve position is varying. .................. 22
Figure 13: Simulation result of DemoPressureValveWithPF showing pout satisfying the
boundary condition of 1 bar, while mdot varies with valve position. ........................... 23
Figure 14: DemoCarnot modeling a Carnot cycle ............................................................. 27
Figure 15: Simple Pressure feedback demo with one valve .............................................. 28
Figure 16: Parameter Mask of the Liquid Tank ................................................................ 29
Figure 17: Valve outlet pressure during valve position change (relaxation factor = 1) ........ 30
Figure 18: Valve output pressure during valve position change (relaxation factor = 5) ....... 30
Figure 19: Flow scheme of a combined cycle power plant ................................................ 31
Figure 20: Combined Cycle Power Plant modeled using Thermolib components in Simulink 32

2016 EUtech Scientific Engineering GmbH IV


Thermolib Getting Started

1 INTRODUCING THERMOLIB
This chapter introduces Thermolib, explains what it is and what you can do with that
toolbox.

1.1 PRODUCT OVERVIEW


In this section you find what Thermolib is and what the most important features of
Thermolib are.

1.1.1 Product Definition

Thermolib is a toolbox for MATLAB/Simulink designed for modeling and simulation of


thermodynamic systems. The toolbox provides a Simulink blockset for system simulations
and a set of MATLAB command line functions for thermodynamic calculations and
thermodynamic balancing of the simulated models. Thermolib also provides an extendable
thermophysical properties database.
The blockset includes Simulink blocks for components such as pumps, compressors, valves,
heat exchangers, tanks, chemical reactors, fuel cell stacks, burners, etc. All component
models focus on the input/output behavior.
The goal is to provide engineers (especially control engineers) with a toolset that enables
them to focus on modeling thermodynamic process at the system level, while Thermolib
handles the underlying thermodynamics and reaction chemisty.

1.1.2 Thermolib - Important Features

Thermolib software is a modeling environment for the engineering design and simulation of
thermodynamic and control systems within Simulink and MATLAB. It is based on
fundamental engineering thermodynamic principles and contains a comprehensive library of
thermodynamic and thermochemical blocks that seamlessly integrate into the MATLAB and
Simulink environment. Generic state calculation blocks facilitate the design of user-defined
components. The thermophysical database is derived from the JANAF tables and can be
easily extended by the user. Thereby Thermolib is not limited by ideal gas assumptions and
can even handle mixtures of reactive multi-species multi-phase mixtures. It thus ensures the
consistent treatment of thermodynamic requirements in the MATLAB/Simulink environment
relieving the design engineer of many otherwise tedious tasks.

2016 EUtech Scientific Engineering GmbH V


Thermolib Getting Started

1.1.3 Assumptions and Limitations

While Thermolib considerably extends and expands the usability of MATLAB/Simulink for
modeling thermodynamic processes, it has some natural limitations attributable to the solver
structure on which Simulink is based. Most importantly, Thermolib does not cover spatial
transport processes and as such it is not a multi-dimensional flow simulation program.
Geometrical design aspects are not considered. Thermolib works at the system level and
models the input/output behavior of process components as it is familiar to the
thermodynamic process engineer.
In some cases the user will want to include results from detailed multi-dimensional flow
simulations or from experiments to generate characteristic curves like flow dependent heat
exchange coefficients or fuel cell polarization curves. This can easily be taken care of in the
Thermolib components.
For more information on the limitations please read the corresponding chapter in the User
Manual.

1.2 RUNNING A DEMO MODEL


This chapter presents the Thermolib demo of a simple gas turbine cycle for power
generation.

1.2.1 What the Model Represents

The gas turbine cycle (Brayton cycle) is depicted below:

Fuel

Combustor
2 3 Electricity

Gas
Turbine
(Brayton)
Generator
Cycle Compressor Turbine

1 4
Intake Air

A compressor feeds compressed air to a combustion chamber where the fuel (in this case
methane, CH4) is injected. For simplicity, complete combustion is assumed. The exhaust gas
from the combustor is then expanded in a turbine to drive a generator shaft. A part of the
work is used to drive the compressor.

2016 EUtech Scientific Engineering GmbH VI


Thermolib Getting Started

1.2.2 What the Model Illustrates

This model illustrates the basic principles and capabilities of Thermolib. It shows how blocks
are connected with standard Simulink busses and how flows can be easily displayed using
the flow display block from the Sinks section of Thermolib.
Also, the example shows how gas mixtures are treated - the incoming wet air is a mixture of
O2, N2 and H2O. After being compressed the air is burnt using CH4 as a fuel inside a
combustor. The combustor essentially is a standard chemical reactor taken from the
Thermolib library. The resulting high temperature gas is then expanded in the turbine.

1.2.3 Opening the Model

Start MATLAB and load Thermolib (if not already done) by issuing the
Thermolib_Setup

command in the \bin folder of the Thermolib installation directory.


Then load the demo model for the gas turbine by either
typing
DemoGasTurbine

at the MATLAB command line or


opening the example manually from \Examples\Applications in your Thermolib
installation directory or
going to Help=>Demos. There look for the Thermolib examples in the Simulink
section of the Demos. Open the DemoGasTurbine from the Applications subgroup.
After opening the model you should see the following:

2016 EUtech Scientific Engineering GmbH VII


Thermolib Getting Started

Figure 1: Gas turbine example before simulation run

In the upper part you see how the flow sheet of the process is modeled using Thermolib
blocks - with the compressors, the mixer, the combustion chamber and the turbine. In the
lower part is located an efficiency calculation.

1.2.4 Running the Model and analyzing the Results

When you run the model you will see some widen lines which are standard Simulink busses
representing the media flows between the components. You see sensors and flow display
blocks attached to the flows to show the interesting physical properties of the flow. To show
or use the properties of the flow you can use one of the following methods:
connect a Flow Display block (Thermolib\Sinks) to the flow and select the signals to
display (displayed in SI units),
connect a Sensor block (Thermolib\Miscellaneous) to the flow and select the signals
and units you want to use,
connect a Bus selector (from Standard Simulink blockset in section Commonly used
blocks) to the flow and select your signals of interest (SI-units).

2016 EUtech Scientific Engineering GmbH VIII


Thermolib Getting Started

You see the temperature, pressure and concentration information displayed in the grey flow
display blocks and in the displays showing the sensor measurements. Note how the
temperature slightly rises after the compressor and dramatically increases after combustion.
The sources of methane and wet air are modeled using blocks from the "Sources" subgroup
of Thermolib. They serve as reservoirs defining the thermodynamic state (T, p, composition)
of the media sources. The mass flows are defined using Isentropic Compressors
(Thermolib\Components\Hydraulic) with isentropic efficiency. The mass flow is controlled by
the "ctrl" port, which gives the actual mass flow as fraction of the maximal mass flow
configured in the compressor mask (here 1 = 100%).

Figure 2: Gas turbine example after simulation run and detail showing a thermal efficiency of about 27%

The combustion chamber is modeled by a Thermolib Reactor block


(Thermolib\Components\Reactors) where the conversion rate is defined at the input. In this
example the conversion rate at the "conv" port of the reactor was chosen to be 1, because
we assume complete combustion. The chemical reaction for combustion of methane is
configured in the block mask to be

2016 EUtech Scientific Engineering GmbH IX


Thermolib Getting Started

CH4 + 2 O2 CO2 + H20.


A "Turbine (Isentropic)" block (Thermolib/Components/Hydraulic) simulates the turbine with
its isentropic efficiency.
In the upper left corner of the model you find a Model Setup block. Each Thermolib model
need such a block. Here you define, with which species you would like to work in your model
and from which thermophysical property file the property data should be loaded.
The thermal efficiency is calculated as the ratio of the net power generated and the lower
heating value of the burnt fuel (LHV).

In Figure 2 you see that the turbine produces a power of about 10 MW (1.01e7 W), while
the air compressor consumes about the half of this (5 MW). Note, that all powers represent
the mechanical work at the fluid/gas. The mechanical losses (e. g. friction in bearings) are
not considered here.

1.2.5 Modifying the Model

We will now try to improve the efficiency by changing the turbine inlet properties
(temperature and pressure). To do this we change the outlet pressure of the compressors.
The outlet pressure value outlet press. gives the absolute pressure level for the compressor
output flow in Pascal (e.g. 7e5 Pa = 7 bar in this case).
Change the simulation end time to inf and run the simulation. During simulation you can
play around with the outlet pressure signal by modifying the setting of the gray Slider Gain
block to see how efficiency and overall power will react on the change. As depicted in the
screenshot below, for example, changing the pressure level from 7 to 14 bar increases the
efficiency by more than 5 percent reaching an absolute value of 32 %.

2016 EUtech Scientific Engineering GmbH X


Thermolib Getting Started

Change compressor outlet pressure here

Figure 3: Gas turbine example with improved efficiency of about 32 %.

1.3 WHAT CAN YOU DO WITH THERMOLIB?


Thermolib consists of different functionalities which help you to model thermodynamic
systems and perform thermodynamic calculations. The most important features are shortly
introduced in the following sections.

1.3.1 Modeling thermodynamic systems with Simulink

The graphical Simulink environment allows for an intuitive design of thermodynamic system
models in that the physical flow (usually) follows the signal flow so that model components
taken from the library can be arranged in resemblance to the underlying physical topology.
While Simulink provides the graphical interface and modeling environment, Thermolib takes
care of the special thermodynamic requirements. The user only needs to drag and drop the
readymade thermodynamic blocks or process components into his Simulink model. This is
much faster than deriving the equation system from the physical conservation laws and
integrating them with standard Simulink blocks. Apart from the sheer complexity this task
will usually bring about, the above mentioned advantage of graphical programming is lost.
Another advantage, perhaps less apparent but even more important is the consistent and
very efficient treatment of thermodynamic considerations in the Simulink framework, e.g.

2016 EUtech Scientific Engineering GmbH XI


Thermolib Getting Started

fluid mixture properties, state changes involving simultaneous reaction and heat transfer,
chemical and phase equilibrium calculations etc.

1.3.2 Thermolib blockset - and its Structure

The most important part of Thermolib is the Simulink based blockset which provides blocks
to simulate typical thermodynamic process components like heat exchangers, chemical
reactors, pumps, compressors, tanks as well as specialized components like fuel cell stacks.

Thermolib Components
(e. g. Pump, Compressor, Heat exchanger ...)

Thermodynamic
State Changes
(e. g. isentropic pressure change)

Thermodynamic States and Properties


Fundamental State Calculations
e.g. T=T(H,p), H=H (T,) ...

Thermolib blockset

Figure 4: Main "layers" of Thermolib blockset

All these component blocks are created in Simulink using a lower layer set of blocks to
perform the fundamental thermodynamic state and property calculations (see Figure 4). The
thermodynamic state and property calculations comprise density calculations, the calculation
of saturation temperature and pressure and the necessary conversions between different
thermodynamic state variables (e.g. T=T(H,p,), H=H (T,)). A typical example is to
calculate the complete state of a given mixture given the enthalpy, pressure and the mixture
composition.
In simulation often occurs the task to calculate a final state for a thermodynamic state
change, while given one of the characteristics of the state change. Imagine an isentropic
pressure drop happening in an idealized turbine. There is a subgroup of Thermolib blockset,
which is dedicated to perform such calculations. You find them in the "Thermodynamic State
Changes". See also the example modeling the Carnot cycle below.

2016 EUtech Scientific Engineering GmbH XII


Thermolib Getting Started

You can use all of these blocks to model your thermodynamic process or to set up your own
custom component blocks. You can also start with a Thermolib component block and modify
it as needed. Try looking under the mask of a Thermolib component (e. g. the Compressor
blocks from the gas turbine example) and you can see how the states and properties blocks
are used to model the physical behavior.
The complete list of subgroups of Thermolib blockset is as follows:
The Balance sub-library contains balance-related blocks needed for generating
energy and mass balancing information.
The Components node is further divided into five sub-libraries according to their
intended field of application. They contain higher-level process components such as
heat exchangers, reformers, stack models, components with pressure feedback, etc.
These components constitute the main part of the Thermolib.
The Controllers sub-library contains PI and PID controller blocks with integrated
anti-windup strategies to create simple controller loops for fuel cell systems.
The Miscellaneous sub-library contains blocks like a general sensor and unit
conversion blocks as well as initial condition block.
The Setup sub-library contains the main Model Setup block required for every
simulation using Thermolib.
The Sinks sub-library contains the Flow Display block to observe thermodynamic
signals and properties in a convenient way.
The Sources sub-library contains source blocks for flow streams, so-called flow
busses, and power signals.
Thermodynamic State Changes. These blocks represent an intermediate layer
between "Thermodynamic States & Properties" and "Components". They represent
thermodynamic state changes like "isobaric enthalpy change". Most of these blocks
encapsulate Thermodynamic States and Properties blocks and a bus assignment for
easier use. You can use these blocks as a starting point for your own components.
Thermodynamic States and Properties. These blocks are the fundamental layer
of Thermolib. Here is where the basic thermodynamic calculations take place. Some
of them calculate single thermodynamic properties like "density" while others like "H-
p-State ..." calculate the complete thermodynamic flow bus (FB) based on a subset of
thermodynamic properties of an incoming Incomplete Flow Bus (IFB).

2016 EUtech Scientific Engineering GmbH XIII


Thermolib Getting Started

1.3.3 Flow Bus representing Media Flows

The flow between connected blocks is represented by a Simulink bus signal. The bus
contains a set of the most important properties defining the flow
molar flow rate (ndot),
pressure (p),
temperature (T),
enthalpy flow (Hdot),
entropy flow (Sdot),
flow of the Gibbs free energy (Gdot),
capacity flow (Cpdot=ndot*cpm),
vapor fractions (x) and the
molar species concentrations (psi).
This information is redundant but enables efficient calculation within the blocks; furthermore,
the user can access all state variables before and behind a process component (see Figure
5).

2016 EUtech Scientific Engineering GmbH XIV


Thermolib Getting Started

Figure 5: Accessing signals on the Thermolib Flow Bus with a standard Bus Selector

1.3.4 Thermal Masses

Temperature changes are governed by heat transfer and heat capacity. During transient
phases (e.g. when there is a change in the amount of heat transferred to the solid surface of
a heat exchanger) the internal energy of a component changes. The temperature change
depends on the overall heat capacity of the component, its thermal mass. The thermal
masses can either be configured directly in the dialogue box of a component or by adding a
Thermal Mass block to the media flow. The Thermal Mass block dampens the temperature
change according to the capacity defined. The flow passing through a component exchanges
heat with the thermal mass, thus the temperature of the output flow follows the input
temperature in a damped fashion.

2016 EUtech Scientific Engineering GmbH XV


Thermolib Getting Started

1.3.5 Chemical Reactions

Thermodynamic systems often contain chemical reactions, e.g. combustion. You can model
reactions by using reactor blocks that come along with Thermolib. The two main reactor
blocks are
the equilibrium reactor and
the reactor with a given conversion rate.
The Equilibrium Reactor (Thermolib/Components/Reactors) simulates a non adiabatic
chemical reactor. You can heat/cool it via a second flow and the block calculates the
chemical and thermodynamic equilibrium condition for the given combination of inputs. The
output is in equilibrium. Note that this calculation is done without assuming a specific volume
of the reactor. The set of chemical reactions taking place in the reactor can be freely
configured (see Figure 6).

Figure 6: Parameter Mask of Equilibrium Reactor (Detail)

The Reactor (Thermolib/Components/Reactors) with given conversion rate is a reactor with


only one reaction taking place. The conversion rate is defined as the ratio of how much of
the input flow reacts as compared to the maximum of how much could react. This block is

2016 EUtech Scientific Engineering GmbH XVI


Thermolib Getting Started

useful if you have measurement data available describing how the conversion rate depends
on the different operating conditions (see Gas turbine example above).

1.3.6 Sources and Sinks

Any open thermodynamic system is fed by a source of media. Thermolib provides two source
blocks for the configuration of a media source: one is for pure substances, the other is for
defining mixtures. Separate blocks are necessary, because in pure substances the Gibbs
Phase Rule applies. The rule states that the degrees of freedom depend on the number of
phases. Consider this simple example: if you want to define a water liquid/vapor mixture that
is half liquid, half vapor you can only define the temperature OR the pressure independently,
because the other variable is fixed by the vapor pressure curve of the species.
The sink block displays selected properties of the flow including its physical units making it
easier to monitor the flow between the system components.

Figure 7: Flow Display blocks shows physical properties with units

1.3.7 Thermodynamic Balancing

Thermolib includes thermodynamic balancing functionality. All component blocks contain


balancing blocks which gather information about incoming and outgoing energy and mass
flows as well as internal mass or energy storages of this block. This information, stored in
the workspace variable SBalanceSpace, can be exported to Excel and ASCII files for further
inspection. Alternatively, the variable SBalanceSpace can be directly used in analysis scripts.
To obtain the balances after running a model, call the following command
SBalanceSpace =
th_ExportBalance(SBalanceSpace,MyBalance.xls,MyBalance.txt)

to export the balances to ASCII and Excel files.

2016 EUtech Scientific Engineering GmbH XVII


Thermolib Getting Started

Figure 8: A mass balance automatically created with th_ExportBalance command

1.3.8 MATLAB functions

For certain tasks you may want to use the thermodynamic property database which is
delivered with Thermolib and the thermodynamic state calculations on the MATLAB
command line.
For some of the thermodynamic states and properties blocks in Simulink there is a
corresponding command line function with the same functionality.
You can use these functions together with the powerful plotting capabilities that standard
MATLAB offers. The MATLAB functions can also be used in conjunction with a PDE solver to
tackle systems with distributed parameters.

Example:

The following code plots the temperature versus entropy of water at a constant pressure.
This is refered to as the isobaric curve in T-s-diagram. One way to plot this diagram is to use
the Thermolib block "isobaric enthalpy change" (Thermolib/Thermodynamic State Changes).
However, using the command line function, one is able to produce the same diagram with
the following code on a much more MATLAB-way:
% plot T-S diagram for pure water
load ChemicalMediaData
T = 200:2000;

2016 EUtech Scientific Engineering GmbH XVIII


Thermolib Getting Started

n = length(T);
psi=ones(1,n);
ndot=ones(1,n);
p = 1e5 * ones(1,n);
psi=ones(1,n);
[State,err] = th_TpState('ndot',ones(1,n),'T',T,'p',p,'psi',psi,...
'Species',{'H2O'},'MediaData',SMediaData)
plot([State.Sdot],T)
title('T-S Diagram for water')
xlabel('molar entropy [J/K*mol]')
ylabel('temperature [K]')

Note the vectorized operation to calculate the state of 1800 different temperatures in one
command. The resulting diagram is shown in Figure 9.

Figure 9: T-s Diagram for water with an isobare

1.3.9 Pressure feedback

Thermodynamic processes often involve hydraulic coupling and networks to some degree. To
model hydraulics with Thermolib there are two possibilities
Forward flow simulation

2016 EUtech Scientific Engineering GmbH XIX


Thermolib Getting Started

Modeling pressure feedback


The first method is the trivial choice of defining a source with a given mass flow. This mass flow will be forced to
pass through the whole network. When a valve position downstream changes, the pressure
drop over the valve will change, but the flow will be constant.

Figure 10 and

Figure 11 show example "DemoPressureValve" and its simulation results, which demonstrate
this method.

Figure 10: Example "DemoPressureValve" demonstrates the forward flow method

2016 EUtech Scientific Engineering GmbH XX


Thermolib Getting Started

Figure 11: Pressure at output varies with valve position, while mass flow is constant

The second option takes into consideration the pressure feedback signal travelling upstream
to the source block. In Thermolib you can model this with explicit feedback signals. This will
cause the mass flow to vary (or even stop) depending on the valve position. In example
"DemoPressureValveWithPF" this is demonstrated (Figure 12). The source is now a tank of
liquid water at 1 bar, while the pump operates on RPM=const.

2016 EUtech Scientific Engineering GmbH XXI


Thermolib Getting Started

Figure 12: DemoPressureValveWithPF with the pressure feedback signals (green goto/from blocks). Pump
operates on constant RPM, while valve position is varying.

2016 EUtech Scientific Engineering GmbH XXII


Thermolib Getting Started

Figure 13: Simulation result of DemoPressureValveWithPF showing pout satisfying the boundary condition of 1 bar,
while mdot varies with valve position.

Thermolib offers both these possibilities. In many models the first method may be sufficient
as the mass flow is often known. In more complex situations you can use the second
method. The methods can also be combined such that the second feedback approach gives
an estimate for the mass flows to be used in the forward calculation method.
To work with the forward calculation method use the blocks from
Thermolib/Components/Hydraulic. When working with pressure feedback use the blocks
from Thermolib/Components/Hydraulic with pressure feedback.
Some blocks can handle both situations so the PFin/PFout (pressure feedback in and
pressure feedback out ports) can be left open or terminated with ground or terminator
blocks. You will find these blocks in both sections. Some other blocks only make sense when
used in conjunction with pressure feedback modeling (e. g. a splitter). They will only be in
the corresponding section.
To model pressure feedback the "PFout" port of a downstream block has to be connected to
the "PFin" port of the corresponding upstream block.

2016 EUtech Scientific Engineering GmbH XXIII


Thermolib Getting Started

Tank blocks serve as sources. Here you have to choose the option "m.out = f(PF)" in the
block mask. This makes the outgoing mass flow depend on the pressure feedback
information. The "downstream" blocks define the boundary conditions, e.g. the outlet
pressure.
To maintain clarity in the model structure, we recommend using From/Goto blocks to feed
back the signals, rather than directly connecting the blocks with lines. To avoid this often
cumbersome manual work Thermolib has a tool, which creates the From/Goto block
connections automatically from a standard forward network.
Type
th_CreateFeedback

at the MATLAB command line to call this dialog. See more about this topic in the
corresponding section of the user manual.
You may want to start by having a look at our extensive set of examples for hydraulic
modeling in \Examples\PressureFeedback subdirectory of your Thermolib installation. You
will also find these demos via "Help Demos Thermodynamic Systems Library
Pressure Feedback" in the MATLAB help system.

1.4 ESSENTIAL STEPS TO BUILD A THERMOLIB MODEL


This section recalls the basic steps to build a Thermolib Model.
1. Add a Model Setup block
Any model using Thermolib needs a Model Setup block. You will find it in the "Setup"
section of Thermolib. Select the Species which you want to use in your model from
the Species list.
2. Decide Feed forward flow or Pressure feedback
Decide if you want to use a forward calculation scheme, where mass flow is given at
the beginning of the network or if you need pressure feedback (in case you want the
flow change to depend on a downstream valve position). When you decide to work
with pressure feedback, make sure that the "PFin" and "PFout" ports of all your
components are correctly connected to the corresponding predecessor block (use the
th_CreateFeedback tool).

3. Add Sources or Initial conditions in loops


Add Source blocks as sources of your media. Make sure that all "in" ports are
connected to valid sources. This also holds for tanks, where there is no incoming
flow. Add a source with flow=0 here. If your model contains flow loops, make sure
you have no algebraic loops. Add an "Initial Condition" block from the "Miscellaneous"

2016 EUtech Scientific Engineering GmbH XXIV


Thermolib Getting Started

section to break them if needed or consider adding a tank to model the media flow in
the loop (which is more physical).
4. Adapt Simulation parameters (step-size, solver...)
Adapt the simulation settings in Simulink as needed for your model. Think about the
time constants of your model. Typically, the characteristic time scale in
thermodynamic processes is in the order of seconds. Make sure that your maximal
step size is not too big, as this may lead to inaccurate results e. g. in balancing.
5. Add Components, Displays / Scopes, Sensors as needed
Add components and other blocks as needed. Consider adding a "Sensor" block from
the "Miscellaneous" section to choose the signals that you are interested in and
display them in convenient physical units.

1.5 LEARNING MORE


Find here, where you can get more information beyond the scope of this Getting Started
Guide.

1.5.1 Using the MATLAB Help system

To learn more about Thermolib you can use the MATLAB help system. Thermolib integrates
its help pages into the standard help of MATLAB. Go to

Help MATLAB Help


in the default menu bar of MATLAB to open the help browser. Look for "Thermodynamic
Systems Library" in the content tree on the left side to get an overview of the help available
for Thermolib. You will also find a link to the printable User Manual.
To get help regarding Thermolib blocks you can always click on the "Help" button in the
parameter dialog box of the respective block to show the blocks documentation.
To get help regarding Thermolib command line functions use the
help <th_command>

command on the MATLAB command line, where you replace <th_command> by the name of
the command line function you need help for. When you use
doc <th_command>

the help for this function will be started in the Help browser.

2016 EUtech Scientific Engineering GmbH XXV


Thermolib Getting Started

1.5.2 Bibliography

There are hundreds of good thermodynamic textbooks available. Thermolib is based on


fundamental thermodynamic engineering principles and is compatible with any book of your
choice. We can recommend
Fundamentals of Thermodynamics, Richard E. Sonntag, Claus Borgnakke, Gordon J.
Van Wylen, 6.Aufl., 2003, John Wiley & Sons.
as a good textbook covering most of the items covered by Thermolib.
If you are a Thermolib user in the field of fuel cell applications, we can recommend
Pukrushpan, Jay T. Control of Fuel Cell Power Systems: principles, modeling, analysis
and feedback design. (Advances in industrial control). Springer, 2005.
Larminie, James. Dicks, Andrew. Fuel Cell Systems Explained, 2nd Edition, Wiley 2003.
as introductions to the thermodynamics of fuel cells.
For more literature see the "References" section of the User Manual.

2 SIMPLE MODELS
This chapter shows three demo models in more detail. This gives you an idea how Thermolib
models could look like.

2.1 MODELING A CARNOT CYCLE


The Carnot cycle is an improtant thermodynamic cycle where thermal energy is converted
into mechanical work in the most efficient manner possible, given a "hot" and a "cold"
reservoir temperature between which the cycle operates. The corresponding thermodynamic
state changes of the working fluid (gas) are as follows:
1. Isothermal expansion at the hot temperature
2. Isentropic expansion to the cold temperature level
3. Isothermal compression at the cold temperature
4. Isentropic compression to the hot temperature level
The blocks that describe these state changes can be found in the "Thermodynamic State
Changes" section of Thermolib.
To view the model of the a Carnot cycle, open the example DemoCarnot.mdl by typing

2016 EUtech Scientific Engineering GmbH XXVI


Thermolib Getting Started

DemoCarnot

in the MATLAB command window.

Figure 14: DemoCarnot modeling a Carnot cycle

The working fluid is water/steam. In the upper part we see the high temperature/high
pressure states, while the lower part shows the states at low temperature and low pressure.
Note the change of the vapor fraction x, indicating a condensation during transition from
from state 1 to state 2 and an evaporation taking place from state 3 to state 4. We did
choose the example such, that all four states are within the vapor-liquid phase equilibrium of
the working fluid.
Note how all " Hdot" values add up to zero.
See also the other examples in \Examples\BasicThermodynamicCycle in your Thermolib
installation directory for more ideas on how to use the state change blocks.

2.2 PRESSURE FEEDBACK DEMO


To get a first impression of pressure feedback modeling with Thermolib, open the model
DemoFlowSimple by typing

2016 EUtech Scientific Engineering GmbH XXVII


Thermolib Getting Started

DemoFlowSimple

in the MATLAB command window.

Figure 15: Simple Pressure feedback demo with one valve

Liquid water at a constant pressure of 5 bar flows out of a tank and through a valve, with
the exit pressure downstream of the valve at 3 bar. The valves position changes at t=100 s.
The water source is a liquid tank. The input mass flow to the tank is set to zero. The
Downstream block defines the outlet condition, which is set to 3 bar. From here the pressure
feedback signal pf_1 is fed back to the pressure valve, while the pressure feedback signal
pf_2 from the valve is fed back to the tank.
The tank parameter m.out = f(PF) is chosen, indicating that the flow rate is calculated using
the downstream pressure information.

2016 EUtech Scientific Engineering GmbH XXVIII


Thermolib Getting Started

Figure 16: Parameter Mask of the Liquid Tank

Taking a look at the simulation results, you will see that the valve outlet pressure moves
back to the 3 bar setpoint after the valve position changes.

2016 EUtech Scientific Engineering GmbH XXIX


Thermolib Getting Started

Figure 17: Valve outlet pressure during valve position change (relaxation factor = 1)

Note that the pressure is calculated iteratively by adjusting the mass flow from the tank in
the time domain, thus imposing an error in the flow dynamics. The pressure feedback solver
finds solutions for slowly varying pressure drops.

You can improve convergence by tuning the relaxation factor for pressure feedback in the
liquid tank, e.g. by increasing this parameter from 1 to 5 the pressure dynamics become
much more pronounced:

Figure 18: Valve output pressure during valve position change (relaxation factor = 5)

2016 EUtech Scientific Engineering GmbH XXX


Thermolib Getting Started

For more detailed description of how pressure feedback works, please have a look at the
corresponding section in the User Manual.

2.3 COMPLETE COMBINED CYCLE POWER PLANT


You can view a more complex model of a combined-cycle power plant by calling
DemoCombinedCyclePowerPlant

in the MATLAB command window.


The process is a combination of a gas turbine and a steam turbine cycle. Methane serves as
fuel. The example can be seen as extension of the gas turbine demo above, where heat
recovery is added. The exhaust gas temperature of the gas turbine is usually high enough
to generate steam. The steam can either be used directly as process steam or to produce
work in a Rankine cycle with heat recovery boiler as shown in the demo below.

Figure 19: Flow scheme of a combined cycle power plant

The modeled process with Thermolib components looks like shown in Figure 20.

2016 EUtech Scientific Engineering GmbH XXXI


Thermolib Getting Started

Figure 20: Combined Cycle Power Plant modeled using Thermolib components in Simulink

Note the higher efficiency of the combined cycle (ca. 50%) compared to the gas turbine
example.

3 RELATED PRODUCTS
Here you can find links to other products, which related to Thermolib in some way.

3.1 REQUIRED PRODUCTS


Thermolib requires
MATLAB 7.5 or above
Simulink 7.0 or above
Thermolib was tested with all MATLAB versions up to R2014b.

2016 EUtech Scientific Engineering GmbH XXXII


Thermolib Getting Started

3.2 RECOMMENDED PRODUCTS


To facilitate some handling aspects of Thermolib, i.e. thermodynamic balancing and the
configuration of the thermophysical properties of species, we recommend using
Microsoft Excel 2003 or above.
Note that thermodynamic balancing can also be done at the MATLAB command line and the
thermophysical property data can be configured via .mat files.

3.3 OTHER RELATED PRODUCTS


HIL-Starter Kit
The HiL Starter Kit helps you to get jump-started with your Hardware-in-the-Loop simulation.
It contains the hard- and software to give you a quick and comprehensive introduction into
setup, parameterization and operation of a HiL system with a PC/104-based real-time
controller.
Enabling technologies such as The MathWorks' Simulink and xPC Target suite offer a fully
integrated end-to-end design environment. xPC Target provides a high-performance, host-
target prototyping environment that connects Simulink and Stateflow models to physical
systems and executes them in real time on PC compatible hardware.
The starter kit has all the customized hard- and software to get you jump-started. It
contains an embedded PC/104 -based control box outfitted with a set of analog/digital I/Os,
a CAN card and CAN bus couplers. A simple Simulink demonstration model is included,
complete with CANopen I/O interfaces.

EshSimulation
Some of our costumers work in the field of domestic heating & cooling applications. Here, in
some cases long term simulations may exceed an entire year but still have to be done with a
high temporal resolution. EshSimulation is a very efficient tool that can handle comparative
simulations with different parameter settings in the shortest time.

Systemlib
Having completed your plant model you may want to create a control application. Here you
will face problems concerning remanent data-storage, alarm handling, time handling etc.
Systemlib offers various functions that will support you with these time consuming tasks.

2016 EUtech Scientific Engineering GmbH XXXIII


Thermolib Getting Started

The HiL-Starter Kit, EshSimulation and Systemlib are EUtech products. For more information
please visit www.eutech-scientific.de.

4 REFERENCES
[1] ftp://ftp.technion.ac.il/pub/supported/aetdd/thermodynamics/
and its mirror: http://garfield.chem.elte.hu/Burcat/burcat.html
[2] NIST-Webbook, http://webbook.nist.gov/chemistry
[3] Fundamentals of Thermodynamics, Richard E. Sonntag, Claus Borgnakke, Gordon
J. Van Wylen, 6.Aufl., 2003, John Wiley & Sons.
[4] Pukrushpan, Jay T. Control of Fuel Cell Power Systems: principles, modeling,
analysis and feedback design. (Advances in industrial control). Springer, 2005.
[5] Larminie, James. Dicks, Andrew. Fuel Cell Systems Explained, 2nd Edition, Wiley
2003.

2016 EUtech Scientific Engineering GmbH XXXIV

S-ar putea să vă placă și