Simulation with observer based state feedback of the string with mass model

Simulation environment

Simulation of the string with mass example, with flatness based state feedback and flatness based state observer (design + approximation), presented in [RW2018a].

References

[RW2018a]

Marcus Riesmeier and Frank Woittennek; Modale Approximation eines verteiltparametrischen Beobachters für das Modell der Saite mit Last. GMA Fachausschuss 1.40 „Systemtheorie und Regelungstechnik“, Salzburg, Austria, September 17-20, 2018.

class FlatString(y0, y1, z0, z1, t0, dt, params)

Bases: pyinduct.simulation.SimulationInput

Flatness based feedforward for the “string with mass” model.

The flat output y of this system is given by the mass position at z = z_0 . This output will be transferred from y0 to y1 starting at t0, lasting dt seconds.

Parameters:
  • y0 (float) – Initial value for the flat output.

  • y1 (float) – Final value for the flat output.

  • z0 (float) – Position of the flat output (left side of the string).

  • z1 (float) – Position of the actuation (right side of the string).

  • t0 (float) – Time to start the transfer.

  • dt (float) – Duration of the transfer.

  • params (bunch) – Structure containing the physical parameters: * m: the mass * tau: the * sigma: the strings tension

class Parameters
class PgDataPlot(data)

Bases: DataPlot, pyqtgraph.QtCore.QObject

Base class for all pyqtgraph plotting related classes.

class SecondOrderFeedForward(desired_handle)

Bases: pyinduct.examples.string_with_mass.system.pi.SimulationInput

Base class for all objects that want to act as an input for the time-step simulation.

The calculated values for each time-step are stored in internal memory and can be accessed by get_results() (after the simulation is finished).

Note

Due to the underlying solver, this handle may get called with time arguments, that lie outside of the specified integration domain. This should not be a problem for a feedback controller but might cause problems for a feedforward or trajectory implementation.

class SwmBaseCanonicalFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

static scalar_product(left, right)
scalar_product_hint()

Scalar product for the canonical form of the string with mass system:

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmBaseFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

l2_scalar_product = True
static scalar_product(left, right)
scalar_product_hint()

Scalar product for the string with mass system:

\begin{align*}
  \langle x, y\rangle = \int_0^1 (x_1'(z)y_1'(z) + x_2(z)y_2(z) \,dz
  + x_3 y_3 + m x_4 y_4
\end{align*}

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmObserverError(control_law, smooth=None)

Bases: pyinduct.examples.string_with_mass.system.pi.StateFeedback

For a smooth fade-in of the observer error.

Parameters:
  • control_law (WeakFormulation) – Function handle that calculates the control output if provided with correct weights.

  • smooth (array-like) – Arguments for SmoothTransition

class SwmPgAnimatedPlot(data, title='', refresh_time=40, replay_gain=1, save_pics=False, create_video=False, labels=None)

Bases: pyinduct.visualization.PgDataPlot

Animation for the string with mass example. Compare with PgAnimatedPlot.

Parameters:
  • data ((iterable of) EvalData) – results to animate

  • title (basestring) – window title

  • refresh_time (int) – time in msec to refresh the window must be greater than zero

  • replay_gain (float) – values above 1 acc- and below 1 decelerate the playback process, must be greater than zero

  • save_pics (bool) –

  • labels

Return:

property exported_files
apply_control_mode(sys_fem_lbl, sys_modal_lbl, obs_fem_lbl, obs_modal_lbl, mode)
approximate_controller(sys_lbl, modal_lbl)
build_canonical_weak_formulation(obs_lbl, spatial_domain, u, obs_err, name='system')

Observer canonical form of the string with mass example

\begin{align*}
    \dot{x}_1(t) &= \frac{2}{m}u(t) \\
    \dot{x}_2(t) &= x_1(t) + \frac{2}{m}u(t) \\
    \dot{x}_3(z,t) &= -x_3'(z,t)-\frac{2}{m}(1-h(z))z u(t) - m^{-1} y(t)
\end{align*}

Boundary condition

x_3(-1,t) = x_2(t) - y(t)

Weak formulation

\begin{align*}
    -\langle \dot x(z, t), \psi(z)\rangle &=
    \frac{2}{m}u(t)\psi_1 + \frac{2}{m}u(t)\psi_2 + x_1\psi_2
    -x_3(1,t)\psi_3(1) - m^{-1}\langle y(t), \psi_3(z) \rangle \\
    &+ \underbrace{x_3(-1,t)\psi_3(-1)}_{x_2(t)\psi_3(-1) - y(t)\psi_3(-1)}
    + \langle x_3(z,t) , \psi_3'(z)\rangle
    + \frac{2}{m}\langle (1 - h(z))z , \psi_3(z)\rangle u(t)
\end{align*}

Output equation

x_3(1,t) =  y(t)

Parameters:
  • sys_approx_label (string) – Shapefunction label for system approximation.

  • obs_approx_label (string) – Shapefunction label for observer approximation.

  • input_vector (pyinduct.simulation.SimulationInputVector) – Holds the input variable.

  • params

    Python class with the members:

    • m (mass)

    • k1_ob, k2_ob, alpha_ob (observer parameters)

Returns:

Observer

Return type:

pyinduct.simulation.Observer

build_controller(sys_lbl, ctrl_lbl)

The control law from [Woi2012] (equation 29)

\begin{align*}
    u(t) = &-\frac{1-\alpha}{1+\alpha}x_2(1) +
    \frac{(1-mk_1)\bar{y}'(1) - \alpha(1+mk_1)\bar{y}'(-1)}{1+\alpha} \\
    \hphantom{=} &-\frac{mk_0}{1+\alpha}(\bar{y}(1) + \alpha\bar{y}(-1))
\end{align*}

is simply tipped off in this function, whereas

\begin{align*}
    \bar{y}(\theta) &=  \left\{\begin{array}{lll}
         \xi_1 + m(1-e^{-\theta/m})\xi_2 +
         \int_0^\theta (1-e^{-(\theta-\tau)/m}) (x_1'(\tau) + x_2(\tau)) \, dz
         & \forall & \theta\in[-1, 0) \\
         \xi_1 + m(e^{\theta/m}-1)\xi_2 +
         \int_0^\theta (e^{(\theta-\tau)/m}-1) (x_1'(-\tau) - x_2(-\tau)) \, dz
         & \forall & \theta\in[0, 1]
    \end{array}\right. \\
    \bar{y}'(\theta) &=  \left\{\begin{array}{lll}
         e^{-\theta/m}\xi_2 + \frac{1}{m}
         \int_0^\theta e^{-(\theta-\tau)/m} (x_1'(\tau) + x_2(\tau)) \, dz
         & \forall & \theta\in[-1, 0) \\
         e^{\theta/m}\xi_2 + \frac{1}{m}
         \int_0^\theta e^{(\theta-\tau)/m} (x_1'(-\tau) - x_2(-\tau)) \, dz
         & \forall & \theta\in[0, 1].
    \end{array}\right.
\end{align*}

Parameters:

approx_label (string) – Shapefunction label for approximation.

Returns:

Control law

Return type:

StateFeedback

build_fem_bases(base_lbl, n1, n2, cf_base_lbl, ncf, modal_base_lbl)
build_modal_bases(base_lbl, n, cf_base_lbl, ncf)
build_original_weak_formulation(sys_lbl, spatial_domain, u, name='system')

Projection (see SwmBaseFraction.scalar_product_hint()

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle &=
    \langle x_2(z,t),\psi_1(z)\rangle + \langle x_1''(z,t), \psi_2(z)\rangle +
    \xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Boundary conditions

\begin{align*}
    x_1(0,t) = \xi_1(t), \qquad u(t) = x_1'(1,t)
\end{align*}

Implemented

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle =
    &\langle x_2(z,t),\psi_1(z)\rangle + \langle x_1'(z,t), \psi_2'(z)\rangle \\
    &+ u(t)\psi_2(1) - x_1'(0,t)\psi_2(0)
    +\xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Parameters:
  • sys_lbl (str) – Base label

  • spatial_domain (Domain) – Spatial domain of the system.

  • name (str) – Name of the system.

Returns:

WeakFormulation

check_eigenvalues(sys_fem_lbl, obs_fem_lbl, obs_modal_lbl, ceq, ss)
ctrl_gain
find_eigenvalues(n)
flatness_based_controller(x2_plus1, y_bar_plus1, y_bar_minus1, dz_y_bar_plus1, dz_y_bar_minus1, name)
get_colors(cnt, scheme='tab10', samples=10)

Create a list of colors.

Parameters:
  • cnt (int) – Number of colors in the list.

  • scheme (str) – Mpl color scheme to use.

  • samples (cnt) – Number of samples to take from the scheme before starting from the beginning.

Returns:

List of np.Array holding the rgb values.

get_modal_base_for_ctrl_approximation()
get_primal_eigenvector(according_paper=False)
init_observer_gain(sys_fem_lbl, sys_modal_lbl, obs_fem_lbl, obs_modal_lbl)
integrate_function(func, interval)

Numerically integrate a function on a given interval using complex_quadrature().

Parameters:
  • func (callable) – Function to integrate.

  • interval (list of tuples) – List of (start, end) values of the intervals to integrate on.

Returns:

(Result of the Integration, errors that occurred during the integration).

Return type:

tuple

obs_gain
ocf_inverse_state_transform(org_state)

Transformation of the the state x(z,t) = (x(z,t), \dot x(z,t), x(0,t), \dot x(0,t))^T
= (x_1(z,t), x_2(z,t), \xi_1(t), \xi_2(t))^T into the coordinates of the observer canonical form

\begin{align*}
    \bar x_1(t) &= w_2'(1) \\
    \bar x_2(t) &= w_1'(1) + w_2'(1) \\
    \bar x_3(\theta, t) &= \frac{1}{2}(w_2(1-\theta) + w_1'(1-\theta)),
    \quad \forall \theta > 0 \\
    \bar x_3(\theta, t) &= \frac{1}{2}(w_2(1+\theta) - w_1'(1+\theta)) +
    w_1'(1) - \theta w_2'(1),
    \quad \forall \theta \le 0 \\
    w_i(z) &= 2\int_0^z \left( \xi_i + \frac{1}{m}\int_0^\zeta
    x_i(\bar\zeta) \,d\bar\zeta \right) \,d\zeta,\quad i=1,2.
\end{align*}

Parameters:

org_state (SwmBaseFraction) – State

Returns:

Transformation

Return type:

SwmBaseCanonicalFraction

param
plot_eigenvalues(eigenvalues, return_figure=False)
pprint(expression='\n\n\n')
register_evp_base(base_lbl, eigenvectors, sp_var, domain)
run(show_plots)
scale_equation_term_list(eqt_list, factor)

Temporary function, as long EquationTerm can only be scaled individually.

Parameters:
  • eqt_list (list) – List of EquationTerm’s

  • factor (numbers.Number) – Scale factor.

Returns:

Scaled copy of EquationTerm’s (eqt_list).

sort_eigenvalues(eigenvalues)
subs_list = [()]
sym

Weak formulations and definition of the bases

class Parameters
class PgDataPlot(data)

Bases: DataPlot, pyqtgraph.QtCore.QObject

Base class for all pyqtgraph plotting related classes.

class SwmBaseCanonicalFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

static scalar_product(left, right)
scalar_product_hint()

Scalar product for the canonical form of the string with mass system:

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmBaseFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

l2_scalar_product = True
static scalar_product(left, right)
scalar_product_hint()

Scalar product for the string with mass system:

\begin{align*}
  \langle x, y\rangle = \int_0^1 (x_1'(z)y_1'(z) + x_2(z)y_2(z) \,dz
  + x_3 y_3 + m x_4 y_4
\end{align*}

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmPgAnimatedPlot(data, title='', refresh_time=40, replay_gain=1, save_pics=False, create_video=False, labels=None)

Bases: pyinduct.visualization.PgDataPlot

Animation for the string with mass example. Compare with PgAnimatedPlot.

Parameters:
  • data ((iterable of) EvalData) – results to animate

  • title (basestring) – window title

  • refresh_time (int) – time in msec to refresh the window must be greater than zero

  • replay_gain (float) – values above 1 acc- and below 1 decelerate the playback process, must be greater than zero

  • save_pics (bool) –

  • labels

Return:

property exported_files
build_canonical_weak_formulation(obs_lbl, spatial_domain, u, obs_err, name='system')

Observer canonical form of the string with mass example

\begin{align*}
    \dot{x}_1(t) &= \frac{2}{m}u(t) \\
    \dot{x}_2(t) &= x_1(t) + \frac{2}{m}u(t) \\
    \dot{x}_3(z,t) &= -x_3'(z,t)-\frac{2}{m}(1-h(z))z u(t) - m^{-1} y(t)
\end{align*}

Boundary condition

x_3(-1,t) = x_2(t) - y(t)

Weak formulation

\begin{align*}
    -\langle \dot x(z, t), \psi(z)\rangle &=
    \frac{2}{m}u(t)\psi_1 + \frac{2}{m}u(t)\psi_2 + x_1\psi_2
    -x_3(1,t)\psi_3(1) - m^{-1}\langle y(t), \psi_3(z) \rangle \\
    &+ \underbrace{x_3(-1,t)\psi_3(-1)}_{x_2(t)\psi_3(-1) - y(t)\psi_3(-1)}
    + \langle x_3(z,t) , \psi_3'(z)\rangle
    + \frac{2}{m}\langle (1 - h(z))z , \psi_3(z)\rangle u(t)
\end{align*}

Output equation

x_3(1,t) =  y(t)

Parameters:
  • sys_approx_label (string) – Shapefunction label for system approximation.

  • obs_approx_label (string) – Shapefunction label for observer approximation.

  • input_vector (pyinduct.simulation.SimulationInputVector) – Holds the input variable.

  • params

    Python class with the members:

    • m (mass)

    • k1_ob, k2_ob, alpha_ob (observer parameters)

Returns:

Observer

Return type:

pyinduct.simulation.Observer

build_fem_bases(base_lbl, n1, n2, cf_base_lbl, ncf, modal_base_lbl)
build_modal_bases(base_lbl, n, cf_base_lbl, ncf)
build_original_weak_formulation(sys_lbl, spatial_domain, u, name='system')

Projection (see SwmBaseFraction.scalar_product_hint()

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle &=
    \langle x_2(z,t),\psi_1(z)\rangle + \langle x_1''(z,t), \psi_2(z)\rangle +
    \xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Boundary conditions

\begin{align*}
    x_1(0,t) = \xi_1(t), \qquad u(t) = x_1'(1,t)
\end{align*}

Implemented

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle =
    &\langle x_2(z,t),\psi_1(z)\rangle + \langle x_1'(z,t), \psi_2'(z)\rangle \\
    &+ u(t)\psi_2(1) - x_1'(0,t)\psi_2(0)
    +\xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Parameters:
  • sys_lbl (str) – Base label

  • spatial_domain (Domain) – Spatial domain of the system.

  • name (str) – Name of the system.

Returns:

WeakFormulation

check_eigenvalues(sys_fem_lbl, obs_fem_lbl, obs_modal_lbl, ceq, ss)
ctrl_gain
find_eigenvalues(n)
get_colors(cnt, scheme='tab10', samples=10)

Create a list of colors.

Parameters:
  • cnt (int) – Number of colors in the list.

  • scheme (str) – Mpl color scheme to use.

  • samples (cnt) – Number of samples to take from the scheme before starting from the beginning.

Returns:

List of np.Array holding the rgb values.

get_modal_base_for_ctrl_approximation()
get_primal_eigenvector(according_paper=False)
integrate_function(func, interval)

Numerically integrate a function on a given interval using complex_quadrature().

Parameters:
  • func (callable) – Function to integrate.

  • interval (list of tuples) – List of (start, end) values of the intervals to integrate on.

Returns:

(Result of the Integration, errors that occurred during the integration).

Return type:

tuple

obs_gain
param
plot_eigenvalues(eigenvalues, return_figure=False)
pprint(expression='\n\n\n')
register_evp_base(base_lbl, eigenvectors, sp_var, domain)
sort_eigenvalues(eigenvalues)
subs_list = [()]
sym

State feedback control

class Parameters
class PgDataPlot(data)

Bases: DataPlot, pyqtgraph.QtCore.QObject

Base class for all pyqtgraph plotting related classes.

class SecondOrderFeedForward(desired_handle)

Bases: pyinduct.examples.string_with_mass.system.pi.SimulationInput

Base class for all objects that want to act as an input for the time-step simulation.

The calculated values for each time-step are stored in internal memory and can be accessed by get_results() (after the simulation is finished).

Note

Due to the underlying solver, this handle may get called with time arguments, that lie outside of the specified integration domain. This should not be a problem for a feedback controller but might cause problems for a feedforward or trajectory implementation.

class SwmBaseCanonicalFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

static scalar_product(left, right)
scalar_product_hint()

Scalar product for the canonical form of the string with mass system:

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmBaseFraction(functions, scalars)

Bases: pyinduct.ComposedFunctionVector

Implementation of composite function vector \boldsymbol{x}.

\boldsymbol{x} = \begin{pmatrix}
    x_1(z) \\
    \vdots \\
    x_n(z) \\
    \xi_1 \\
    \vdots \\
    \xi_m \\
\end{pmatrix}

derive(order)

Basic implementation of derive function.

Empty implementation, overwrite to use this functionality. For an example implementation see Function

Parameters:

order (numbers.Number) – derivative order

Returns:

derived object

Return type:

BaseFraction

evaluation_hint(values)

If evaluation can be accelerated by using special properties of a function, this function can be overwritten to performs that computation. It gets passed an array of places where the caller wants to evaluate the function and should return an array of the same length, containing the results.

Note

This implementation just calls the normal evaluation hook.

Parameters:

values – places to be evaluated at

Returns:

Evaluation results.

Return type:

numpy.ndarray

get_member(idx)

Getter function to access members. Empty function, overwrite to implement custom functionality. For an example implementation see Function

Note

Empty function, overwrite to implement custom functionality.

Parameters:

idx – member index

l2_scalar_product = True
static scalar_product(left, right)
scalar_product_hint()

Scalar product for the string with mass system:

\begin{align*}
  \langle x, y\rangle = \int_0^1 (x_1'(z)y_1'(z) + x_2(z)y_2(z) \,dz
  + x_3 y_3 + m x_4 y_4
\end{align*}

Returns:

Scalar product function handle wrapped inside a list.

Return type:

list(callable)

class SwmObserverError(control_law, smooth=None)

Bases: pyinduct.examples.string_with_mass.system.pi.StateFeedback

For a smooth fade-in of the observer error.

Parameters:
  • control_law (WeakFormulation) – Function handle that calculates the control output if provided with correct weights.

  • smooth (array-like) – Arguments for SmoothTransition

class SwmPgAnimatedPlot(data, title='', refresh_time=40, replay_gain=1, save_pics=False, create_video=False, labels=None)

Bases: pyinduct.visualization.PgDataPlot

Animation for the string with mass example. Compare with PgAnimatedPlot.

Parameters:
  • data ((iterable of) EvalData) – results to animate

  • title (basestring) – window title

  • refresh_time (int) – time in msec to refresh the window must be greater than zero

  • replay_gain (float) – values above 1 acc- and below 1 decelerate the playback process, must be greater than zero

  • save_pics (bool) –

  • labels

Return:

property exported_files
apply_control_mode(sys_fem_lbl, sys_modal_lbl, obs_fem_lbl, obs_modal_lbl, mode)
approximate_controller(sys_lbl, modal_lbl)
build_canonical_weak_formulation(obs_lbl, spatial_domain, u, obs_err, name='system')

Observer canonical form of the string with mass example

\begin{align*}
    \dot{x}_1(t) &= \frac{2}{m}u(t) \\
    \dot{x}_2(t) &= x_1(t) + \frac{2}{m}u(t) \\
    \dot{x}_3(z,t) &= -x_3'(z,t)-\frac{2}{m}(1-h(z))z u(t) - m^{-1} y(t)
\end{align*}

Boundary condition

x_3(-1,t) = x_2(t) - y(t)

Weak formulation

\begin{align*}
    -\langle \dot x(z, t), \psi(z)\rangle &=
    \frac{2}{m}u(t)\psi_1 + \frac{2}{m}u(t)\psi_2 + x_1\psi_2
    -x_3(1,t)\psi_3(1) - m^{-1}\langle y(t), \psi_3(z) \rangle \\
    &+ \underbrace{x_3(-1,t)\psi_3(-1)}_{x_2(t)\psi_3(-1) - y(t)\psi_3(-1)}
    + \langle x_3(z,t) , \psi_3'(z)\rangle
    + \frac{2}{m}\langle (1 - h(z))z , \psi_3(z)\rangle u(t)
\end{align*}

Output equation

x_3(1,t) =  y(t)

Parameters:
  • sys_approx_label (string) – Shapefunction label for system approximation.

  • obs_approx_label (string) – Shapefunction label for observer approximation.

  • input_vector (pyinduct.simulation.SimulationInputVector) – Holds the input variable.

  • params

    Python class with the members:

    • m (mass)

    • k1_ob, k2_ob, alpha_ob (observer parameters)

Returns:

Observer

Return type:

pyinduct.simulation.Observer

build_controller(sys_lbl, ctrl_lbl)

The control law from [Woi2012] (equation 29)

\begin{align*}
    u(t) = &-\frac{1-\alpha}{1+\alpha}x_2(1) +
    \frac{(1-mk_1)\bar{y}'(1) - \alpha(1+mk_1)\bar{y}'(-1)}{1+\alpha} \\
    \hphantom{=} &-\frac{mk_0}{1+\alpha}(\bar{y}(1) + \alpha\bar{y}(-1))
\end{align*}

is simply tipped off in this function, whereas

\begin{align*}
    \bar{y}(\theta) &=  \left\{\begin{array}{lll}
         \xi_1 + m(1-e^{-\theta/m})\xi_2 +
         \int_0^\theta (1-e^{-(\theta-\tau)/m}) (x_1'(\tau) + x_2(\tau)) \, dz
         & \forall & \theta\in[-1, 0) \\
         \xi_1 + m(e^{\theta/m}-1)\xi_2 +
         \int_0^\theta (e^{(\theta-\tau)/m}-1) (x_1'(-\tau) - x_2(-\tau)) \, dz
         & \forall & \theta\in[0, 1]
    \end{array}\right. \\
    \bar{y}'(\theta) &=  \left\{\begin{array}{lll}
         e^{-\theta/m}\xi_2 + \frac{1}{m}
         \int_0^\theta e^{-(\theta-\tau)/m} (x_1'(\tau) + x_2(\tau)) \, dz
         & \forall & \theta\in[-1, 0) \\
         e^{\theta/m}\xi_2 + \frac{1}{m}
         \int_0^\theta e^{(\theta-\tau)/m} (x_1'(-\tau) - x_2(-\tau)) \, dz
         & \forall & \theta\in[0, 1].
    \end{array}\right.
\end{align*}

Parameters:

approx_label (string) – Shapefunction label for approximation.

Returns:

Control law

Return type:

StateFeedback

build_fem_bases(base_lbl, n1, n2, cf_base_lbl, ncf, modal_base_lbl)
build_modal_bases(base_lbl, n, cf_base_lbl, ncf)
build_original_weak_formulation(sys_lbl, spatial_domain, u, name='system')

Projection (see SwmBaseFraction.scalar_product_hint()

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle &=
    \langle x_2(z,t),\psi_1(z)\rangle + \langle x_1''(z,t), \psi_2(z)\rangle +
    \xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Boundary conditions

\begin{align*}
    x_1(0,t) = \xi_1(t), \qquad u(t) = x_1'(1,t)
\end{align*}

Implemented

\begin{align*}
    \langle\dot x(z,t), \psi(z)\rangle =
    &\langle x_2(z,t),\psi_1(z)\rangle + \langle x_1'(z,t), \psi_2'(z)\rangle \\
    &+ u(t)\psi_2(1) - x_1'(0,t)\psi_2(0)
    +\xi_2(t)\psi_3 + x_1'(0)\psi_4
\end{align*}

Parameters:
  • sys_lbl (str) – Base label

  • spatial_domain (Domain) – Spatial domain of the system.

  • name (str) – Name of the system.

Returns:

WeakFormulation

check_eigenvalues(sys_fem_lbl, obs_fem_lbl, obs_modal_lbl, ceq, ss)
ctrl_gain
find_eigenvalues(n)
flatness_based_controller(x2_plus1, y_bar_plus1, y_bar_minus1, dz_y_bar_plus1, dz_y_bar_minus1, name)
get_colors(cnt, scheme='tab10', samples=10)

Create a list of colors.

Parameters:
  • cnt (int) – Number of colors in the list.

  • scheme (str) – Mpl color scheme to use.

  • samples (cnt) – Number of samples to take from the scheme before starting from the beginning.

Returns:

List of np.Array holding the rgb values.

get_modal_base_for_ctrl_approximation()
get_primal_eigenvector(according_paper=False)
init_observer_gain(sys_fem_lbl, sys_modal_lbl, obs_fem_lbl, obs_modal_lbl)
integrate_function(func, interval)

Numerically integrate a function on a given interval using complex_quadrature().

Parameters:
  • func (callable) – Function to integrate.

  • interval (list of tuples) – List of (start, end) values of the intervals to integrate on.

Returns:

(Result of the Integration, errors that occurred during the integration).

Return type:

tuple

obs_gain
ocf_inverse_state_transform(org_state)

Transformation of the the state x(z,t) = (x(z,t), \dot x(z,t), x(0,t), \dot x(0,t))^T
= (x_1(z,t), x_2(z,t), \xi_1(t), \xi_2(t))^T into the coordinates of the observer canonical form

\begin{align*}
    \bar x_1(t) &= w_2'(1) \\
    \bar x_2(t) &= w_1'(1) + w_2'(1) \\
    \bar x_3(\theta, t) &= \frac{1}{2}(w_2(1-\theta) + w_1'(1-\theta)),
    \quad \forall \theta > 0 \\
    \bar x_3(\theta, t) &= \frac{1}{2}(w_2(1+\theta) - w_1'(1+\theta)) +
    w_1'(1) - \theta w_2'(1),
    \quad \forall \theta \le 0 \\
    w_i(z) &= 2\int_0^z \left( \xi_i + \frac{1}{m}\int_0^\zeta
    x_i(\bar\zeta) \,d\bar\zeta \right) \,d\zeta,\quad i=1,2.
\end{align*}

Parameters:

org_state (SwmBaseFraction) – State

Returns:

Transformation

Return type:

SwmBaseCanonicalFraction

param
plot_eigenvalues(eigenvalues, return_figure=False)
pprint(expression='\n\n\n')
register_evp_base(base_lbl, eigenvectors, sp_var, domain)
scale_equation_term_list(eqt_list, factor)

Temporary function, as long EquationTerm can only be scaled individually.

Parameters:
  • eqt_list (list) – List of EquationTerm’s

  • factor (numbers.Number) – Scale factor.

Returns:

Scaled copy of EquationTerm’s (eqt_list).

sort_eigenvalues(eigenvalues)
subs_list = [()]
sym