Muscat.FE.SymWeakForm module¶
- ArrayToMatrix(array, normalize=False) MutableDenseMatrix[source]¶
Convert a list of object into a sympy.Matrix (1D). str objects are converted into a symbols. If normalize is True, the array is rescaled by its L2-norm, if all values are numerical; a warning is issued otherwise.
- Parameters:
array (arraylike) – a list of objects
normalize (bool, optional) – if true and all the values in the array are numerical then the vector is rescaled (norm(array) ==1), by default False
- Returns:
a sympy matrix with str converted to symbols
- Return type:
Matrix
- Cross(a, b)[source]¶
Compute the cross product of two 3D vector fields.
- Parameters:
a (sympy.Matrix) – Vector field of shape
(n, 1).b (sympy.Matrix) – Vector field of shape
(n, 1).
- Returns:
Vector field of shape
(n, 1).- Return type:
sympy.Matrix
- Diag(arg)[source]¶
Create a diagonal matrix from symbolic weak forms.
- Parameters:
arg (array-like) – Iterable of shape
(n,)containing weak forms as SymPy expressions.- Returns:
Diagonal matrix of shape
(n, n).- Return type:
sympy.Matrix or numpy.ndarray
- Divergence(arg, sdim=3)[source]¶
Compute the divergence of a vector or matrix field.
- Parameters:
arg (sympy.Matrix) – Matrix of shape
(n, 1)or(n, n)withnequal to2or3.sdim (int, optional) – Dimension of the divergence, either
2or3.
- Returns:
Expression if
argis a vector, or a matrix of shape(n, 1)ifargis a matrix field.- Return type:
sympy.Expr or sympy.Matrix
- GetConstant(name, size=1) Symbol | MutableDenseMatrix[source]¶
Create a scalar or vector constant symbolic field.
- Parameters:
name (str) – Label of the constant field.
size (int, optional) – Number of components. If
1, a scalar symbol is returned.
- Returns:
Scalar symbol when
size == 1; otherwise a column matrix of symbols.- Return type:
sympy.Symbol or sympy.Matrix
- GetCoordinate(size: int64)[source]¶
Function to get the coordinate of the current point. The Coordinate symbol will be populated with the proper value when processed by the integrator
- Parameters:
size (MuscatIndex) – size: MuscatIndex, dimension of the space. Usually taken equal to the problem dimension
- Returns:
sympy.Matrix of shape (size,1) with the special denomination “Coordinate”
- Return type:
sympy.Matrix
- GetElementDeterminant()[source]¶
Function to get the determinant of the element jacobian. The ELEMENT_DETERMINANT symbol will be populated with the proper value when processed by the integrator :rtype: sympy.Symbol with the special denomination “ELEMENT_DETERMINANT”
- GetField(name: str, size: int64, sdim: int64, star=False, extraCoordinates=[]) MutableDenseMatrix[source]¶
Instantiate a scalar, vector or tensor symbolic field.
- Parameters:
name (str) – Label of the field. If
size > 1, each component receives a suffix for the coordinate.size (MuscatIndex or tuple of MuscatIndex) – Dimension of the field. Use
1for a scalar,2for 2D and3for 3D. If a tuple is given, a tensor field is created.sdim (MuscatIndex) – Space dimension where the field evolves.
star (bool, optional) – Whether the field is a test field.
extraCoordinates (list[str], optional) – Extra field parameters, such as time.
- Returns:
Matrix containing functions of the spatial coordinates and any extra coordinates.
- Return type:
sympy.Matrix
- GetNormal(size: int64)[source]¶
Return the element normal symbolic field.
The Normal symbol is populated with the proper value when processed by the integrator.
- Parameters:
size (MuscatIndex) – Dimension of the normal. Usually equal to the problem dimension.
- Returns:
Matrix of shape
(size, 1)with the special denomination"Normal".- Return type:
sympy.Matrix
- GetScalarField(alpha)[source]¶
Create a constant scalar field from multiple input types.
- Parameters:
alpha (object) – Input value used to create the scalar field.
- Returns:
sympy.Symbolifalphais a string,floatifalphais an integer or float,1.0ifalphaisNone, otherwisealpha.- Return type:
sympy.Symbol or float or object
- GetTestField(name: str, size: int64, sdim: int64, extraCoordinates=[]) MutableDenseMatrix[source]¶
Instantiate a test field.
This is a convenience wrapper around
GetFieldwithstar=True.- Parameters:
name (str) – Label of the field. If
size > 1, each component receives a suffix for the coordinate and the test character.size (MuscatIndex or tuple of MuscatIndex) – Dimension of the field. Use
1for a scalar,2for 2D and3for 3D. If a tuple is given, a tensor field is created.sdim (MuscatIndex) – Space dimension where the field evolves.
extraCoordinates (list[str], optional) – Extra field parameters, such as time.
- Returns:
Matrix containing functions of the spatial coordinates and any extra coordinates.
- Return type:
sympy.Matrix
- Gradient(arg, sdim=3)[source]¶
Compute the gradient of a vector or scalar field.
- Parameters:
arg (sympy.Matrix) – Matrix of shape
(1, 1)for a scalar field or(n, 1)for a vector field.sdim (int, optional) – Space dimension on which to differentiate, either
2or3.
- Returns:
Matrix of shape
(sdim, 1)for a scalar field or(sdim, n)for a vector field. The first dimension is the differentiation coordinate and the second is the vector component.- Return type:
sympy.Matrix
- Inner(a, b)[source]¶
Compute the scalar product of two vector fields.
- Parameters:
a (sympy.Matrix) – Vector field of shape
(n, 1).b (sympy.Matrix) – Vector field of shape
(n, 1).
- Returns:
Scalar product following the first dimension, using the opposite convention to NumPy.
- Return type:
sympy.Expr
Notes
Matrix support is not implemented yet.
- Laplacian(arg, sdim=3)[source]¶
Compute the Laplacian of a scalar or vector field.
- Parameters:
arg (sympy.Matrix) – Matrix of shape
(1, 1)for a scalar field or(n, 1)for a vector field.sdim (int, optional) – Space dimension on which to differentiate, either
2or3.
- Returns:
Expression for a scalar field, or a matrix of shape
(n, 1)for a vector field.- Return type:
sympy.Expr or sympy.Matrix
- Strain(arg, sdim=3)[source]¶
Compute the strain matrix of a displacement vector.
- Parameters:
arg (sympy.Matrix) – Displacement field of shape
(n, 1).sdim (int, optional) – Dimension for the derivation, either
2or3.
- Returns:
Strain matrix of shape
(n, n).- Return type:
sympy.Matrix