After defining a dictionary to store the element nodal based results, this function creates a new result with part of the required equation and then defines which set to obtain the results from. Then, looping through each element and its nodes, it calculates the part of the equation that is not possible with the standard Mechanical equations and assigns it into the dictionary for the given node and element Id.
def EvaluateValueX(Set, Const1, Const2, Const3):
XValues = {} #key = element node id tuple, #data = values array.
SolRes = UpstreamSolution.CreateSolutionResult("",str(Const2/(1+Const3))+"*((((s1+s2+s3)/(3*seqv))-\
(1/3)))","Stress")
SolRes.ResultSet = Set
for Element in DA.MeshData.Elements():
for Node in Element.Nodes():
SolResValue = SolRes.ElementNodalValues(Element.Id,Node.Id)
XValue = Const1 * math.exp(SolResValue[0])
XValues[Element.Id,Node.Id] = XValue
return XValues