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

39
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 models Hands on: Program dynamic models in Simulink Use predefined examples Demonstrations of other models it don’t mean a thing if it ain’t got that swing Duke Ellington

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

Page 1: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 2: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 3: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 4: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 5: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 6: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 7: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

7

Room temperature

Relative humidity

Page 8: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

8

O2 concentration

Product temperature

Firmness loss

Respiration heat generation

Page 9: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 10: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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 −

=+ �∆+=

Page 11: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 12: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 13: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 14: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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 ρρ +−−=∂∂

Page 15: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

15

Use integrator block

Integration is done numerically by means of thespecified solver

� +=t

t

ydttyfty0

0),()(

example_lumped_heat_transfer.mdl

Page 16: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

16

example_lumped_heat_transfer.mdl

example_lumped_heat_transfer.mdl

Page 17: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 18: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 19: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 20: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 21: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 22: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

==

−=∂∂−

+∇∇=∂∂ ρρ

Page 23: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 24: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

24

1D spherical

ha, Tacenter surface

temperature profile

Page 25: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 26: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

26

example_sphere_linear.mdl

comparison of results FEMLAB - Simulink

Page 27: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 28: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 29: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

ρρ

ρ

ρ

+−−=∂

∂×−−−−

−+−=∂

−−−=∂

)(

)()(

)()(

)()(�

Page 30: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 31: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 32: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

32

example_controller.mdl

example_controller.mdl

Kp=1000 (P)

Kp=1000,Ti=0.1 (PI)

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

Page 33: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

33

cool room with PID control of air temperature

PID

example_cool_room_continuous_discrete_control.mdl

Page 34: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 35: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

35

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

Page 36: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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)!

Page 37: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

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

Page 38: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

38

Page 39: Dynamic process simulation for design, operation and control · 2005. 6. 20. · Dynamic equation systems Numerical solution methods Getting started with Simulink Simulation of a

39

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