18 Tools for dynamical systems
18.1 artest arnold dynamical system
CALLING SEQUENCE :
artest(f_l,[odem,xdim,npts])
arnold(t,x)
iarf([a])
PARAMETERS :
- f_l
: can be "arnold" or arnold. It is the name of the external for the arnold system. If
f_l is set to "arnold" a Fortran coded version of the arnold system where a(1:6)=1
will be used and if f_l is set to arnold a Scilab coded version will be used .
arnold is a Scilab macro coding the Arnold system. This macro is loaded when calling artest.
- iarf
: is used to fix the values of a in the Scilab coded case. a is a vector of size 6.
- odem,xdim,npts
: are optional arguments. Their meaning and syntax can be found in the portr3d help
DESCRIPTION :
A call to the function artest() will interactively
display a phase portrait of a the following dynamical system :
ydot(1)=a(1)*cos(y(2)) +a(2)*sin(y(3))
ydot(2)=a(3)*cos(y(3)) +a(4)*sin(y(1))
ydot(3)=a(5)*cos(y(1)) +a(6)*sin(y(2))
See Also :
portr3d
X, ode
X, chaintest
X, lotest
X
18.2 bifish shows a bifurcation diagram in a fish population discrete time model
CALLING SEQUENCE :
bifish([f_ch])
PARAMETERS :
- f_ch
: can be one of fish, fishr and fishr2. This option selects the population model.
DESCRIPTION :
The dynamical system fish is the following :
y=b*exp(-0.1*(x(k)_1+x(k)_2));
x(k+1)=[ y 2*y ; s 0.0]*x(k);
and the parameters s evolves to show the bifurcation diagram.
fishr and fishr2 are constructed as above but with added white noises.
fishr
y=b*exp(-0.1*(xk(1)+xk(2)))
xkp1=[ y 2*y ; s*(1+0.1*(rand()-0.5)) 0.0]*xk
fishr2
z=exp(-0.1*(xk(1)+xk(2)))
xkp1=[ b*z**(1+0.1*(rand()-0.5)) 2*b*z**(1+0.1*(rand()-0.5)) ; s 0.0]*xk
The three macros fish, fishr, fishr2 are loaded in Scilab when calling bifish.
See Also :
ode
X
18.3 boucle phase portrait of a dynamical system with observer
CALLING SEQUENCE :
[]=boucle(fch,[abruit,xdim,npts,farrow])
PARAMETERS :
- fch
: Scilab macro. fch is supposed to be an observed-controlled system with
noisy output of state dimension 4 ( [x;xchap] is of dimension 4).
fch can be created with the macro obscont1 or can be set to one of the two following string
which gives pre computed examples
1
- "bcomp"
: for a non-linear competition model.
- "lcomp"
: for a linear example.
0
- abruit
: give the noise variance.
- xdim,npts,farrow
: See portrait
DESCRIPTION :
Phase portrait of dynamical systems.
See Also :
portrait
X, ode
X, obscont1
X
18.4 chaintest a three-species food chain model
CALLING SEQUENCE :
chaintest([f_l,b1,odem,xdim,npts])
[xdot]=chain(t,x)
[z1]=ch_f1(u)
[z2]=ch_f2(u)
PARAMETERS :
- f_l
: the name of the macro which code the three-species food chain model (default
value chain).
- odem,xdim,npts
: are optional arguments. Their meaning and syntax can be found in the portr3d help
DESCRIPTION :
A call to the function chaintest() will interactively
display a phase portrait of a three-species food chain model given by:
ff1= f1(x(1))
ff2= f2(x(2))
xdot1= x(1)*(1-x(1)) - ff1*x(2)
xdot2= ff1*x(2) - ff2*x(3) - 0.4*x(2)
xdot3= ff2*x(3) - 0.01*x(3)
and
f1(u)=5*u/(1+b1*u)
f2(u)z2=0.1*u/(1+2*u)
The default value for b1 is 3.0.
The Scilab macros chain(t,x),f1(u),f2(u) code the dynamical system
See Also :
portr3d
X, ode
X
18.5 gpeche a fishing program
CALLING SEQUENCE :
[xk,ukp1]=gpeche(uk,pasg)
[ut]=peche(t)
[pdot]=pechep(t,p)
DESCRIPTION :
gpeche Iterates a gradient method on a fishing problem
Computes the trajectory associated to the command law uk prints the cost value and computes a new control.
18.6 fusee a set of Scilab macro for a landing rocket problem
FUSEE :
[xdot]=fusee(t,x)
Dynamical motion equation for the rocket
FINIT :
finit()
Initialises the following parameters for rocket landing.
- k
: The acceleration of the rocket engines
- gamma
: The moon gravity acceleration.
- umax
: the gaz ejection flow out.
- mcap
: the mass of the space capsule.
- cpen
: penalisation in the cost function of the final state.
FUSEEGRAD :
[ukp1]=fuseegrad(niter,ukp1,pasg)
- niter
: number of gradient iteration steps.
- ukp1
: initial control value ( vector of sie 135 )
- pasg
: the gradient step value.
DESCRIPTION :
Iterate a gradient method and returns the computed control.
FUSEEP :
[pdot]=fuseep(t,p)
DESCRIPTION :
adjoint equation for the landing rocket problem.
POUSSE :
[ut]=pousse(t)
return the value of a piece wise constant control
build on the discrete control uk
UBANG :
[uk]=ubang(tf,tcom)
returns a bang-bang control, 0 form time 0 to tcom
and 1 form tcom to tf.
FCOUT :
[c,xk,pk,ukp1]=fcout(tf,uk,pasg)
DESCRITION :
optimise the following cost function by gradient iterations.
c = -m(tf) + C*( h(tf)**2 + v(tf)**2)
SFUSEE :
[]=sfusee(tau,h0,v0,m0,Tf)
DESCRIPTION :
computes the rocket trajectory when a bang-bang control is used
tau is the commutation time.
- h0
: The initial position (high)
- v0
: The initial speed ( negative if the rocket is landing )
- m0
: The total initial mass ( capsule and fuel).
- Tf
: Time horizon.
EQUAD :
DESCRIPTION :
[xk,pk]=equad(tf,uk)
Computes the state and adjoint state of the rocket system for a given
control ur.
TRAJ :
[xt]=traj(t)
returns a piece wise value of the mass evolution.
18.7 lotest demo of the Lorenz attractor
CALLING SEQUENCE :
[]=lotest([f_l,odem,xdim,npts,pinit])
[y]=lorenz(t,x)
[]=ilo(sig,ro,beta)
[]=ilof(sig,ro,beta)
PARAMETERS :
- f_l
: can be "loren" or lorenz. it is the name of the external for
the Lorenz system.
"loren" will use a Fortran coded version of the lorenz system
and arnold will and loren will use a Scilab coded version.lorentz is the Scilab macro which code the lorenz system.
This macro is loaded when calling lotest.
- ilof, ilo
:are used to fix the parameters of the Fortran and Scilab code version of the
Lorenz system.
- odem,xdim,npts
: are optional arguments. Their meaning and syntax can be found in the portr3d
help
DESCRIPTION :
A call to the function lotest() will interactively
display a phase portrait of a the following dynamical system
y(1)=sig*(x(2)-x(1));
y(2)=ro*x(1) -x(2)-x(1)*x(3);
y(3)=-beta*x(3)+x(1)*x(2);
See Also :
portr3d
X, ode
X, chaintest
X, lotest
X
18.8 mine a mining problem
CALLING SEQUENCE :
[cout,feed]=mine(n1,n2,uvect)
PARAMETERS :
- n1
: Number of discrete point for the state.
- n2
: Number of time step
- uvect
: a row vector which gives the possible control value ( integer values ).
for example u=[-1,0,1] means that at each step we come down one step
or stay at the same level or rise one step ).
- cout(n1,n2)
: The Bellman values.
- feed(n1,n2)
: The feedback Law.
DESCRIPTION :
Dynamic programming applied to an optimal extraction of ore in an opencast mine.
The extraction is done as follows : the steam shovel move forward for (k=1,2,...,n2)
at each step it takes the ore, then move up or down (or stay at the same level)
according to the control value to reach another level at next step.
The extraction process must maximise the following cost :
-- n2-1
\\
/ f(x(k),k) + V_F(x,n2)
-- k=1
with x(k+1)=x(k) + u. x(k) is the trajectory depth at step k (x=1 is the ground level).
The instantaneous cost f(i,k) stands for the benefit of digging at depth i at position k.
It must be given as a Scilab macro ff_o
[y]=ff_o(x,k)
and for efficiency ff_o must accept and return column vectors for x and y.
V_F(i,n2) is a final cost which is set so as to impose the steam shovel to be at ground level
at position n2
FF_O :
SHOWCOST :
CALLING SEQUENCE :
[]=showcost(n1,n2,teta,alpha)
DESCRIPTION :
Shows a 3D representation of the instantaneous cost.
18.9 obscont1 a controlled-observed system
CALLING SEQUENCE :
[macr]=obscont1(sysn)
PARAMETERS :
- sysn
: A Scilab string which gives the name of the controlled system.
- gaincom,gainobs
: column vectors giving the requested gains
- macr
: a new Scilab function which simulates the controlled observed system.
[x1dot]=macr(t,x1,abruit,pas,n)
x1=[x;xchap],
DESCRIPTION :
This macros return a new function which computes the controlled observed
version of a linearised system around the (xe,ue) point.
before calling this function, a noise vector br should be created.
the equilibrium point (xe,ue) should be given as a global Scilab.
the linearised system $f,g,h$ and the two gain matrices l,k are
returned as global Scilab data.
18.10 portr3d 3 dimensional phase portrait.
CALLING SEQUENCE :
[]=portr3d(f,[odem,xdim,npts,pinit])
PARAMETERS :
- f
: a Scilab external which gives the field of the dynamical system. Hence
it can be a macro name which computes the field at time t and point x [y]=f(t,x,[u])
or a list list(f1,u1) where f1 is a macro of type [y]=f1(t,x,u) or a character string
- rest
: The other parameters are optional. If omitted they will be asked interactively
1
- odem
: gives the integration method to use. The value "default" can be used,
otherwise see ode for a complete set of possibilities
- npts
: a vector of size (2,10) [number-of-points,step] gives the step for integration
and the number of requested points. The solution will be calculated and drawn
for time=0:step:(step*[number-of-points])
- xdim
: [xmin,xmax,ymin,ymax,zmin,zmax] the boundaries of the graphic frame.
- pinit
: initial values for integration. A set of initial points can be given in a matrix
pinit = [x0(1), x1(1),...., xn(1)
x0(2), x1(2),...., xn(2)
x0(3), x1(3),...., xn(3)].
0
DESCRIPTION :
Interactive integration and display of a 3 dimensional phase portrait
of a dynamical system dx/dt=f(t,x,[u]) (where u is an optional parameter )
See Also :
ode
X
18.11 portrait 2 dimensional phase portrait.
CALLING SEQUENCE :
[]=portrait(f,[odem,xdim,npts,pinit])
PARAMETERS :
- f
: a Scilab external which gives the field of the dynamical system. Hence
it can be a macro name which computes the field at time t and point x [y]=f(t,x,[u])
or a list list(f1,u1) where f1 is a macro of type [y]=f1(t,x,u) or a character string.
The macro can be used to simulate a continuous or discrete system and in case
of discrete system the second parameter must be set to 'discrete'
- rest
: The other parameters are optional. If omitted they will be asked interactively
1
- odem
: gives the integration method to use. The value "default" can be used,
otherwise see ode for a complete set of possibilities
- npts
: a vector of size (2,10) [number-of-points,step] gives the step for integration
and the number of requested points. The solution will be calculated and drawn
for time=0:step:(step*[number-of-points])
- xdim
: [xmin,xmax,ymin,ymax,zmin,zmax] the boundaries of the graphic frame.
- pinit
: initial values for integration. A set of initial points can be given in a matrix
pinit = [x0(1), x1(1),...., xn(1)
x0(2), x1(2),...., xn(2)
x0(3), x1(3),...., xn(3)].
0
DESCRIPTION :
Interactive integration and display of a 2 dimensional phase portrait
of a dynamical system dx/dt=f(t,x,[u]) (where u is an optional parameter )
EXAMPLE :
a=rand(2,2)
deff('[ydot]=l_s(t,y)','ydot=a*y')
portrait(l_s)
See Also :
ode
X
18.12 recur a bilinear recurrent equation
CALLING SEQUENCE :
[y]=recur(x0,var,k,n)
[integr]=logr(k,var)
DESCRIPTION :
computes solutions of a bilinear recurrent equation
x(i+1)=-x(i)*(k + sqrt(var)*br(i))
with initial value x0 and driven by a white noise
of variance var.
Trajectories are drawn and the empirical Lyapunov exponent
is returned
( x(i) is not to much different from exp(y*i) )
A theoretical computation of the Lyapunov exponent
is given by
[integr]=logr(k,var)
18.13 systems a collection of dynamical system
CALLING SEQUENCE :
[]=systems()
DESCRIPTION :
A call to this function will load into Scilab a set of macros which
describes dynamical systems. Their parameters can be initiated by
calling the routine tdinit().
BIOREACT :
[ydot]=biorecat(t,x)
a bioreactor model,
COMPET :
[xdot]=compet(t,x [,u])
a competition model. x(1),x(2) stands for two populations which
grows on a same resource. 1/u is the level of that resource (
1 is the default value).
xdot=0*ones(2,1);
xdot(1) = ppr*x(1)*(1-x(1)/ppk) - u*ppa*x(1)*x(2) ,
xdot(2) = pps*x(2)*(1-x(2)/ppl) - u*ppb*x(1)*x(2) ,
- The macro [xe]=equilcom(ue)
computes an equilibrium point of the competition model and a fixed
level of the resource ue ( default value is 1)
- The macro [f,g,h,linsy]=lincomp([ue])
gives the linearisation of the competition model ( with output y=x)
around the equilibrium point xe=equilcom(ue).
This macro returns [f,g,h] the three matrices of the linearised system.
and linsy which is a Scilab macro [ydot]=linsy(t,x) which computes the
dynamics of the linearised system
CYCLLIM :
[xdot]=cycllim(t,x)
a model with a limit cycle
xdot=a*x+qeps(1-||x||**2)x
LINEAR :
[xdot]=linear(t,x)
a linear system
BLINPER :
[xdot]=linper(t,x)
a linear system with quadratic perturbations.
POP :
[xdot]=pop(t,x)
a fish population model
xdot= 10*x*(1-x/K)- peche(t)*x
PROIE :
a Predator prey model with external insecticide.
[xdot]=p_p(t,x,[u]
LINCOM :
[xdot]=lincom(t,x,k)
linear system with a feedback
xdot= a*x +b*(-k*x)
See Also :
tdinit
X
18.14 tangent linearization of a dynamical system at an equilibrium point
CALLING SEQUENCE :
[f,g,newm]=tangent(ff,xe,[ue])
PARAMETERS :
- ff
: a string which gives the name of the Scilab macro which codes the system
- xe
: column vector which gives the equilibrium point for the value ue of the parameter
- ue
: real value.
- f, g
: two matrices for the linearised system dxdot=f.dx + g.du
- newm
: A new macro of type [y]=newm(t,x,u) which computes the field of the linearised system (newm(t,xe,ue)=0)
DESCRIPTION :
linearises around the equilibrium point (xe,ue) the vector field of
the dynamical system given by a Scilab macro ff, xdot=ff(t,x,[u]).
The dynamical system is supposed to be autonomous.
18.15 tdinit interactive initialisation of the tdcs dynamical systems
CALLING SEQUENCE :
tdinit()
DESCRIPTION :
This macro can be used to interactively define the parameters needed
by the dynamical systems described in systems
1
- bioreactor model
- competition model
- system with limit cycle
- linear system
- quadratic model
- linear system with a feedback
- prey predatory model
0
See Also :
portrait
X, systems
X