2
$\begingroup$

My question is a continuation of the topic Which way of solving from nonlinear control to choose?, and in the future I plan to expand this question.

I want to try to apply this article https://www.wolfram.com/mathematica/new-in-10/nonlinear-control-systems/asymptotic-output-tracking.html but for a different ODE or ODE system.

Edit: Take system of ODE with output $y$ for example:

$\begin{cases} \frac{dx}{dt}=H \cdot \sin(t)+u \\ \frac{dH}{dt}+h \cdot H = \frac{df}{dt} \\ y=x \end{cases} $

where $f=-x^2$, $x$ and $H$ - variables, $h$ - constant, $y$ - output.

To begin with Asymptotic Output Tracking, we transform system of ODE into the affine state-space https://reference.wolfram.com/language/ref/AffineStateSpaceModel.html.

Here is my code.

Clear["Derivative"]

ClearAll["Global`*"]

pars = {xs = -1, h = 1}

f = -x^2

ode = {x', H'} == {H Sin[t] + u, f' - h H}

asys = AffineStateSpaceModel[
  NonlinearStateSpaceModel[{ode[[2]], {x}}, {{x, xs}, {H, 
     1}}, {u}]]

I would be grateful for any help and support in resolving the issue.

NEW EDIT: This is my code for $f=\log (\text{sech}(1-x(t)))$ and two outputs y={D[f, x[t]], x[t]}

Clear["Derivative"]

ClearAll["Global`*"]

pars = {xs = -1, xe = 1, h = 1, \[Beta] = 1}

f = Log[Sech[(x[t] - xe)]]

assm = AffineStateSpaceModel[{x'[t] == H[t] Sin[t] + u[t], 
   H'[t] + h H[t] == D[f, t]}, {{x[t], xs}, {H[t], 0}}, 
  u[t], {D[f, x[t]], x[t]}, t]

ref = Exp[-\[Beta] t]

pars1 = {Subscript[p, 1] -> -1}

fb = AsymptoticOutputTracker[assm, ref, {Subscript[p, 1]}] /. pars1

csys = SystemsModelStateFeedbackConnect[assm, fb]

{xe, OutputResponse[{csys}, {0, 0}, {t, 0, 10}]}

Plot[%, {t, 0, 10}, PlotRange -> All]

NEW PROBLEM (16.02.2021):

 Clear["Derivative"]

ClearAll["Global`*"]

f = -((x[t] + \[Alpha]1 Sin[\[Omega]1 t] - 
       xe)^2 + (y[t] + \[Alpha]2 Sin[\[Omega]2 t] - ye)^2)

asys = AffineStateSpaceModel[{x'[t] == 
     f \[Alpha]1 Sin[\[Omega]1 t] + u1[t], 
    y'[t] == f \[Alpha]2 Sin[\[Omega]2 t] + u2[t]}, {{x[t], 
     xs}, {y[t], ys}}, {u1[t], u2[t]}, {f \[Alpha]1 Sin[\[Omega]1 t], 
    f \[Alpha]2 Sin[\[Omega]2 t]}, t] // Simplify

pars1 = {Subscript[r, 1] -> (-(\[Alpha]1 Sin[\[Omega]1 t])^3), 
  Subscript[r, 2] -> (-(\[Alpha]2 Sin[\[Omega]2 t])^3), 
  Subscript[p, 1] -> -5, Subscript[p, 2] -> -5}

pars = {\[Alpha]1 = 0.35, \[Omega]1 = 1, \[Alpha]2 = 0.35, \[Omega]2 =
    2, xs = -1, xe = 1, ys = 2, ye = -2, h1 = 1, h2 = 1}

fb = AsymptoticOutputTracker[
    asys, {Subscript[r, 1], Subscript[r, 2]}, {Subscript[p, 1], 
     Subscript[p, 2]}] /. pars1 // Simplify

ERROR:

AsymptoticOutputTracker::dmat2: The decoupling matrix {{0.,Sin[t] (<<1>>)},{0.,Sin[2 t] (<<1>>)}} has no columns with two or more nonzero elements, and hence the extension algorithm fails.

AsymptoticOutputTracker::dmat2: The decoupling matrix {{0.,Sin[t] (<<1>>)},{0.,Sin[2 t] (<<1>>)}} has no columns with two or more nonzero elements, and hence the extension algorithm fails.

What is this error related to?

$\endgroup$
1
  • $\begingroup$ Apparently you cross posted it at engineering.stackexchange.com/questions/40211, and it appears to me that you are not quite sure what to ask. I have attempted an answer by party reading between the lines. For any follow-up please make your question more clear. $\endgroup$ Feb 8, 2021 at 20:26

1 Answer 1

3
$\begingroup$

Updated answer

Use the chain rule and express $f'[t]$ in terms of $x'[t]$. Then the two equations can be solved for $x'[t]$ and $H'[t]$. AffineStateSpaceModel (including NonlinearStateSpaceModel and StateSpaceModel) can handle this automatically.

The model:

assm = AffineStateSpaceModel[{x'[t] == H[t] Sin[t] + u[t], 
 H'[t] + h H[t] == D[-x[t]^2, t]}, {x[t], H[t]}, u[t], x[t], t];

The signal the output should track:

ref = x0 Exp[-β t] t^3; (* just the exponential term is rather bland *)

The feedback controller:

fb = AsymptoticOutputTracker[assm, ref, {p1}]

$t^2 \text{x0} e^{\beta (-t)} (\text{p1} t+\beta t-3)-\text{p1} x_1(t)+\sin (t) x_2(t)$

The closed-loop system:

csys = SystemsModelStateFeedbackConnect[assm, fb];

Simulate by substituting some values:

{ref /. {β -> 1, x0 -> 1}, OutputResponse[{csys, x0} /. {β -> 1, x0 -> 1, p1 -> -1}, {0}, t
    ][[1]]} // Simplify // Quiet;
Plot[%, {t, 0, 15}, PlotRange -> All]

enter image description here

Case when $f$ is $e^{-(x-1)^2}$ and $x$ is the output

assm = AffineStateSpaceModel[{x'[t] == H[t] Sin[t] + u[t], 
    H'[t] + h H[t] == D[Exp[-(x[t] - 1)^2], t]}, {x[t], H[t]}, u[t], 
   x[t], t];

ref = x0 Exp[-β t] t^3;

fb = AsymptoticOutputTracker[assm, ref, {p1}];

csys = SystemsModelStateFeedbackConnect[assm, fb];

{ref /. {β -> 1, x0 -> 1}, 
   OutputResponse[{csys, x0} /. {β -> 1, x0 -> 1, h -> 1, p1 -> -1}, 
     {0}, {t, 0, 10}][[1]]} // Simplify ;
Plot[%, {t, 0, 10}, PlotRange -> All]

enter image description here

Previous answer

The model:

assm = AffineStateSpaceModel[{{Exp[-x[t]^2]}, {{1}}, {Exp[-x[t]^2]}}, x[t], u[t], y[t], t];

The signal the output should track:

ref = x0 Exp[-β t] t^3; (* just the exponential term is rather bland *)

The feedback controller:

fb = AsymptoticOutputTracker[assm, ref, p]

$\frac{t^2 \text{x0} (p t+\beta t-3) \left(-e^{x(t)^2-\beta t}\right)+p+2 e^{-x(t)^2} x(t)}{2 x(t)}$

The closed-loop system:

csys = SystemsModelStateFeedbackConnect[assm, fb];

Simulate by substituting some values:

{ref /. {β -> 1, x0 -> 1}, OutputResponse[{csys, x0} /. {β -> 1, x0 -> 1, p -> -1}, {0}, t
    ][[1]]} // Simplify // Quiet;
Plot[%, {t, 0, 15}, PlotRange -> All]

enter image description here

$\endgroup$
14
  • $\begingroup$ What if I want to use not $x(t)$ as an output, but $\frac{df}{dx}$ or $x(t)+H(t)$ for example $\endgroup$
    – dtn
    Feb 10, 2021 at 3:54
  • $\begingroup$ Can this code be extended to a multi-input system? $\endgroup$
    – dtn
    Feb 10, 2021 at 9:53
  • $\begingroup$ The answer to all your questions is yes. I was able get the simulation working by switching to a numeric one or changing the reference to $x0 e^{\beta (-t)}$. For multiple inputs see reference.wolfram.com/language/ref/…. $\endgroup$ Feb 10, 2021 at 14:10
  • $\begingroup$ Try to use function $f=e^{-(x-1)^2}$, and also $x(t)$ as an output. For some reason, the solution for $x(t)$ does not transition from state $xs=-1$ to state $1$. $\endgroup$
    – dtn
    Feb 10, 2021 at 14:18
  • 1
    $\begingroup$ Dear Suba Thomas, please see my new edit. mathematica.stackexchange.com/questions/239610/… Is it correct? That's what i mean. $\endgroup$
    – dtn
    Feb 11, 2021 at 4:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.