Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation...

Post on 11-Mar-2021

1 views 0 download

Transcript of Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation...

1

Flanders Centre / Laboratory of Postharvest Technology www.vcbt.be

Dynamic process simulation for design, operation and control

Pieter Verboven

Aim

Learn about implementing dynamic modelsHands on:

Program dynamic models in SimulinkUse predefined examples

Demonstrations of other models

it don’t mean a thing if it ain’t got that swingDuke Ellington

2

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

Dynamic equation systems

Simple systemsAlgebraic equations

Continuous systemsDifferential equations

Discrete systemsDifference equations

3

Simple systems

systems without a state

output at a time instance only depends on the input at that time instancesystem response is always the same for the same input, independent of timeuses:

algebraic equations: y=f(u)logic relations

u(t) (input) y(t) (output)

example of a simple system

510

52

<==>=

tifuy

tifuy

4

Continuous systems

systems with a state

state depends on the inputs and previous values of the state continuouslyuses differential equations

e.g. 1st order explicit ordinary differential equation (ODE)

x(t)statesu(t) (input) y(t) (output)

00 )()),(),((

)),(),((

xtx

ttutxgy

ttutxfdtdx

==

=

example of a continous system

0)0(

25

===

+−==′

txxy

xdtdx

x

5

Discrete systems

systems with a state

state depends on the inputs and previous valuesof the state at discrete time stepsuses difference equations

x(t)statesu(t) (input) y(t) (output)

tnnt

xx

nnunxgny

nnunxfnx

∆===

−−−=

*)(

)0()),(),(()(

)1),1(),1(()(

0

example of a discrete system

0.100.2)1(5.0)0(

)()()(5.0)1(*5.1)2(

=∆===

−+=+

t

x

x

nxny

nxnxnx

6

Example in the agro-food chain

Large-scale cooling facility

Condenser

Compressor

Expansion valve

Evaporator

Condenser

Compressor

Expansion valve

Evaporator

Refrigeration unit Gas handling unit

Cells

-+

Buffer tank

7

Room temperature

Relative humidity

8

O2 concentration

Product temperature

Firmness loss

Respiration heat generation

9

Application:loading strategybatch wisestep wise

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

10

Numerical solution methods

Continous systems: solution of ODEs

Analytical solutions only for simple ODEsNumerical solution

make assumption about behaviour of variable in between time points, e.g., linear variationInsert the approximation into the equationsolve the resulting system of algebraic equations in a discrete number of time points

00 )(

),('

yty

ytfy

==

Solver algorithmsexplicit solvers

forward Eulervery inexpensivelow accuracy

Adams-Bashfortuse old derivative functionsinexpensivemoderate accuracy

Runge-Kutta methodsderivative function at new intermediate pointsexpensive (higher order)very accurate

not suited for stiff problems

)(

)(

1

1'

iii

iii

i

ytfyy

yft

yyy

∆+=

=∆−=

+

+

j

n

jii

jjij

i

kayy

tkyfk

tyfk

�+=

∆+=∆=

+

11

1

1

)(

)(

α

)(0

1 ji

n

jjii yfatyy −

=+ �∆+=

11

stiff problem

explicit solver implicit solver

2.01

15

0

=>==

−=′

ctdx

yxy

implicit solvers for stiff systemsAdams-Moulton

backward Euler & Crank-Nicolson (Trapezium)conditionally stableuse new and old derivative functionshigher order very expensive

( ) 2)()(

)(

11

111

++

+++

+∆=−∆=−=∇

iiii

iiii

yfyftyy

ytfyyy

12

Backward Differentiation Formulas (BDFs)use more old variable valueshigher order very stableexpensive

Numerical Differentiation Formulas (NDFs)improved BDFs (add estimate of truncation error)more efficient than BDFs

use iteration methods to solve non-linear equationuse with variable time step: superior performance

1112

11

112

1

2

)(21

:2

−++

++

+++

+−=∇

−=∇

∆=∇+∇

=

iiii

iii

iii

yyyy

yyy

ytfyy

k

11

111

)(1

++

++=

∇+∆=∇� ik

kiim

k

m

yytfym

κγ

)(1

111

++=

∆=∇� iim

k

m

ytfym

Solvers available in SimulinkNon-stiff

fixed stepode1: forward Eulerode4: 4th order Runge-Kuttaode5: Runge-Kutta

variable stepode45: Runge-Kutta basedode23: Runge-Kutta based

Stiffvariable step

ode15s: NDFs or BDFsode23s: linear implicit methodode23t: trapezoidal rule based

13

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

Simulink

software package for modelling, simulation and analyzing dynamic systems

linear and non-linearcombined continuous and discrete systemsgraphical interfaceblock diagramsblock libraries (pre-defined and user-developed)modular – hierarchicalcoupling to MATLAB

example_simple.mdl

14

Simulink in a nut shell

from within MATLABclick on iconcommand line simulink

list of thematic block libraries openscreate a new modeldrag and drop blocks from library to modellink the blocks with line arrowsdefine parameters for all blocks (double click)set time spanstart simulationanalyse results

ExampleProgram the lumped heat transfer equation

ρ: density [kg m-3]V: volume [m3]cp: specific heat [J kg-1 °C-1]h: heat transfer coefficient [W m-2 °C-1]A: surface area [m2]Q: heat generation [W kg -1]T: temperature [°C]t: time [s]

( ) VQTThAtT

Vc ap ρρ +−−=∂∂

15

Use integrator block

Integration is done numerically by means of thespecified solver

� +=t

t

ydttyfty0

0),()(

example_lumped_heat_transfer.mdl

16

example_lumped_heat_transfer.mdl

example_lumped_heat_transfer.mdl

17

Notesmodel parameters are defined as constants: linearmodel

specific heat/ heat generation can be a function of T: use, e.g., look-up table, function block

can include discontinuities

example_lumped_heat_transfer_nonlinear.mdl

18

example_lumped_heat_transfer_phase_change.mdl

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

19

Exercise: accuracy of solversexample_lumped_heat_transfer.mdl

compare solvers at different fixed time steps.25tc, .50tc,tc,2tc,4tcrecord value at certain time

compare to using automatic time steps

ode45 at 4tc ode15s at 4tc ode15s automatic step

hAVc

tcρ=

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

20

Multi-component systems

real lifeinteraction of different dynamic systems

coupled ODEsstiffness

modular-hierarchical modellinguse of (user-defined) librariesexample_cool_room_continuous.mdl

cool room

21

model

r: refrigerant (coolant)c: refrigeration in vessela:aire:exteriorp:product

pppappap

pppp

eawwappaarcca

paaa

arccrcprrr

prrr

QVTTAht

TcV

TTAhTTAhTTAht

TcV

TTAhTTcmt

TcV

ρρ

ρ

ρ

+−−=∂

−−−+−=∂

−−−=∂

)(

)()()(

)()(�

example_cool_room_continuous.mdl

22

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

Distributed dynamic systemsdepend also on spatial coordinatese.g., the Fourier equation for heat conduction

ρ: density [kg m-3]cp: specific heat [J kg-1 °C-1]k: thermal conductivity [W m-1 °C-1]h: heat transfer coefficient [W m-2 °C-1]Q: heat generation [W kg -1]T: temperature [°C]t: time [s]

0)0(

)(

TtT

TThTn

k

QTktT

c

a

p

==

−=∂∂−

+∇∇=∂∂ ρρ

23

also have the format

but f(y,t) contains spatial partial derivativesuse numerical techniques to solve equation

finite difference methodfinite element methodfinite volume method…

generally lead to the set of first order ODEs

use ODE solver to solve set of equations

00 )(

),('

yty

ytfy

==

C u Ku fddt

+ =

example: heat conduction in a spheresolution in FEMLAB

3D

ha, Ta

24

1D spherical

ha, Tacenter surface

temperature profile

25

3D 1D spherical coordinates

FEMLAB in Simulink

possibility to combine ODEs and PDEsexport model from FEMLAB to MATLAB structure

general dynamiclinearised dynamicspecify inputs and outputsinitial conditions cannot be exported!

introduce structure in FEMLAB blockFEMLAB model uses ODE solver of Simulink

26

example_sphere_linear.mdl

comparison of results FEMLAB - Simulink

27

example_sphere_linear_plus_air_lumped.mdlstiff problem!

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

28

Discrete-continuous simulationDiscrete events require that time step is accuratelycontrolled at the discontinuity

imposes new initial value problemmissing the discontinuity means wrong initiation of nextcontinuous period

fixed time solvers cannot deal with discontinuitiesMethod in simulink

zero-crossing detectioneach relevant block carries a ‘zero-crossing’ variablechanges sign at discontinuity of stateinterpolation between last and current step to localise crossingstep up to and then over discontinuity

example_lumped_heat_transfer_phase_change.mdlturn of zero-crossing in switch and integrator blocks

without detectionwith zero-crossing detection

29

cool room with door openings

model

r: refrigerant (coolant)c: refrigeration in vessela:aire:exteriorp:product

pppappap

pppp

deaddeaww

appaarcca

paaa

arccrcprrr

prrr

QVTTAht

TcV

sTTAhTTAh

TTAhTTAht

TcV

TTAhTTcmt

TcV

ρρ

ρ

ρ

+−−=∂

∂×−−−−

−+−=∂

−−−=∂

)(

)()(

)()(

)()(�

30

example_cool_room_continuous_discrete.mdl

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

31

Controllers

Feedback controller

PID controller

Kp: gainTi: integral timeTd: derivation time

controller proces-

+

y

R

e u

���

����

�++= � dt

tdeTdtte

TteKu d

ip

)()(

1)(

dynamic modelling of controllersparameter tuningreal process simulation

smallchange

decreasedecreasesmallchange

Td

eliminateincreaseincreasedecreaseTi

decreasesmallchange

increasedecreaseKp

Steadyerror

Settlingtime

OvershootRise time

32

example_controller.mdl

example_controller.mdl

Kp=1000 (P)

Kp=1000,Ti=0.1 (PI)

Kp=1000,Ti=0.1,Td=1000 (PID)

33

cool room with PID control of air temperature

PID

example_cool_room_continuous_discrete_control.mdl

34

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

Parametric studies

explore the effect of changing parametervalues in the modelexample_cool_room_parametric.mdlautomatic parameter testing

run the model from the MATLAB command lineparametric_cool_room.m

35

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

36

multi-step modelling

chain modellingproduct changes conditions/process from one step to the nextimportant for

agro-food chain quality management: chain designsolving reliability issuestraining of operatorsaids management decissions

example_chain_simulation.mdlsimulink is limited for multiple steps (max.3)!

37

OutlineDynamic equation systemsNumerical solution methodsGetting started with SimulinkSimulation of a dynamic systemMulti-component systemsDistributed dynamic systemsDiscrete-continuous simulationController simulationParametric studiesMulti-step modellingCustomized visualisation

Customized visualisation

Make your model user-friendlyuse object-oriented programminguse hierarchical and modular programming

example: GUI for temperature and quality in chicory production chain

completely built in MATLAB environmentsolve ODEs for temperature and temperature-dependent quality kinetics

38

39

it don’t mean a thing if it ain’t got that swingDuke Ellington