See attached matlab file. It might help you.

Dead Sea Hydro-power station.

It is proposed to build a 400MW-hydropower station on the shore of the Dead Sea. The plant will drain seawater from the Mediterranean through turbines and into the Dead Sea. The vertical distance between the inlet and outlet depends on...

See attached file for full problem description.

University of KwaZulu-Natal

School of Electrical, Electronic and Computer Engineering

SYSTEMS AND SIMULATION - ENEL3SS

0) INTRODUCTION

This is a first contact course in control systems. The broad aim of the course is to develop skills in

understanding the behaviour of physical dynamic systems and to understand the engineering tools

required for design of control systems. Specifically, we will cover the following main sections:

1) Modelling: We will develop the model of a physical system by writing down sets of first

order differential equations. The time varying variables of such a model are called the state

variables. The study of systems that are represented as state space models allows a very

fundamental understanding of system behaviour to be developed. State space

representations are used for system modelling and understanding, for computer simulation

and for controller design. We will start of with general (non-linear, time varying) models

but will focus on linear or linearised, time invariant systems.

2) Introduction to simulation and the Matlab/Simulink environment: The development of

affordable advanced computing hardware and software allows fast development of

simulation models of complex systems. We will use a Windows based program called

Matlab and a package called Simulink that runs under Matlab. This software is available

on the LAN and there is on-line help. You are expected to use Matlab for tutorials and the

development of these skills will be examined. We will illustrate the principle of simulation

by investigating first order explicit and implicit Euler methods. Packaged software uses

more advanced algorithms and is fairly reliable although simulation must be tested for

reasonableness as the algorithms used can and do fail on particular problems.

3) Linearisation and linear systems: Many problems either are linear or can be linearised. Our

interest in obtaining linear problems is that there are very powerful methods available for

analysing and designing linear systems. We will investigate the time response of linear

systems and the application of the Laplace transform to solving the differential equations.

4) Input-output descriptions of linear systems: In many cases we are more interested in the

input and output variables of a system than in the internal (or state) variables. As a result

we will investigate the input-output properties of systems and the output response of

systems to sinusoidal input signals. We will develop some understanding of the

relationship between the time domain behaviour and the frequency domain behaviour of

systems.

5) Discrete time and sampled data systems: The very widespread use of computer hardware

means that it is important to understand the behaviour of systems when part of the system is

digital hardware interfaced to the "real world" by A/D (analogue-digital) and D/A

converters.

Systems & Simulation - ENEL3SS 1

SS1_1.DOC

1. SYSTEM MODELLING

1.1. General non-linear system models

A fundamental principle in nature is that of conservation. Certain quantities in nature such as mass

and energy are conserved in the sense that they do not vanish without explanation. If we define a

physical system that is of interest to us by means of its boundary, the law of conservation is that the

rate of increase of a conserved quantity within the system is the rate at which that quantity crosses

the system boundary plus the rate of manufacture/transformation of the conserved quantity within

the system.

System

Crossing boundary

boundary

manufacture/

transformation

Conservation of a quantity within a system

This can be written as a general law:

dQ

= boundary + manufacture

dt

Q is the conserved quantity of interest. boundary is the rate at which the conserved quantity crosses

