Problems initializing own constitutive model #11560
-
I want to implement a hardening law for plasticity. For this I work with the application ConstitutiveModelsApplication. I replaced the deprecated Python commands and the material models already implemented in this application are now running. I added my plasticity model to the 'add_custom_constitutive_laws_to_python.cpp' file bute get the error AttributeError: 'module 'KratosMultiphysics.ConstitutiveModelsApplication' has no attribute 'VonMisesLinearElasticSwiftPlasticityModel'' I am using VisualCode on Windows 11 Pro and Pythonn 3.11.3 on a 64-bit machine. Has someone a hint where I should look for my fault or what is the right way to find it? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Can you plz produce a diff on your |
Beta Was this translation helpful? Give feedback.
-
Sure: ---------- applications/ConstitutiveModelsApplication/CMakeLists.txt ---------- ${CMAKE_CURRENT_SOURCE_DIR}/custom_models/plasticity_models/hardening_rules/modified_exponential_damage_hardening_rule.cpp #utilities applications/ConstitutiveModelsApplication/custom_python/add_custom_constitutive_laws_to_python.cpp // Plasticity models |
Beta Was this translation helpful? Give feedback.
-
@scja1991 any luck? |
Beta Was this translation helpful? Give feedback.
-
I do not know how is maintining the |
Beta Was this translation helpful? Give feedback.
Right, so far so good. However, it's not enough to include the header of your class, you have to define its bindings manually. You can take a look at the rest of
add_custom_constitutive_laws_to_python.cpp
for examples. You'll probably have to define your bindings like this:py::class_<VonMisesLinearElasticSwiftPlasticityModel, VonMisesLinearElasticSwiftPlasticityModel::Pointer, ConsitutiveLaw>(m, "VonMisesLinearElasticSwiftPlasticityModel") .def(py::init<>()) ;
Details
This is just extra info if you want to know more about python bindings - it's not strictly necessary to understand it to solve your problem at hand.
We're using pybind to create python bindings for C++ c…