I would like to enrich the definition of non linear materials. So I would like to dynamically modify the properties of the non linear material data.
The code would be something like this:
Code: Select all
class _FemMaterialMechanicalNonlinear:
"The FemMaterialMechanicalNonlinear object"
def __init__(self, obj):
obj.Proxy = self
self.Type = "FemMaterialMechanicalNonlinear"
obj.addProperty("App::PropertyLink", "LinearBaseMaterial", "Base", "Set the linear material the nonlinear build uppon.")
// Several choices of hardening model
choices_nonlinear_material_models = ["isotropic hardening","kinematic hardening","combined"]
obj.addProperty("App::PropertyEnumeration", "MaterialModelNonlinearity", "Fem", "Set the type on nonlinear material model")
obj.MaterialModelNonlinearity = choices_nonlinear_material_models
obj.MaterialModelNonlinearity = choices_nonlinear_material_models[0]
// The following properties should change depending on the material model
// however these are the properties at init
obj.addProperty("App::PropertyString", "YieldPoint1", "Fem", "Set stress and strain for yield point one, separated by a comma.")
obj.YieldPoint1 = "235.0, 0.0"
obj.addProperty("App::PropertyString", "YieldPoint2", "Fem", "Set stress and strain for yield point one, separated by a comma.")
obj.YieldPoint2 = "241.0, 0.025"
obj.addProperty("App::PropertyString", "YieldPoint3", "Fem", "Set stress and strain for yield point three, separated by a comma.")
obj.YieldPoint3 = "250.0, 0.03"
def execute(self, obj):
// Depending on the choice, I want to add another property
if obj.MaterialModelNonlinearity == choices_nonlinear_material_models[1]:
obj.addProperty("App::PropertyString", "YieldPoint4", "Fem", "Set stress and strain for yield point three, separated by a comma.")
obj.YieldPoint4 = "260.0, 0.04"
// I should remove as well properties that are no more relevant:
obj.RemoveProperty("App::PropertyString", "YieldPoint1"")
return
What is the correct approach ?
BR
Sodelo