From: Michael Plante on
> I now want to write this model as: s(n + 1) = g(n, s(n), u(n)).

Does it need to be 'written' in closed form? If not, does it need to be
evaluated in real time (used in-line in an observer/estimator), or is this
for a simulation? If the latter, is it for system ID (as some have
assumed), or is it to simulate an estimator? If it's for system ID, just
do the numerical integration...it's offline anyway, and probably more
effective; the rest of this post assumes it is not for ID, since you
mention a control loop (as I understand it, ID is more difficult when you
have feedback control operating at the same time as your data collection).



>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?

With numerical integration, the ZOH is trivial: hold u(n) constant for
the appropriate amount of time. Are your equations sufficiently
well-behaved, and/or do you have sufficient confidence in your
measurements? If so, numerical integration has a relative disadvantage in
this case of impairing your ability to look at equations intuitively
(except perhaps for simple single-step fixed-step-size methods, where it's
not too laborious to apply a 'numerical' method by hand). There are
several important things to look at when picking a numerical integration
method; RK is not always appropriate. Check convergence regions of each
method, stiffness of the equations, whether a method requires several
initial time values (multistep), and whether it requires data that is not
yet known (implicit).


>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.

Do you only want the transfer functions so you can follow the wiki recipe,
or do you actually want to do analysis with them? If the latter, and if
linearization (either at a fixed point, at each step, or along a predefined
path) doesn't introduce unacceptable error, this is likely to be simpler to
write out, and is more likely to allow pencil and paper analysis. I'm a
bit confused about whether you actually care to write it out, though, since
you mention liking both c2d and transfer functions, which seems to require
two different paths.



From: Tim Wescott on
On Tue, 17 Nov 2009 19:15:31 +0100, Edward Jensen wrote:

> "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.

No, you don't _have_ to linearize if you like your nonlinear difference
equation.

In general when you go to a fully nonlinear problem you have the
opportunity to toss transfer functions -- and all of the easy system
analysis and design tools that they represent -- away.

You can keep the ZOH block, but it's up to you to figure out what to do
with it.

--
www.wescottdesign.com
From: vashkevich 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.
>
>

Too common question.

Simple example
d2X/dt2 + 10*dX/dt + 10*X*X*X = A*sin(2pi*0.01*t)

Results for A >~ 1700:

ZOH with Ts=0.1s don't works
Runge-Kutta RK4 with h = 0.1s don't works

Euler with h = 0.01s - works and gives true solution!
(10 intermediate calculation in ZOH)

If You remember, RK4 must give effective accuracy h^5,
but this is not true for nonlinear equation,
and even Euler become better with accuracy = h^2
From: JCH on

"Edward Jensen" <edward(a)jensen.invalid> schrieb im Newsbeitrag
news:hdubk2$psm$1(a)news.net.uni-c.dk...
> 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?
>


EXAMPLE

Linearizing a nonlinear differential equation (DE):

* http://home.arcor.de/janch/janch/_control/20091118-non-linear-ode/

Red points: nonlinear DE
Black points: approximated linear DE

If system is load dependent then optimize the controller (PID) on at least 3
load points and adjust the controller parameters automatically using a
polynomial.

See Note in Math Model: Model Adaptation 2


--
Regards JCH


From: pnachtwey on
On Nov 17, 11:40 pm, "JCH" <ja...(a)nospam.arcornews.de> wrote:
> "Edward Jensen" <edw...(a)jensen.invalid> schrieb im Newsbeitragnews:hdubk2$psm$1(a)news.net.uni-c.dk...
>
>
>
>
>
> > 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?
>
> EXAMPLE
>
> Linearizing a nonlinear differential equation (DE):
>
> *http://home.arcor.de/janch/janch/_control/20091118-non-linear-ode/
>
> Red points:   nonlinear DE
> Black points: approximated linear DE
>
> If system is load dependent then optimize the controller (PID) on at least 3
> load points and adjust the controller parameters automatically using a
> polynomial.
>
> See Note in Math Model: Model Adaptation 2
>
> --
> Regards JCH
Stop your nonsense. You have been able to identify any of the systems
I have provided in the past. Your system identification doesn't have
an concept of a ambient value, dead time or know the difference
between type 0 and type 1 systems. It is easy to do what you are
doing if you know the solution and then generate the problem.

Peter Nachtwey