Metafor

ULiege - Aerospace & Mechanical Engineering

User Tools

Site Tools


doc:user:elements:volumes:user_defined_materials

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
doc:user:elements:volumes:user_defined_materials [2024/06/06 15:25] – created radermeckerdoc:user:elements:volumes:user_defined_materials [2024/10/22 14:15] (current) radermecker
Line 1: Line 1:
-====== User-defined materials ======+====== User defined materials ======
  
-===== PythonHyperMaterial =====+This section explains how any user can define its own constitutive equation in Metafor (usermat or user-defined feature). 
  
 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: 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:
  
-  * `def PythonHyperMaterial.__init__(self, _no):`, with `_nobeing the material number. +  * ''def PythonHyperMaterial.<nowiki>__init__</nowiki>(self, _no):'' with ''_no'' being the material number chosen
-  * `def computeStressPython(self, FTotal):` +  * ''def computeStressPython(self, FTotal):'' 
-    * **Input:** The total deformation gradient+    * **Input:** The total deformation gradient ''FTotal'', sent from C++ to Python through a ''std::vector'' [F11, F12, F13, F21, F22, F23, F31, F32, F33], hence ''FTotal[0] = F11'', etc. 
-      * Sent from C++ to Python through a `std::vector[F11, F12, F13, F21, F22, F23, F31, F32, F33] +    * **Output:** The Cauchy stress, in the current configuration, returned from Python to C++ through a Python list [Sig11, Sig22, Sig33, Sig12, Sig13, Sig23]
-    * **Output:** Cauchy stress, in the **current configuration**. +
-      * 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 ''SRIPR'' for the integration will not work.
 +</WRAP>
 +<WRAP center round info 60%>
 +The material tangent moduli is automatically approximated using finite central difference.
 +</WRAP>
  
-==== 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, including `PythonHyperMaterial`. 
- 
-    :!: Therefore, so far, global perturbation (of the internal forces) must be used :!: 
- 
-    ```python 
-    elementsProps.put(STIFFMETHOD, STIFF_NUMERIC) 
-    ``` 
- 
-  * **Why doesn't `ComputeStressPython`** (i.e., the user-defined material) use Matr3/... etc? 
- 
-    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, adding the material directly in Metafor remains the preferred procedure (especially with its tangent moduli). 
  
-==== 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, _no):     def __init__(self, _no):
         PythonHyperMaterial.__init__(self, _no)         PythonHyperMaterial.__init__(self, _no)
Line 52: Line 44:
  
 def getMetafor(_p): def getMetafor(_p):
- 
     # ... some code ... #     # ... some code ... #
          
Line 62: Line 53:
     elementsProps = ElementProperties(Volume2DElement)     elementsProps = ElementProperties(Volume2DElement)
     elementsProps.put(MATERIAL, 1)     elementsProps.put(MATERIAL, 1)
-    elementsProps.put(STIFFMETHOD, STIFF_NUMERIC) 
  
     # ... some code ... #     # ... some code ... #
          
     return metafor     return metafor
 +</code>
 +
 +
doc/user/elements/volumes/user_defined_materials.1717680329.txt.gz · Last modified: by radermecker

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki