This routine calls the “EvaluateValueX” function to obtain the X Values then creates 2 solution results for the plastic strain results for this and, if one exists, the previous set. A dictionary is created for the element nodal results being generated and this is populated by performing the required calculation.
def EvaluateDamage(Set, Const1, Const2, Const3):
XValues = EvaluateValueX(Set, Const1, Const2, Const3)
StrainRes = UpstreamSolution.CreateSolutionResult("","EPPLEQV_RST","Strain")
StrainRes.ResultSet = Set
PrevStrainRes = UpstreamSolution.CreateSolutionResult("","EPPLEQV_RST","Strain")
if (Set >= 2):
PrevStrainRes.ResultSet = Set - 1
DamageValues = {} #key = element node id tuple, #data = values array.
for Element in DA.MeshData.Elements():
for Node in Element.Nodes():
S1 = StrainRes.ElementNodalValues(Element.Id,Node.Id)[0]
S2 = 0
if (Set >= 2):
S2 = PrevStrainRes.ElementNodalValues(Element.Id,Node.Id)[0]
XValue = XValues[Element.Id,Node.Id]
DamageValues[Element.Id,Node.Id] = (S1 - S2) / XValue
return DamageValues