From: Edward Jensen on
Hi.

I'm working on modeling a system which have resulted in a system of first
order nonlinear differential equations
s'(t) = f(t, s(t), u(t))
with state vector s(t) and control input u(t) and s(t), u(t) \in R^3
The measurements are simply given by y(t) = s(t).

The continuous time model is embedded in a digital control loop where there
output y(n) is a sampled version of y(t) with zero order hold and Ts = 0.1
s. Similarly the discrete control inputs u(n) is converted through zero
order hold to u(t) with the same sample time.

I now want to write this model as: s(n + 1) = g(n, s(n), u(n)). I know how
to do this is for a linear continous time continous model s'(t) = Ax(t) +
Bu(t) with the c2d fuction but I am in doubt how to do this for the
nonlinear model.

Should I linearize the continous time differential equation first or what is
the best method?

Thanks in advance.




From: Vladimir Vassilevsky on


Edward Jensen wrote:
> Hi.
>
> I'm working on modeling a system which have resulted in a system of first
> order nonlinear differential equations
> s'(t) = f(t, s(t), u(t))
> with state vector s(t) and control input u(t) and s(t), u(t) \in R^3
> The measurements are simply given by y(t) = s(t).
>
> The continuous time model is embedded in a digital control loop where there
> output y(n) is a sampled version of y(t) with zero order hold and Ts = 0.1
> s. Similarly the discrete control inputs u(n) is converted through zero
> order hold to u(t) with the same sample time.
>
> I now want to write this model as: s(n + 1) = g(n, s(n), u(n)). I know how
> to do this is for a linear continous time continous model s'(t) = Ax(t) +
> Bu(t) with the c2d fuction but I am in doubt how to do this for the
> nonlinear model.
>
> Should I linearize the continous time differential equation first or what is
> the best method?

http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods


Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
From: Tim Wescott on
On Tue, 17 Nov 2009 15:22:52 +0100, Edward Jensen wrote:

> Hi.
>
> I'm working on modeling a system which have resulted in a system of
> first order nonlinear differential equations s'(t) = f(t, s(t), u(t))
> with state vector s(t) and control input u(t) and s(t), u(t) \in R^3 The
> measurements are simply given by y(t) = s(t).
>
> The continuous time model is embedded in a digital control loop where
> there output y(n) is a sampled version of y(t) with zero order hold and
> Ts = 0.1 s. Similarly the discrete control inputs u(n) is converted
> through zero order hold to u(t) with the same sample time.
>
> I now want to write this model as: s(n + 1) = g(n, s(n), u(n)). I know
> how to do this is for a linear continous time continous model s'(t) =
> Ax(t) + Bu(t) with the c2d fuction but I am in doubt how to do this for
> the nonlinear model.
>
> Should I linearize the continous time differential equation first or
> what is the best method?
>
> Thanks in advance.

(I'm cross-posting my reply to sci.engr.control - really this time)

The best way to do this is the way that works right for your problem.

Isn't that helpful?

This being a nonlinear problem chances are that any solution is going to
be approximate. If you're lucky then that's not the case, you can do an
exact solution at each time step -- but then, if that were the case you
probably wouldn't be asking.

What you have to fall back onto is your bag of tricks. Any effort to
control a nonlinear system involves having a bag of mathematical tricks.
You try out tricks from your bag, and when you find one that works well
enough you test the heck out of it and you call it good.

In general when I do this sort of thing I figure out the amount of error
that I can tolerate, and I choose the easiest method for solving the
differential equation that meets that error criterion. This may mean
trying to find an exact solution, it may mean finding a way to express the
system so that I can do a one-time linearization and keep the errors in
check through feedback, it may mean that I use simple rectangular
integration at each step (and maybe crank the sample rate way up) -- there
are a number of different methods that one can try, but if there were One
True Method then folks wouldn't bother teaching so much linear systems
theory.

--
www.wescottdesign.com





--
www.wescottdesign.com
From: Edward Jensen on
"Tim Wescott" <tim(a)seemywebsite.com> wrote in message
news:3sudnSoYDfzbTp_WnZ2dnUVZ_rli4p2d(a)web-ster.com...
> On Tue, 17 Nov 2009 15:22:52 +0100, Edward Jensen wrote:
>
>> Hi.
>>
>> I'm working on modeling a system which have resulted in a system of
>> first order nonlinear differential equations s'(t) = f(t, s(t), u(t))
>> with state vector s(t) and control input u(t) and s(t), u(t) \in R^3 The
>> measurements are simply given by y(t) = s(t).
>>
>> The continuous time model is embedded in a digital control loop where
>> there output y(n) is a sampled version of y(t) with zero order hold and
>> Ts = 0.1 s. Similarly the discrete control inputs u(n) is converted
>> through zero order hold to u(t) with the same sample time.
>>
>> I now want to write this model as: s(n + 1) = g(n, s(n), u(n)). I know
>> how to do this is for a linear continous time continous model s'(t) =
>> Ax(t) + Bu(t) with the c2d fuction but I am in doubt how to do this for
>> the nonlinear model.
>>
>> Should I linearize the continous time differential equation first or
>> what is the best method?
>>
>> Thanks in advance.
>
> (I'm cross-posting my reply to sci.engr.control)
>
> The best way to do this is the way that works right for your problem.
>
> Isn't that helpful?
>
> This being a nonlinear problem chances are that any solution is going to
> be approximate. If you're lucky then that's not the case, you can do an
> exact solution at each time step -- but then, if that were the case you
> probably wouldn't be asking.
>
> What you have to fall back onto is your bag of tricks. Any effort to
> control a nonlinear system involves having a bag of mathematical tricks.
> You try out tricks from your bag, and when you find one that works well
> enough you test the heck out of it and you call it good.
>
> In general when I do this sort of thing I figure out the amount of error
> that I can tolerate, and I choose the easiest method for solving the
> differential equation that meets that error criterion. This may mean
> trying to find an exact solution, it may mean finding a way to express
> the system so that I can do a one-time linearization and keep the errors
> in check through feedback, it may mean that I use simple rectangular
> integration at each step (and maybe crank the sample rate way up) --
> there are a number of different methods that one can try, but if there
> were One True Method then folks wouldn't bother teaching so much linear
> systems theory.

Thanks for your reply. Of course you are correct when saying that there is
no best way. What confuses me is that I have never at the university tried
solving a nonlinear problem like this.
We have always worked with a linear differential equation which we have
discretized using the aproach outlined at
http://en.wikipedia.org/wiki/Discretization#Discretization_of_linear_state_space_models
which corresponds to what Matlab does with the c2d function with the 'zoh'
argument.

My question is basically: Can I add a ZOH term to the nonlinear difference
equation that is an approximation of the nonlinear differential equation
using fx a Runge-Kutta method as Vladmir links to or is a linearization of
the differential equation required such that the method given in the wiki
link can be used?

In the first case I will not have a LTI system and I am unsure how to work
with transfer functions and the ZOH block in such a case.

Thanks again.


From: pnachtwey on
On Nov 17, 10:15 am, "Edward Jensen" <edw...(a)jensen.invalid> wrote:
> "Tim Wescott" <t...(a)seemywebsite.com> wrote in message
>
> news:3sudnSoYDfzbTp_WnZ2dnUVZ_rli4p2d(a)web-ster.com...
>
>
>
>
>
> > On Tue, 17 Nov 2009 15:22:52 +0100, Edward Jensen wrote:
>
> >> Hi.
>
> >> I'm working on modeling a system which have resulted in a system of
> >> first order nonlinear differential equations s'(t) = f(t, s(t), u(t))
> >> with state vector s(t) and control input u(t) and s(t), u(t) \in R^3 The
> >> measurements are simply given by y(t) = s(t).
>
> >> The continuous time model is embedded in a digital control loop where
> >> there output y(n) is a sampled version of y(t) with zero order hold and
> >> Ts = 0.1 s. Similarly the discrete control inputs u(n) is converted
> >> through zero order hold to u(t) with the same sample time.
>
> >> I now want to write this model as: s(n + 1) = g(n, s(n), u(n)). I know
> >> how to do this is for a linear continous time continous model s'(t) =
> >> Ax(t) + Bu(t) with the c2d fuction but I am in doubt how to do this for
> >> the nonlinear model.
>
> >> Should I linearize the continous time differential equation first or
> >> what is the best method?
>
> >> Thanks in advance.
>
> > (I'm cross-posting my reply to sci.engr.control)
>
> > The best way to do this is the way that works right for your problem.
>
> > Isn't that helpful?
>
> > This being a nonlinear problem chances are that any solution is going to
> > be approximate.  If you're lucky then that's not the case, you can do an
> > exact solution at each time step -- but then, if that were the case you
> > probably wouldn't be asking.
>
> > What you have to fall back onto is your bag of tricks.  Any effort to
> > control a nonlinear system involves having a bag of mathematical tricks..
> > You try out tricks from your bag, and when you find one that works well
> > enough you test the heck out of it and you call it good.
>
> > In general when I do this sort of thing I figure out the amount of error
> > that I can tolerate, and I choose the easiest method for solving the
> > differential equation that meets that error criterion.  This may mean
> > trying to find an exact solution, it may mean finding a way to express
> > the system so that I can do a one-time linearization and keep the errors
> > in check through feedback, it may mean that I use simple rectangular
> > integration at each step (and maybe crank the sample rate way up) --
> > there are a number of different methods that one can try, but if there
> > were One True Method then folks wouldn't bother teaching so much linear
> > systems theory.
>
> Thanks for your  reply. Of course you are correct when saying that there is
> no best way. What confuses me is that I have never at the university tried
> solving a nonlinear problem like this.
We didn't even know what system identification was when I went to
college.

> We have always worked with a linear differential equation which we have
> discretized using the aproach outlined athttp://en.wikipedia.org/wiki/Discretization#Discretization_of_linear_...
> which corresponds to what Matlab does with the c2d function with the 'zoh'
> argument.
Good start but I prefer the RK approach because it is easier to handle
dead times and non-linearities.
>
> My question is basically: Can I add a ZOH term to the nonlinear difference
> equation that is an approximation of the nonlinear differential equation
> using fx a Runge-Kutta method as Vladmir links to or is a linearization of
> the differential equation required such that the method given in the wiki
> link can be used?
The problem is that optimizing routines need to be able to change the
dead time continuously. Therefore you must provide a way to
interpolated between signals if using discrete methods. Usually a
linear interpolation is good enough. With RK this isn't a problem.
>
> In the first case I will not have a LTI system and I am unsure how to work
> with transfer functions and the ZOH block in such a case.
>
> Thanks again.
I recently posted a link to a pdf that shows how I do system
identification on another use group.
I will make this post do double duty
http://groups.google.com/group/sci.engr.control/browse_frm/thread/b7039c3c82914398#
It shows how one can use RK4 and a optimization routine to ID a
differential equation. Actually you can use this technique to ID
coefficients for several differential equations but it is best to
limit what needs to be identified.
One simply adds all the differential equations to the D(y,t) function
to make a system of differential equations. However,
It is best to ID each component separately if possible, divide and
conquer. Sometime the system identification can find many
combinations of parameters that seem to fit the test data.

It would help to know what you are trying to do. I deal with
hydraulics and that has sqrt functions in the differential equations.
I simply live and work with that that. Many fluid applications have
functions like v'=a*v^2+b. It is easy enough to find a and b but
these coefficients are usually made of many other parameters.
Obviously system identification will not help unless I know all but
one of the parameters that make up a and b.

Peter Nachtwey