doc:user:elements:volumes:user_defined_materials
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:user:elements:volumes:user_defined_materials [2024/06/06 15:28] – radermecker | doc:user:elements:volumes:user_defined_materials [2024/10/22 14:15] (current) – radermecker | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== | + | ====== |
| - | The goal is to create a Python class (e.g., in the input file) that derives from the C++ class `PythonHyperMaterial` and overwrites the following functions: | + | This section explains how any user can define its own constitutive equation in Metafor |
| - | * `def PythonHyperMaterial.__init__(self, | + | The idea is to create a Python class (e.g., in the input file) that derives from the C++ class `PythonHyperMaterial` and overwrites the following functions: |
| - | * `_no` being the material number. | + | |
| - | * `def computeStressPython(self, | + | * '' |
| - | * **Input:** The total deformation gradient. | + | * '' |
| - | * Sent from C++ to Python through a `std::vector` [F11, F12, F13, F21, F22, F23, F31, F32, F33] | + | * **Input:** The total deformation gradient |
| - | * **Output:** Cauchy stress, in the current configuration. | + | * **Output: |
| - | * Sent from Python to C++ through a Python list [Sig11, Sig22, Sig33, Sig12, Sig13, Sig23] | + | |
| The relation between stress and strain is defined by the user. | The relation between stress and strain is defined by the user. | ||
| + | | ||
| + | <WRAP center round important 60%> | ||
| + | Selective integration with pressure report '' | ||
| + | </ | ||
| + | <WRAP center round info 60%> | ||
| + | The material tangent moduli is automatically approximated using finite central difference. | ||
| + | </ | ||
| - | ===== Remarks ===== | ||
| - | |||
| - | * **Why does `PythonHyperMaterial` derive from `HyperMaterial`? | ||
| - | |||
| - | Hyper (Cauchy) Materials are based on the total deformation gradient. In the next merge, I will (try to) add Material perturbation to evaluate (finite difference) the Material Tangent Operator for all Cauchy Hypermaterial, | ||
| - | |||
| - | :!: Therefore, so far, global perturbation (of the internal forces) must be used :!: | ||
| - | |||
| - | ```python | ||
| - | elementsProps.put(STIFFMETHOD, | ||
| - | ``` | ||
| - | |||
| - | * **Why doesn' | ||
| - | |||
| - | This user-defined feature should be kept **as simple as possible** (KISS). Therefore, the user can rely on simple data types which they can easily transform, for instance, to `np.array` (see example). A student has already used this feature without any questions after receiving the example below. If the application requires an efficient implementation, | ||
| ===== Example: A NeoHookean Model ===== | ===== Example: A NeoHookean Model ===== | ||
| + | <code python> | ||
| + | from wrap import * | ||
| + | import numpy as np | ||
| + | metafor = None | ||
| - | ```python | ||
| class UserMat(PythonHyperMaterial): | class UserMat(PythonHyperMaterial): | ||
| - | |||
| def __init__(self, | def __init__(self, | ||
| PythonHyperMaterial.__init__(self, | PythonHyperMaterial.__init__(self, | ||
| Line 51: | Line 44: | ||
| def getMetafor(_p): | def getMetafor(_p): | ||
| - | |||
| # ... some code ... # | # ... some code ... # | ||
| | | ||
| Line 61: | Line 53: | ||
| elementsProps = ElementProperties(Volume2DElement) | elementsProps = ElementProperties(Volume2DElement) | ||
| elementsProps.put(MATERIAL, | elementsProps.put(MATERIAL, | ||
| - | elementsProps.put(STIFFMETHOD, | ||
| # ... some code ... # | # ... some code ... # | ||
| | | ||
| return metafor | return metafor | ||
| + | </ | ||
| + | |||
doc/user/elements/volumes/user_defined_materials.1717680506.txt.gz · Last modified: by radermecker
