Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEM] Add tools for more yield points in simple hardening materials #5024

Merged
merged 3 commits into from Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/Mod/Fem/femexamples/material_nl_platewithhole.py
Expand Up @@ -149,8 +149,7 @@ def setup(doc=None, solvertype="ccxtools"):
# nonlinear material
name_nlm = "Material_nonlin"
nonlinear_mat = ObjectsFem.makeMaterialMechanicalNonlinear(doc, material_obj, name_nlm)
nonlinear_mat.YieldPoint1 = '240.0, 0.0'
nonlinear_mat.YieldPoint2 = '270.0, 0.025'
nonlinear_mat.YieldPoints = ['240.0, 0.0', '270.0, 0.025']
analysis.addObject(nonlinear_mat)
# check solver attributes, Nonlinearity needs to be set to nonlinear

Expand Down
98 changes: 58 additions & 40 deletions src/Mod/Fem/femobjects/material_mechanicalnonlinear.py
Expand Up @@ -41,44 +41,62 @@ class MaterialMechanicalNonlinear(base_fempythonobject.BaseFemPythonObject):

def __init__(self, obj):
super(MaterialMechanicalNonlinear, self).__init__(obj)
self.add_properties(obj)

obj.addProperty(
"App::PropertyLink",
"LinearBaseMaterial",
"Base",
"Set the linear material the nonlinear builds upon."
)

choices_nonlinear_material_models = ["simple hardening"]
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]

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 two, 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 = ""
def onDocumentRestored(self, obj):

# YieldPoints was (until 0.19) stored as 3 separate variables. Consolidate them if present.
yield_points = []
if hasattr(obj, "YieldPoint1"):
if obj.YieldPoint1:
yield_points.append(obj.YieldPoint1)
obj.removeProperty("YieldPoint1")
if hasattr(obj, "YieldPoint2"):
if obj.YieldPoint2:
yield_points.append(obj.YieldPoint2)
obj.removeProperty("YieldPoint2")
if hasattr(obj, "YieldPoint3"):
if obj.YieldPoint3:
yield_points.append(obj.YieldPoint3)
obj.removeProperty("YieldPoint3")

self.add_properties(obj)
if yield_points:
obj.YieldPoints = yield_points

# TODO: If in the future more nonlinear options are added, update choices here.

def add_properties(self, obj):

# this method is called from onDocumentRestored
# thus only add and or set a attribute
# if the attribute does not exist

if not hasattr(obj, "LinearBaseMaterial"):
obj.addProperty(
"App::PropertyLink",
"LinearBaseMaterial",
"Base",
"Set the linear material the nonlinear builds upon."
)

if not hasattr(obj, "MaterialModelNonlinearity"):
choices_nonlinear_material_models = ["simple hardening"]
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]

if not hasattr(obj, "YieldPoints"):
obj.addProperty(
"App::PropertyStringList",
"YieldPoints",
"Fem",
"Set stress and strain for yield points as a list of strings, "
"each point \"stress, plastic strain\""
)
obj.YieldPoints = []
8 changes: 2 additions & 6 deletions src/Mod/Fem/femsolver/calculix/write_femelement_material.py
Expand Up @@ -113,10 +113,6 @@ def is_density_needed():
if nl_mat_obj.LinearBaseMaterial == mat_obj:
if nl_mat_obj.MaterialModelNonlinearity == "simple hardening":
f.write("*PLASTIC\n")
if nl_mat_obj.YieldPoint1:
f.write("{}\n".format(nl_mat_obj.YieldPoint1))
if nl_mat_obj.YieldPoint2:
f.write("{}\n".format(nl_mat_obj.YieldPoint2))
if nl_mat_obj.YieldPoint3:
f.write("{}\n".format(nl_mat_obj.YieldPoint3))
for yield_point in nl_mat_obj.YieldPoints:
f.write("{}\n".format(yield_point))
f.write("\n")