BasicTools.Containers.SymExpr module
- BasicTools.Containers.SymExpr.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 contruction of the SymExprWithPos
- Parameters:
ops (Dict) – _description_
- Returns:
the Symbolic expression dependent of the position
- Return type:
- class BasicTools.Containers.SymExpr.SymExprBase(string=None, symbols=None)[source]
Bases:
BaseOutputObjectStore read from string and store a symbolic expression. the expression read using sympy. the first and the second derivative are automatically computed.
- GetValue(pos=None) number[source]
Return the evaluated expression
- Parameters:
pos (_type_, optional) – Not Used, by default None
- Returns:
the evaluated expression
- Return type:
np.number
- GetValueDerivative(coor: str, pos=None) number[source]
Return the first derivative of the expression with respect to coor
- Parameters:
coor (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 coor.
- Return type:
np.number
- GetValueSecondDerivative(coor1: str, coor2: str, pos=None) number[source]
Return the second derivative of the expression with respect to coor1 and coor2
- Parameters:
coor1 (str) – the name of the variable to be used by the derivative
coor2 (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 coor1 and coord2. d/dcoord1 * d/dcoord2 * expr
- Return type:
np.number
- SetConstant(name: str, value: number)[source]
Add/Set the value of the free variable of the expression
- Parameters:
name (str) – name of the variable
value (np.number) – value
- SetExpression(string: str, _symbols: List[str] | 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 BasicTools.Containers.SymExpr.SymExprWithPos(string=None, symbols=None)[source]
Bases:
SymExprBaseStore 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)[source]
Return the evaluated expression
- Parameters:
pos (_type_, optional) – Not Used, by default None
- Returns:
the evaluated expression
- Return type:
np.number
- GetValueDerivative(coor, pos)[source]
Return the first derivative of the expression with respect to coor
- Parameters:
coor (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 coor.
- Return type:
np.number
- GetValueSecondDerivative(coor1, coor2, pos)[source]
Return the second derivative of the expression with respect to coor1 and coor2
- Parameters:
coor1 (str) – the name of the variable to be used by the derivative
coor2 (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 coor1 and coord2. d/dcoord1 * d/dcoord2 * expr
- Return type:
np.number
- SetExpression(string)[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