the boundary into the system (boundary

the rate at which the conserved quantity is manufactured/transformed from other quantities within

the system. In many processes there is no manufacture but we should look out for both

mechanisms.

Examples of conserved quantities: mass (of components or total), energy (kinetic, potential, heat,

chemical or total), sum of total mass and energy (generalised energy) in nuclear reactions, number

(of people, bank balances etc.).

Examples of unconserved quantities: temperature, pressure, value of money, social worth of people.

Simple example: Water level in a tank

The conserved quantity is the mass of water in the tank. (What is the

system boundary?) The water is incompressible and therefore the uin

volume and mass are directly related. The inflow/outflow is in

volume/time and the level is volume/area. For constant area,

dV V

= Net inflow rate = (uin-uout), h=V/A h uout

dt

The process is linear with respect to volume and hence with respect to

level if the area is constant.

Systems & Simulation - ENEL3SS 2

SS1_1.DOC

[time,Uin]

+

From 1/s 1 height

Workspace +

Sum flow-volume To Workspace

1/area

[time,Uout]

From

Workspace1

time_out

Clock To Workspace1

Simulink simulation of level in a tank

Modelling is an important interest of this course and like most things, it is best learned by practice,

the main learning of system modelling will be by tutorial work. We will apply knowledge from

many branches of science and engineering and the final model will be based on exact conservation

laws and empirical/phenomenological observations. The model can usually be refined if it is found

that the reality and the model do not have satisfactory agreement and can simplified by omitting

secondary effects if it is found too cumbersome for the application and if the application can

tolerate lower fidelity. We will use the modern simulation tools that are available to validate and

visualise our model.

We will generally obtain for lumped parameter systems models in the form,

x = f ( x , u, t ) the state differential equation

& (1a)

y = g ( x , u, t ) the algebraic output equation (1b)

t is the time

x is the [n×1] state vector (of state variables)

u is the [m×1] input vector

y is the [p×1] output vector

f is an [n×1] non-linear, time varying vector equation with elements fi

g is a [p×1] non-linear, time varying equation with elements, gi

u - inputs system y - outputs

x - state variables

When we develop models of dynamical systems in this course, the model equations should always

be given in the form of eq(1) with the state, input and output variables clearly identified.

uin

Example 2 - Level in a cylindrical drum

An example would be a boiler drum.

R h uout

L

Systems & Simulation - ENEL3SS 3

SS1_1.DOC

The volume is, (show this!)

V = L R 2 arcsin(1 - h / R ) - ( R - h) 2 Rh - h2

also,

dV = 2 L 2 Rh - h2 dh

We can write the model using either the height or the volume as the state variable. (Remember

dh dV dV

that the mass and therefore the volume, is the conserved variable.) Recall that = and

dt dt dh

because solving for h as a function of V may be messy, we would prefer to use h as the state

variable. We get,

dh

= ( uin - uout ) 2 L 2 Rh - h2 state differential equation

dt

h=h algebraic output equation

Tank height simulation

[time,Uin]

+

From

Workspace + * 1/s height

Sum To Workspace

Product height rate -

[time,Uout] height

1/sqrt(2*1*u-u^2)

From

Workspace1 1/(dV/dh)

time_out

Clock To Workspace1

Simulink model for example 2 (R=1, L=1)

Example 3 - Mechanical system - Ping pong ball levitator

Assume that a nozzle makes a cone of air with velocity,

u( t )

v air ( h) = . u(t) is the position of a control valve, h is the ball vair

( h + )2

h

height above the nozzle and is a constant. This is an empirical law

based on heuristic understanding and laboratory measurement. nozzle

(v air - v ball )2

The ball experiences upward force as a result of drag, f up = c d A . A is the ball

2

cross sectional area, cd is the drag coefficient, is the density of the air. This is also an empirical

law, supported by theoretical investigations. We do not necessarily have to understand the cross-

disciplinary engineering behind empirical laws but they must be plausible i.e. they must make

sense!

Systems & Simulation - ENEL3SS 4

SS1_1.DOC

d ( mv)

The conserved variables are (i) momentum (recall correct version of Newton II - Fext = )

dt

and (ii) space.

u(t)

2

- v ball

dv ball 1 (h + )2

= c d A - mg

dt m 2

state differential equation

dh

= v ball

dt

(m is the mass and g the acceleration due to gravity.) Let us say that we are interested in the kinetic

energy of the ball and its height as outputs:

mv2ball

E= algebraic output equation

2

h=h

f(u) k_energy

Fcn2 To Workspace4

velocity

To Workspace3

Mux f(u) f(u) 1/s 1/s

Repeating XY Graph

Fcn Fcn1 velocity height

Sequence Mux Graph

height

To Workspace1

time

Clock To Workspace

Fcn = u(1)/(u(2)+0.02)^2-u(3)

Fcn1 = 0.44*1.205*0.01875^2*pi/2.5e-3*u^2*sgn(u)/2-9.8

( = 0.02, m=2.5g, r=18.75mm, cd = 0.44, =1.205)

Systems & Simulation - ENEL3SS 5

SS1_1.DOC

Example 4 - Manufacture within the system boundary - Cell growth in a biosystem.

S/V

Bugs grow at a rate, r = µ max cells/cell/unit time (This is known as Monod law). µmax

S / V + Ks

is the maximum growth rate, S/V is the concentration of substrate (i.e. bug food!) which changes

with time as the bugs consume it. KS is a constant - the so-called limiting substrate concentration.

If S/V=KS the growth rate is half the maximum. If S/V>>KS the growth rate is equal to µmax. Cells

consume the substrate by ×r (kg/cell/unit time) to grow.

The conserved variables of interest are the number of cells, and the amount of substrate. Assuming

that the reaction is in a fixed volume, conservation of quantities and their concentration is

equivalent. With C as the number of cells and uin the substrate feed rate, we get a model with state

differential equation,

dC S/V

= µ max C cell growth

dt S / V + Ks

dS S/V

= - µ max C + uin substrate conservation

dt S / V + Ks

Mux f(u) 1/s

Mux Fcn cells

Graph

-0.1*u(1) 1/s

Fcn1 substraste

Graph1

Systems & Simulation - ENEL3SS 6

SS1_1.DOC

Example 5 Aids

(See: Jeffrey AM, Xia X and Craig I, "On attaining maximum and durable suppression of the viral

load", African Control Conference, Cape Town, December 2003.)

Simple model is a predator-prey model (human CD4+ cells are the prey) and anti-retroviral drugs

are a control. The drugs are never 100% effective and the real system is very complicated.

Model:

dT

= s + pT (1 - T / Tm ) - T T - VT

dt

dT1

= q1 VT - 1T1 - kT1

dt

dT2

= q 2 VT - 2 T2 + kT1

dt

dV

= N 2 T2 - cV1

dt

State variables, x = [T, T1, T2, V]T are concentrations of uninfected CD4+ cells, latently infected

CD4+ cells, actively infected CD4+ cells, and free virus particles respectively.

s 10/mm3/day source production rate of uninfected cells from the body

p 0.03/day proliferation rate

Tm 1500/mm3 steady state cell count

T 0.02//day death rate constant of healthy cells

7.5×10-6/mm3/day infection effectiveness

q1 0.05 production rate constant of latently infected CD4+ cells

q2 0.55 production rate constant of actively infected CD4+ cells

1 0.02/day death rate constant of latently infected cells

2 0.5/day death rate constant of actively infected cells

k 0.075 activation rate of latently infected cells

N 2000 virons/cell production of free virus particles per actively infected cell

c 5/day death rate constant of free virus particles

The two classes of commonly used anti-retroviral agents are Reverse Transcriptase (RT) Inhibitors

and Protease Inhibitors (PI). Both agents work within the CD4+ T cell because they cannot prevent

the virus from entering the cell. Reverse Transcriptase Inhibitors reduce successful infection of the

CD4+ T cell by the virus by reducing the values of q1 and q2. Perfect inhibition would occur if the

rates were zero but in practice, perfect inhibition is not attainable. Protease Inhibitors block the

protease enzyme so that the virus particles that are produced are mostly non-infectious. There are

therefore two types of virus particles when protease inhibitors are used. The first type is the

infectious virus particles that still continue to infect CD4+ T cells and the other is the non-

infectious type. Similarly, perfect inhibition occurs when all virus particles that are produced are

noninfectious. Current therapies use a combination of Reverse Transcriptase and Protease

Inhibitors and the combined therapy model can be presented as,

Systems & Simulation - ENEL3SS 7

SS1_1.DOC

dT

= s + pT (1 - T / Tm ) - T T - VT

dt

dT1

= µ RT q1 VT - 1T1 - kT1

dt

dT2

= µ RT q 2 VT - 2 T2 + kT1

dt

dV I

= µ PI N 2 T2 - cV I

dt

dV N

= (1 - µ PI ) N 2 T2 - cV N

dt

µRT is the control input for reverse transcriptase and µPI is the control input for protease inhibitors

and the free virus particles have been split into infectious and non-infectious.

Comments

1) Build the model in Simulink and test its performance at various values of 0

2) No drug has µ· = 0 and µ· depends on patient, drug and virus.

