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

CheckIntegrity(GUI: bool = False)[source]
Cross(a, b)[source]

Cross product of 3D vector field Input:

a: sympy.matrix of size (n,1) (vector field) b: sympy.matrix of size (n,1) (vector field)

Return type:

sympy.matrix of size (n,1) (vector field)

Diag(arg)[source]

Operator to create a matrix from a list of symbolic weak forms Input:

arg: array or iterable or shape (n) with __len__ implemented containing weak forms (sympy expressions)

Return type:

Sympy Matrix of shape (n x n)

Divergence(arg, sdim=3)[source]

Operator to compute the divergence of a vector or on a matrix Input:

arg: SympyMatrix of size (n,1) or (n,n) (n=2 or 3) sdim: dimension of the divergence (either 2 or 3)

Return type:

sympy.expr if arg is a vector (shape (n,1)) or sympy.Matrix of shape (n,1) if arg is a Matrix of shape (n,n)

FromVoigtSigma(arg)[source]

https://en.wikipedia.org/wiki/Voigt_notation

GetConstant(name, size=1) Symbol | MutableDenseMatrix[source]

Function to populate a constant field, vectorial or scalar Input:

name: str, label of the constant field if the field is vectorial then the

Return type:

sympy.Symbol if size=1 or

GetField(name: str, size: int64, star=False, sdim=3, extraCoordinates=[]) MutableDenseMatrix[source]

Function to instanciate a scalar, a vector field or a tensor field: Input:

name: str, label of the field, if size > 1 then each component will get a suffix for the coordinate size: MuscatIndex or tuple of MuscatIndex, dimension of the field (1 for scalar, 2 for 2D, 3 for 3D), if a tuple is given a tensor field is created. star: bool, whether the instanciated field is a test field (is used by the function GetTestField) sdim : int, space dimension where the field will evolve extraCoordinates: list[str], list of extra parameter of the field (time for instance)

Return type:

sympy.Matrix of shape (size,1) containing functions of (“x”,”y”,”z”) if sdim=3, (“x”,”y”) if sdim=2, (“x”) if sdim=1, along with extraCoordinates if given

GetNormal(size: int64)[source]

Function to get the normal of an element. The Normal symbol will be populated with the proper value when processed by the integrator Input:

size: MuscatIndex, dimension of the normal. Usually taken equal to the problem dimension

Return type:

sympy.Matrix of shape (size,1) with the special denomination “Normal”

GetScalarField(alpha)[source]

Factory to create a constant scalar field from multiple input types :rtype: sympy.Symbol if alpha is string, float if alpha is int or float.

GetTestField(name, size, sdim=3, extraCoordinates=[])[source]

Function to instanciate a test field. It is a simple wrapper of the function GetField with star=True Input:

name: str, label of the field, if size > 1 then each component will get a suffix for the coordinate + and the test character size: MuscatIndex or tuple of MuscatIndex, dimension of the field (1 for scalar, 2 for 2D, 3 for 3D), if a tuple is given a tensor field is created. sdim : int, space dimension where the field will evolve extraCoordinates: list[str], list of extra parameter of the field (time for instance)

Return type:

sympy.Matrix of shape (size,1) containing functions of (“x”,”y”,”z”) if sdim=3, (“x”,”y”) if sdim=2, (“x”) if sdim=1, along with extraCoordinates if given

GetTestSufixChar() str[source]
Gradient(arg, sdim=3)[source]

Computes the gradient of a vector or scalar Input:

arg: sympy.matrix of size (1,1) (scalar field) or (n,1) (vector field) sdim: dimension space on which to differentiate (2 or 3 for 2D or 3D)

Return type:

sympy.Matrix of size (sdim,1) if arg is a scalar field else (sdim,n) if arg is a vector field. The first dim is the differentiation coordinate and the second the vector composant

Inner(a, b)[source]

Computing the scalar product of two vectors fields Input:

a: vector field of shape (n,1) b: vector field of shape (n,1)

Return type:

sympy.exp of the scalar product following first dimension (opposite convention than numpy)

TODO: Make implementation compliant with numpy in the case of matrices

Laplacian(arg, sdim=3)[source]

Computes the Laplacian of the scalar or vector field Input:

arg: sympy.matrix of size (1,1) (scalar field) or (n,1) (vector field) sdim: dimension space on which to differentiate (2 or 3 for 2D or 3D)

Return type:

sympy.expr if arg is a scalar field else (n,1) if arg is a vector field.

Strain(arg, sdim=3)[source]

Computes the strain matrix of a displacement vector Input:

arg: sympy.matrix displacement field of shape (n,1) sdim: int dimension for the derivation (2 or 3)

Return type:

sympy.Matrix of shape (n,n)

StrainAxyCol(arg, radius)[source]
ToVoigtEpsilon(arg)[source]

https://en.wikipedia.org/wiki/Voigt_notation

ToVoigtSigma(arg)[source]

https://en.wikipedia.org/wiki/Voigt_notation

Trace(arg)[source]

Operator to compute the trace of a sympy matrix Input:

arg: sympy matrix

Return type:

sympy.expr (weak form) composed of the sum of diagonal elements