Class CeSolver#

Class Documentation#

class CeSolver#
Constrained expression solver.

This class solves constrained expressions for you.

Parameters
----------
C : ConstraintOperators
    This is a tuple or list constraint operators. Each element in the
    iterable should be a Python function that takes in a sympy function,
    such as `g(x)`, and outputs that function evaluated in the same way
    as the function in the constraint. For example, if the constraint was
    u(3) = 0, then the assocaited constraint operator would be:
    `lambda u: = u.subs(x,3)`.
kappa : Exprs
    This is a tuple or list of the kappa portion of each constraint. For the
    example u(3) = 0, the kappa portion is simply 0. Note, the standard
    Python 0 should not be used, but rather, sympy.re(0).
s : Exprs
    This is a tuple or list of the support functions. These should be given
    in terms of sympy symbols and constants. For example, if we wanted to
    use the constant function x = 1 as a support function, then we would
    use sympy.re(1) in this iterable.
g : AppliedUndef| Any
    This is the free function used in the constrained expression. For example,
    `g(x)`.

References
----------
The algorithm used here is given at 26:13 of this video: https://www.youtube.com/watch?v=uisOZVBHA2U&t=1573s

Examples
--------
Consider the constraints `u(0) = 2` and `u_x(2) = 1` where `u_x` is the derivative of `u(x)` with respect to `x`.
Moreover, suppose we want to use `g(x)` as the free function.

import sympy as sp
from tfc.utils import CeSolver

x = sp.Symbol("x")
y = sp.Symbol("y")
u = sp.Function("u")
g = sp.Function("g")

C = [lambda u: u.subs(x,0), lambda u: sp.diff(u,x).subs(x,2)]
K = [sp.re(2), sp.re(1)]
s = [sp.re(1), x]

cs = CeSolver(C,K,s, g(x))
ce = cs.ce

In the above code example, `ce` is the constrained expression that satisfies these constraints.

Public Functions

__init__(self, ConstraintOperators C, Exprs kappa, Exprs s, AppliedUndef|Any g)#
print_type(self)#
print_type(self, Literal["tfc", "pretty", "latex", "str"] print_type)#
ce(self)#
Constrained expression.

Returns
-------
Any
    Constrained expression.
ce(self, Any ce)#
Sets the constrained expression to the user-supplied value.

Parameters
----------
ce: Any
    Sympy representation of the constrained expression.
phi(self)#
Switching functions.

Returns
-------
Any
    Switching functions.
phi(self, Any phi)#
Set the switching functions.

Parameters
----------
phi : Any
    The switching functions.
alpha(self)#
Alpha matrix (inverse of the support matrix)

Returns
sp.Matrix
    alpha matrix. The elements are on the field over which
    the constrained expression is defined.
S(self)#
Support matrix.

Returns
sp.Matrix
    Support matrix. The elements are on the field over which
    the constrained expression is defined.
rho(self)#
Projection functionals.

Returns
-------
Any
    Projection functionals.
s(self)#
Switching functions.

Returns
-------
Exprs
    Support functions.
s(self, Exprs s)#
Set the support functions.

Parameters
----------
s : Exprs
    This is a tuple or list of the support functions. These should be given
    in terms of sympy symbols and constants. For example, if we wanted to
    use the constant function x = 1 as a support function, then we would
    use sympy.re(1) in this iterable.
kappa(self)#
Kappa values.

Returns
-------
Exprs
    Kappa values.
kappa(self, Exprs kappa)#
Set the kappa values.

Parameters
-------
kappa : Exprs
    This is a tuple or list of the kappa portion of each constraint. For the
    example u(3) = 0, the kappa portion is simply 0. Note, the standard
    Python 0 should not be used, but rather, sympy.re(0).
C(self)#
Constraint operators.

Returns
-------
ConstraintOperators
    Constraint operators.
C(self, ConstraintOperators C)#
Parameters
----------
C : ConstraintOperators
    This is a tuple or list constraint operators. Each element in the
    iterable should be a Python function that takes in a sympy function,
    such as `g(x)`, and outputs that function evaluated in the same way
    as the function in the constraint. For example, if the constraint was
    u(3) = 0, then the assocaited constraint operator would be:
    `lambda u: = u.subs(x,3)`.
g(self)#
Free function.

Returns
-------
AppliedUndef | Any
    Free function.
g(self, AppliedUndef|Any g)#
Set the free function.

Parameters
----------
g : AppliedUndef | Any
    This is the free function used in the constrained expression. For example,
    `g(x)`.
checkCe(self)#
Checks the constrained expression stored in the class against the stored constraints.

Return
------
bool:
    Returns True if the constraint expression satisfies the constraints and false otherwise.

Protected Functions

_solveCe(self)#
Solves the constrained expression and stores it in self.ce

Protected Attributes

_C#
_K#
_s#
_g#
_print_type#
_ce_stale#
_ce#
_phi#
_phi_stale#
_alpha#
_alpha_stale#
_S#
_S_stale#
_rho#
_rho_stale#