3) CD4+ cell counts of around 200/mm3 are regarded as critically low levels.

Systems & Simulation - ENEL3SS 8

SS1_1.DOC

Dead Sea Hydro-power station.

It is proposed to build a 400MW-hydropower station on the shore of the Dead Sea. The plant will drain seawater from the Mediterranean through turbines and into the Dead Sea. The vertical distance between the inlet and outlet depends on...

See attached file for full problem description.

University of KwaZulu-Natal

School of Electrical, Electronic and Computer Engineering

SYSTEMS AND SIMULATION - ENEL3SS

0) INTRODUCTION

This is a first contact course in control systems. The broad aim of the course is to develop skills in

understanding the behaviour of physical dynamic systems and to understand the engineering tools

required for design of control systems. Specifically, we will cover the following main sections:

1) Modelling: We will develop the model of a physical system by writing down sets of first

order differential equations. The time varying variables of such a model are called the state

variables. The study of systems that are represented as state space models allows a very

fundamental understanding of system behaviour to be developed. State space

representations are used for system modelling and understanding, for computer simulation

and for controller design. We will start of with general (non-linear, time varying) models

but will focus on linear or linearised, time invariant systems.

2) Introduction to simulation and the Matlab/Simulink environment: The development of

affordable advanced computing hardware and software allows fast development of

simulation models of complex systems. We will use a Windows based program called

Matlab and a package called Simulink that runs under Matlab. This software is available

on the LAN and there is on-line help. You are expected to use Matlab for tutorials and the

development of these skills will be examined. We will illustrate the principle of simulation

by investigating first order explicit and implicit Euler methods. Packaged software uses

more advanced algorithms and is fairly reliable although simulation must be tested for

reasonableness as the algorithms used can and do fail on particular problems.

3) Linearisation and linear systems: Many problems either are linear or can be linearised. Our

interest in obtaining linear problems is that there are very powerful methods available for

analysing and designing linear systems. We will investigate the time response of linear

systems and the application of the Laplace transform to solving the differential equations.

4) Input-output descriptions of linear systems: In many cases we are more interested in the

input and output variables of a system than in the internal (or state) variables. As a result

we will investigate the input-output properties of systems and the output response of

systems to sinusoidal input signals. We will develop some understanding of the

relationship between the time domain behaviour and the frequency domain behaviour of

systems.

5) Discrete time and sampled data systems: The very widespread use of computer hardware

means that it is important to understand the behaviour of systems when part of the system is

digital hardware interfaced to the "real world" by A/D (analogue-digital) and D/A

converters.

Systems & Simulation - ENEL3SS 1

SS1_1.DOC

1. SYSTEM MODELLING

1.1. General non-linear system models

A fundamental principle in nature is that of conservation. Certain quantities in nature such as mass

and energy are conserved in the sense that they do not vanish without explanation. If we define a

physical system that is of interest to us by means of its boundary, the law of conservation is that the

rate of increase of a conserved quantity within the system is the rate at which that quantity crosses

the system boundary plus the rate of manufacture/transformation of the conserved quantity within

the system.

System

Crossing boundary

boundary

manufacture/

transformation

Conservation of a quantity within a system

This can be written as a general law:

dQ

= boundary + manufacture

dt

Q is the conserved quantity of interest. boundary is the rate at which the conserved quantity crosses

the boundary into the system (boundary

the rate at which the conserved quantity is manufactured/transformed from other quantities within

the system. In many processes there is no manufacture but we should look out for both

mechanisms.

Examples of conserved quantities: mass (of components or total), energy (kinetic, potential, heat,

chemical or total), sum of total mass and energy (generalised energy) in nuclear reactions, number

(of people, bank balances etc.).

Examples of unconserved quantities: temperature, pressure, value of money, social worth of people.

Simple example: Water level in a tank

The conserved quantity is the mass of water in the tank. (What is the

system boundary?) The water is incompressible and therefore the uin

volume and mass are directly related. The inflow/outflow is in

volume/time and the level is volume/area. For constant area,

dV V

= Net inflow rate = (uin-uout), h=V/A h uout

dt

The process is linear with respect to volume and hence with respect to

level if the area is constant.

Systems & Simulation - ENEL3SS 2

SS1_1.DOC

[time,Uin]

+

From 1/s 1 height

Workspace +

Sum flow-volume To Workspace

1/area

[time,Uout]

From

Workspace1

time_out

Clock To Workspace1

Simulink simulation of level in a tank

Modelling is an important interest of this course and like most things, it is best learned by practice,

the main learning of system modelling will be by tutorial work. We will apply knowledge from

many branches of science and engineering and the final model will be based on exact conservation

laws and empirical/phenomenological observations. The model can usually be refined if it is found

that the reality and the model do not have satisfactory agreement and can simplified by omitting

secondary effects if it is found too cumbersome for the application and if the application can

tolerate lower fidelity. We will use the modern simulation tools that are available to validate and

visualise our model.

We will generally obtain for lumped parameter systems models in the form,

x = f ( x , u, t ) the state differential equation

& (1a)

y = g ( x , u, t ) the algebraic output equation (1b)

t is the time

x is the [n×1] state vector (of state variables)

u is the [m×1] input vector

y is the [p×1] output vector

f is an [n×1] non-linear, time varying vector equation with elements fi

g is a [p×1] non-linear, time varying equation with elements, gi

u - inputs system y - outputs

x - state variables

When we develop models of dynamical systems in this course, the model equations should always

be given in the form of eq(1) with the state, input and output variables clearly identified.

uin

Example 2 - Level in a cylindrical drum

An example would be a boiler drum.

R h uout

L

Systems & Simulation - ENEL3SS 3

SS1_1.DOC

The volume is, (show this!)

V = L R 2 arcsin(1 - h / R ) - ( R - h) 2 Rh - h2

also,

dV = 2 L 2 Rh - h2 dh

We can write the model using either the height or the volume as the state variable. (Remember

dh dV dV

that the mass and therefore the volume, is the conserved variable.) Recall that = and

dt dt dh

because solving for h as a function of V may be messy, we would prefer to use h as the state

variable. We get,

dh

= ( uin - uout ) 2 L 2 Rh - h2 state differential equation

dt

h=h algebraic output equation

Tank height simulation

[time,Uin]

+

From

Workspace + * 1/s height

Sum To Workspace

Product height rate -

[time,Uout] height

1/sqrt(2*1*u-u^2)

From

Workspace1 1/(dV/dh)

time_out

Clock To Workspace1

Simulink model for example 2 (R=1, L=1)

Example 3 - Mechanical system - Ping pong ball levitator

Assume that a nozzle makes a cone of air with velocity,

u( t )

v air ( h) = . u(t) is the position of a control valve, h is the ball vair

( h + )2

h

height above the nozzle and is a constant. This is an empirical law

based on heuristic understanding and laboratory measurement. nozzle

(v air - v ball )2

The ball experiences upward force as a result of drag, f up = c d A . A is the ball

2

cross sectional area, cd is the drag coefficient, is the density of the air. This is also an empirical

law, supported by theoretical investigations. We do not necessarily have to understand the cross-

disciplinary engineering behind empirical laws but they must be plausible i.e. they must make

sense!

Systems & Simulation - ENEL3SS 4

SS1_1.DOC

d ( mv)

The conserved variables are (i) momentum (recall correct version of Newton II - Fext = )

dt

and (ii) space.

u(t)

2

- v ball

dv ball 1 (h + )2

= c d A - mg

dt m 2

state differential equation

dh

= v ball

dt

(m is the mass and g the acceleration due to gravity.) Let us say that we are interested in the kinetic

energy of the ball and its height as outputs:

mv2ball

E= algebraic output equation

2

h=h

f(u) k_energy

Fcn2 To Workspace4

velocity

To Workspace3

Mux f(u) f(u) 1/s 1/s

Repeating XY Graph

Fcn Fcn1 velocity height

Sequence Mux Graph

height

To Workspace1

time

Clock To Workspace

Fcn = u(1)/(u(2)+0.02)^2-u(3)

Fcn1 = 0.44*1.205*0.01875^2*pi/2.5e-3*u^2*sgn(u)/2-9.8

( = 0.02, m=2.5g, r=18.75mm, cd = 0.44, =1.205)

Systems & Simulation - ENEL3SS 5

SS1_1.DOC

Example 4 - Manufacture within the system boundary - Cell growth in a biosystem.

S/V

Bugs grow at a rate, r = µ max cells/cell/unit time (This is known as Monod law). µmax

S / V + Ks

is the maximum growth rate, S/V is the concentration of substrate (i.e. bug food!) which changes

with time as the bugs consume it. KS is a constant - the so-called limiting substrate concentration.

If S/V=KS the growth rate is half the maximum. If S/V>>KS the growth rate is equal to µmax. Cells

consume the substrate by ×r (kg/cell/unit time) to grow.

The conserved variables of interest are the number of cells, and the amount of substrate. Assuming

that the reaction is in a fixed volume, conservation of quantities and their concentration is

equivalent. With C as the number of cells and uin the substrate feed rate, we get a model with state

differential equation,

dC S/V

= µ max C cell growth

dt S / V + Ks

dS S/V

= - µ max C + uin substrate conservation

dt S / V + Ks

Mux f(u) 1/s

Mux Fcn cells

Graph

-0.1*u(1) 1/s

Fcn1 substraste

Graph1

Systems & Simulation - ENEL3SS 6

SS1_1.DOC

Example 5 Aids

(See: Jeffrey AM, Xia X and Craig I, "On attaining maximum and durable suppression of the viral

load", African Control Conference, Cape Town, December 2003.)

Simple model is a predator-prey model (human CD4+ cells are the prey) and anti-retroviral drugs

are a control. The drugs are never 100% effective and the real system is very complicated.

Model:

dT

= s + pT (1 - T / Tm ) - T T - VT

dt

dT1

= q1 VT - 1T1 - kT1

dt

dT2

= q 2 VT - 2 T2 + kT1

dt

dV

= N 2 T2 - cV1

dt

State variables, x = [T, T1, T2, V]T are concentrations of uninfected CD4+ cells, latently infected

CD4+ cells, actively infected CD4+ cells, and free virus particles respectively.

s 10/mm3/day source production rate of uninfected cells from the body

p 0.03/day proliferation rate

Tm 1500/mm3 steady state cell count

T 0.02//day death rate constant of healthy cells

7.5×10-6/mm3/day infection effectiveness

q1 0.05 production rate constant of latently infected CD4+ cells

q2 0.55 production rate constant of actively infected CD4+ cells

1 0.02/day death rate constant of latently infected cells

2 0.5/day death rate constant of actively infected cells

k 0.075 activation rate of latently infected cells

N 2000 virons/cell production of free virus particles per actively infected cell

c 5/day death rate constant of free virus particles

The two classes of commonly used anti-retroviral agents are Reverse Transcriptase (RT) Inhibitors

and Protease Inhibitors (PI). Both agents work within the CD4+ T cell because they cannot prevent

the virus from entering the cell. Reverse Transcriptase Inhibitors reduce successful infection of the

CD4+ T cell by the virus by reducing the values of q1 and q2. Perfect inhibition would occur if the

rates were zero but in practice, perfect inhibition is not attainable. Protease Inhibitors block the

protease enzyme so that the virus particles that are produced are mostly non-infectious. There are

therefore two types of virus particles when protease inhibitors are used. The first type is the

infectious virus particles that still continue to infect CD4+ T cells and the other is the non-

infectious type. Similarly, perfect inhibition occurs when all virus particles that are produced are

noninfectious. Current therapies use a combination of Reverse Transcriptase and Protease

Inhibitors and the combined therapy model can be presented as,

Systems & Simulation - ENEL3SS 7

SS1_1.DOC

dT

= s + pT (1 - T / Tm ) - T T - VT

dt

dT1

= µ RT q1 VT - 1T1 - kT1

dt

dT2

= µ RT q 2 VT - 2 T2 + kT1

dt

dV I

= µ PI N 2 T2 - cV I

dt

dV N

= (1 - µ PI ) N 2 T2 - cV N

dt

µRT is the control input for reverse transcriptase and µPI is the control input for protease inhibitors

and the free virus particles have been split into infectious and non-infectious.

Comments

1) Build the model in Simulink and test its performance at various values of 0

2) No drug has µ· = 0 and µ· depends on patient, drug and virus.

3) CD4+ cell counts of around 200/mm3 are regarded as critically low levels.

Systems & Simulation - ENEL3SS 8

SS1_1.DOC

### Recently Asked Questions

- Please help Directions In this Assignment, you will compose and informative essay in a minimum of 3-full pages in which you specifically address the parts

- Consider the opposing philosophical viewpoint of judicial activism and restraint. Generally speaking, the legislature makes laws and the judiciary interprets

- Jacob owns company that offers jeans in a perfectly competitive product market. Jacob is a monopsonist in the labor market, and the table below shows the