Feedback¶
This module contains all classes and functions related to the approximation of distributed feedback as well as their implementation for simulation purposes.
- class Feedback(feedback_law, **parse_kwargs)[source]¶
Bases:
pyinduct.simulation.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 ObserverFeedback(observer_law, output_error)[source]¶
Bases:
Feedback
Wrapper class for all observer gains that have to interact with the simulation environment.
Note
For observer gains (
observer_gain
) which are constructed from different test function bases, dont forget to specify these bases when initialization theTestFunction
by using the keyword argumentapprox_lbl
.- Parameters:
observer_law (
WeakFormulation
) – Variational formulation of the Observer gain. (Projected on a set of test functions.)output_error (
StateFeedback
) – Output error
- class SimulationInput(name='')[source]¶
Bases:
object
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.
- clear_cache()[source]¶
Clear the internal value storage.
When the same SimulationInput is used to perform various simulations, there is no possibility to distinguish between the different runs when
get_results()
gets called. Therefore this method can be used to clear the cache.
- get_results(time_steps, result_key='output', interpolation='nearest', as_eval_data=False)[source]¶
Return results from internal storage for given time steps.
- Raises:
Error – If calling this method before a simulation was run.
- Parameters:
time_steps – Time points where values are demanded.
result_key – Type of values to be returned.
interpolation – Interpolation method to use if demanded time-steps are not covered by the storage, see
scipy.interpolate.interp1d()
for all possibilities.as_eval_data (bool) – Return results as
EvalData
object for straightforward display.
- Returns:
Corresponding function values to the given time steps.
- class StateFeedback(control_law)[source]¶
Bases:
Feedback
Base class for all feedback controllers that have to interact with the simulation environment.
- Parameters:
control_law (
WeakFormulation
) – Variational formulation of the control law.
- calculate_scalar_product_matrix(base_a, base_b, scalar_product=None, optimize=True)[source]¶
Calculates a matrix , whose elements are the scalar products of each element from base_a and base_b, so that .
- Parameters:
base_a (
ApproximationBase
) – Basis abase_b (
ApproximationBase
) – Basis bscalar_product – (List of) function objects that are passed the members of the given bases as pairs. Defaults to the scalar product given by base_a
optimize (bool) – Switch to turn on the symmetry based speed up. For development purposes only.
- Returns:
matrix
- Return type:
numpy.ndarray
- evaluate_transformations(ce, weight_label, vect_shape, is_observer=False)[source]¶
Transform the different feedback/observer gains in
ce
to the basisweight_label
and accumulate them to one gain vector.If the feedback gain was approximated with respect to the weights from the state the weight transformations the procedure is straight forward. However, in most of the time, during the simulation only the weights of some base are available. Therefore, a weight transformation
to this basis will be computed.
The transformation of a approximated observer gain is a little bit more involved. Since, if one wants to know the transformation from the gain vector to the approximation with respect to another test base one has an additional degree of freedom with the ansatz .
In the most cases there is a natural choice for and , such that the the transformation to the desired projections can be acquired with little computational effort. However, for now these more elegant techniques are not covered in this method.
Here only one method is implemented:
Finally the transformation between the weights and will be computed with
get_weight_transformation
.For more advanced approximation and transformation features, take a look at upcoming tools in the symbolic simulation branch of pyinduct (comment from 2019/06/27).
Warning
Since neither
CanonicalEquation
norStateSpace
know the target test base , which was used in theWeakFormulation
, at the moment, the observer gain transformation works only if the state approximation base and the test base coincides. Which holds for example, for standard fem approximations methods and modal approximations of self adjoint operators.- Parameters:
ce (
CanonicalEquation
) – Feedback/observer gain.weight_label (string) – Label of functions the weights correspond to.
vect_shape (tuple) – Shape of the feedback vector.
is_observer (bool) – The argument ce is interpreted as feedback/observer if observer is False/True. Default: False
- Returns:
Accumulated feedback/observer gain.
- Return type:
numpy.array
- get_base(label)[source]¶
Retrieve registered set of initial functions by their label.
- Parameters:
label (str) – String, label of functions to retrieve.
- Returns:
initial_functions
- get_transformation_info(source_label, destination_label, source_order=0, destination_order=0)[source]¶
Provide the weights transformation from one/source base to another/destination base.
- Parameters:
source_label (str) – Label from the source base.
destination_label (str) – Label from the destination base.
source_order – Order from the available time derivative of the source weights.
destination_order – Order from the desired time derivative of the destination weights.
- Returns:
Transformation info object.
- Return type:
- get_weight_transformation(info)[source]¶
Create a handle that will transform weights from info.src_base into weights for info-dst_base while paying respect to the given derivative orders.
This is accomplished by recursively iterating through source and destination bases and evaluating their
transformation_hints
.- Parameters:
info (
TransformationInfo
) – information about the requested transformation.- Returns:
transformation function handle
- Return type:
callable
- parse_weak_formulation(weak_form, finalize=False, is_observer=False)[source]¶
Parses a
WeakFormulation
that has been derived by projecting a partial differential equation an a set of test-functions. Within this process, the separating approximation is plugged into the equation and the separated spatial terms are evaluated, leading to a ordinary equation system for the weights .- Parameters:
weak_form – Weak formulation of the pde.
finalize (bool) – Default: False. If you have already defined the dominant labels of the weak formulations you can set this to True. See
CanonicalEquation.finalize()
- Returns:
The spatially approximated equation in a canonical form.
- Return type: