Muscat.Containers.SymExpr module

CheckIntegrity(GUI: bool = False)[source]
CreateSymExprWithPos(ops: Dict) SymExprWithPos[source]

Simple wrapper to create a SymExprWithPos from a dict. [“val”] is used to extract the expression to be used for the construction of the SymExprWithPos

Parameters:

ops (Dict) – _description_

Returns:

the Symbolic expression dependent of the position

Return type:

SymExprWithPos

class SymExprBase(string: str | None = None, symbols=None, derivatives: bool = True)[source]

Bases: object

Store read from string and store a symbolic expression. the expression read using sympy. the first and the second derivative are automatically computed.

GetValue() number[source]

Return the evaluated expression

Returns:

the evaluated expression

Return type:

np.number

GetValueDerivative(symbol: str) number[source]

Return the first derivative of the expression with respect to symbol

Parameters:
  • symbol (str) – the name of the variable to be used by the derivative

  • pos (_type_, optional) – Not Used, by default None

Returns:

the evaluation of the derivative of the expression with respect to symbol.

Return type:

np.number

GetValueSecondDerivative(symbol1: str, symbol2: str) number[source]

Return the second derivative of the expression with respect to symbol1 and symbol2

Parameters:
  • symbol1 (str) – the name of the variable to be used by the derivative

  • symbol2 (str) – the name of the variable to be used by the derivative

  • pos (_type_, optional) – Not Used, by default None

Returns:

the evaluation of the derivative of the expression with respect to symbol1 and symbol2. d2/(dSymbol1 * dSymbol2) * expr

Return type:

np.number

SetConstant(name: str, value: number) None[source]

Add/Set the value of the free variables of the expression

Parameters:
  • name (str) – name of the variable

  • value (np.number) – value

SetExpression(string: str, symbols: List[str] | None = None) None[source]
Set the expression to be used. A list of symbols (list[str]) can be provided

to determine the free variable of the expression. if no symbols are provided the symbol ‘t’ (for time) with value 0.0 is defined by default.

Parameters:
  • string (str) – the string representation of the expression to be parsed by sympy

  • symbols (list[str], optional) – List of symbol to be used to parse the expression, by default None

constants

Constants used to evaluate the expression. (free variables).

class SymExprWithPos(string: str | None = None, symbols=None, derivatives: bool = True)[source]

Bases: SymExprBase

Store read from string and store a symbolic expression depending implicitly on (x,y,z). the expression read using sympy. the first and the second derivative are automatically computed.

GetValue(pos: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[source]

Return the evaluated expression

Returns:

the evaluated expression

Return type:

np.number

GetValueDerivative(symbol: str, pos: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[source]

Return the first derivative of the expression with respect to symbol

Parameters:
  • symbol (str) – the name of the variable to be used by the derivative

  • pos (_type_, optional) – Not Used, by default None

Returns:

the evaluation of the derivative of the expression with respect to symbol.

Return type:

np.number

GetValueSecondDerivative(symbol1: str, symbol2: str, pos: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) ndarray[source]

Return the second derivative of the expression with respect to symbol1 and symbol2

Parameters:
  • symbol1 (str) – the name of the variable to be used by the derivative

  • symbol2 (str) – the name of the variable to be used by the derivative

  • pos (_type_, optional) – Not Used, by default None

Returns:

the evaluation of the derivative of the expression with respect to symbol1 and symbol2. d2/(dSymbol1 * dSymbol2) * expr

Return type:

np.number

SetExpression(string: str) None[source]
Set the expression to be used. A list of symbols (list[str]) can be provided

to determine the free variable of the expression. if no symbols are provided the symbol ‘t’ (for time) with value 0.0 is defined by default.

Parameters:
  • string (str) – the string representation of the expression to be parsed by sympy

  • symbols (list[str], optional) – List of symbol to be used to parse the expression, by default None