The main stages involved in the process for Solids are:
Enter the pre-processor /prep7
Initialize model with deformations from end of the explicit analysis
Specify reduced element integration
Enter solution processor
Initialize implicit model with stresses from end of the explicit analysis
Initialize implicit model with plastic strains from end of the explicit analysis
The first thing to consider is the deformation at the end of the explicit analysis. Deformation is a nodal result and thus deformation components are obtained at every node.
UpstreamSolution = DesignAssessment.SolutionSelections()[0].SolutionByRow(1)
UpstreamResult1 = UpstreamSolution.CreateSolutionResult("","UVECTORS","Distance")
#write "Text" to solver output file"
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
for Node in DesignAssessment.MeshData.Nodes():
NodeID = Node.Id
#set variables to components of deformation vector result
U1 = UpstreamResult1.NodalValues(NodeID)[0]
U2 = UpstreamResult1.NodalValues(NodeID)[1]
U3 = UpstreamResult1.NodalValues(NodeID)[2]
print str(NodeID) + ": " +str(U3)
#write commands to redefine node locations
Text = "*GET, X_CO, NODE, " + str(NodeID) +", LOC, X,\n\
*GET, Y_CO, NODE, " + str(NodeID) + ", LOC, Y,\n\
*GET, Z_CO, NODE, " + str(NodeID) + ", LOC, Z,\n\
N, "+str(NodeID) + ", X_CO + ("+ str(U1) +"), Y_CO + (" + str(U2) + "), Z_CO + (" + str(U3)+")\n"
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
DesignAssessment.Helper.AppendToSolverOutputFile(Text) writes whatever is
stored in the variable Text to the Solver Output File
of the Design Assessment system.
The Mechanical APDL commands then are written in the following format:
*GET, X_CO, NODE, 1, LOC, X, *GET, Y_CO, NODE, 1, LOC, Y, *GET, Z_CO, NODE, 1, LOC, Z, N, 1, X_CO + (0.0159664358944), Y_CO + (-0.478581756353), Z_CO + (4.01744182454e-05) *GET, X_CO, NODE, 2, LOC, X, *GET, Y_CO, NODE, 2, LOC, Y, *GET, Z_CO, NODE, 2, LOC, Z, N, 2, X_CO + (0.0159850046039), Y_CO + (-0.478512704372), Z_CO + (2.13666535274e-05) *GET, X_CO, NODE, 3, LOC, X, *GET, Y_CO, NODE, 3, LOC, Y, *GET, Z_CO, NODE, 3, LOC, Z, N, 3, X_CO + (0.0159850046039), Y_CO + (-0.478512704372), Z_CO + (-2.13666735362e-05)
These commands obtain the original location of the nodes from the mesh of the implicit analysis, add the deformation of those nodes from the end of the explicit analysis, and redefine the position of the nodes to the new location. Refer to the Mechanical APDL Command Reference for more information on the specific Mechanical APDL commands.
It is now necessary to write Mechanical APDL commands to initialize the model with the stresses and plastic strains from the end of the explicit analysis. The Mechanical APDL command used for this is INISTATE.
Solution results are created for each of the results that are of interest. The integration method is set to unaveraged because the result for the element is required, as opposed to the result at the node. Using an unaveraged integration method means that all of the nodes on one element have the same value. It is therefore only necessary to get the value at one of the nodes. Element.Nodes()[0].Id gets the Node ID of the first node in the array of nodes for the current element. The results are then obtained for this node.
#stress components
SX = UpstreamSolution.CreateSolutionResult("","SX","No Units")
SY = UpstreamSolution.CreateSolutionResult("","SY","No Units")
SZ = UpstreamSolution.CreateSolutionResult("","SZ","No Units")
SXY = UpstreamSolution.CreateSolutionResult("","SXY","No Units")
SYZ = UpstreamSolution.CreateSolutionResult("","SYZ","No Units")
SXZ = UpstreamSolution.CreateSolutionResult("","SXZ","No Units")
#specify unaveraged integration method
SX.IntegrationMethod = ("unaveraged")
SY.IntegrationMethod = ("unaveraged")
SZ.IntegrationMethod = ("unaveraged")
SXY.IntegrationMethod = ("unaveraged")
SYZ.IntegrationMethod = ("unaveraged")
SXZ.IntegrationMethod = ("unaveraged")
for Element in DesignAssessment.MeshData.Elements():
#get ID of first node in element
FirstNodeId = Element.Nodes()[0].Id
#write commands to initialize stress
Text = "INISTATE, SET, DTYP, STRESS\nINISTATE, DEFINE, " + str(Element.Id) + \
", all,all,all, "
+ str(SX.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SY.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SZ.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SXY.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SYZ.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SXZ.ElementNodalValues(Element.Id, FirstNodeId)[0])
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
This generates Mechanical APDL commands as follows:
INISTATE, SET, DTYP, STRESS INISTATE, DEFINE, 1, all,all,all,77669520.0,-108961984.0,8667132.0,-127329504.0,40947276.0,-21408484.0 INISTATE, SET, DTYP, STRESS INISTATE, DEFINE, 2, all,all,all,73086624.0,-54661364.0, 2108868.5,-50930028.0,-2542906.5,-13913089.0 INISTATE, SET, DTYP, STRESS INISTATE, DEFINE, 3, all,all,all, 57340700.0, -85816616.0, -16383176.0, -96323688.0, 0.0, 0.0
For shells, the layers and integration points within layers have to also be considered. These are also defined as parameters of the INISTATE command. In the Design Assessment script, you must specify which integration point within the layer to obtain results for. This is done as follows:
SX.ShellFaceResultDisplay = "Top"
SY.ShellFaceResultDisplay = "Top"
SZ.ShellFaceResultDisplay = "Top"
SXY.ShellFaceResultDisplay = "Top"
SYZ.ShellFaceResultDisplay = "Top"
SXZ.ShellFaceResultDisplay = "Top"
for Element in DesignAssessment.MeshData.Elements():
FirstNodeId = Element.Nodes()[0].Id
Text = "INISTATE, SET, DTYP, STRESS\nINISTATE, DEFINE, " + str(Element.Id) + ", all,all,3, " \
+ str(SX.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SY.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SZ.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SXY.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SYZ.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SXZ.ElementNodalValues(Element.Id, FirstNodeId)[0])
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
This obtains results from the explicit analysis on the top surface of the layer. When writing the Mechanical APDL commands, the layers are counted from the bottom, so here we specify layer 3 as we are defining the values for the top layer.
The same thing is done for plastic strain and accumulated equivalent plastic strain. The full Solve script for Solids is included as a reference below:
def RunDA():
UpstreamSolution = DesignAssessment.SolutionSelections()[0].SolutionByRow(1)
UpstreamResult1 = UpstreamSolution.CreateSolutionResult("","UVECTORS","Distance")
#enter pre-processor
Text = "/prep7\n"
#write "Text" to solver output file"
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
for Node in DesignAssessment.MeshData.Nodes():
NodeID = Node.Id
#set variables to components of deformation vector result
U1 = UpstreamResult1.NodalValues(NodeID)[0]
U2 = UpstreamResult1.NodalValues(NodeID)[1]
U3 = UpstreamResult1.NodalValues(NodeID)[2]
print str(NodeID) + ": " +str(U3)
#write commands to redefine node locations
Text = "*GET, X_CO, NODE, " + str(NodeID) +", LOC, X,\n\
*GET, Y_CO, NODE, " + str(NodeID) + ", LOC, Y,\n\
*GET, Z_CO, NODE, " + str(NodeID) + ", LOC, Z,\n\
N, "+str(NodeID) + ", X_CO + ("+ str(U1) +"), Y_CO + (" + str(U2) + "), Z_CO + (" + str(U3)+")\n"
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
#stress components
SX = UpstreamSolution.CreateSolutionResult("","SX","No Units")
SY = UpstreamSolution.CreateSolutionResult("","SY","No Units")
SZ = UpstreamSolution.CreateSolutionResult("","SZ","No Units")
SXY = UpstreamSolution.CreateSolutionResult("","SXY","No Units")
SYZ = UpstreamSolution.CreateSolutionResult("","SYZ","No Units")
SXZ = UpstreamSolution.CreateSolutionResult("","SXZ","No Units")
#specify unaveraged integration method
SX.IntegrationMethod = ("unaveraged")
SY.IntegrationMethod = ("unaveraged")
SZ.IntegrationMethod = ("unaveraged")
SXY.IntegrationMethod = ("unaveraged")
SYZ.IntegrationMethod = ("unaveraged")
SXZ.IntegrationMethod = ("unaveraged")
#plastic strain components
EPPLX = UpstreamSolution.CreateSolutionResult("","EPPLX","No Units")
EPPLY = UpstreamSolution.CreateSolutionResult("","EPPLY","No Units")
EPPLZ = UpstreamSolution.CreateSolutionResult("","EPPLZ","No Units")
EPPLXY = UpstreamSolution.CreateSolutionResult("","EPPLXY","No Units")
EPPLYZ = UpstreamSolution.CreateSolutionResult("","EPPLYZ","No Units")
EPPLXZ = UpstreamSolution.CreateSolutionResult("","EPPLXZ","No Units")
EPPLX.IntegrationMethod = ("unaveraged")
EPPLY.IntegrationMethod = ("unaveraged")
EPPLZ.IntegrationMethod = ("unaveraged")
EPPLXY.IntegrationMethod = ("unaveraged")
EPPLYZ.IntegrationMethod = ("unaveraged")
EPPLXZ.IntegrationMethod = ("unaveraged")
#accumulated equivalent plastic strain
EFF_PL_STNALL = UpstreamSolution.CreateSolutionResult("","EFF_PL_STNALL","No Units")
EFF_PL_STNALL.IntegrationMethod = ("unaveraged")
#specify reduced integration formulation for SOLID185
Text = " \n\n\net,1,185,,1\n/solu"
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
for Element in DesignAssessment.MeshData.Elements():
#get ID of first node in element
FirstNodeId = Element.Nodes()[0].Id
#write commands to initialise stress
Text = "INISTATE, SET, DTYP, STRESS\nINISTATE, DEFINE, " + str(Element.Id) + ", all,all,all, " \
+ str(SX.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SY.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SZ.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(SXY.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SYZ.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(SXZ.ElementNodalValues(Element.Id, FirstNodeId)[0])
DesignAssessment.Helper.AppendToSolverOutputFile(Text)
for Element in DesignAssessment.MeshData.Elements():
FirstNodeId = Element.Nodes()[0].Id
#write commands to initialize plastic strain
Text2 = "INISTATE, SET, DTYP, EPPL\nINISTATE, DEFINE, "+ str(Element.Id) + ", all,all,all, "\
+ str(EPPLX.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(EPPLY.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(EPPLZ.ElementNodalValues(Element.Id, FirstNodeId)[0]) + ", " \
+ str(EPPLXY.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(EPPLYZ.ElementNodalValues(Element.Id, FirstNodeId)[0])+ ", " \
+ str(EPPLXZ.ElementNodalValues(Element.Id, FirstNodeId)[0])
DesignAssessment.Helper.AppendToSolverOutputFile(Text2)
for Element in DesignAssessment.MeshData.Elements():
FirstNodeId = Element.Nodes()[0].Id
#write commands to initialize accumulated equivalent plastic strain
Text2 = "INISTATE, SET, DTYP, PLEQ\nINISTATE, DEFINE, "+ str(Element.Id) + ", all,all,all, "\
+ str(EFF_PL_STNALL.ElementNodalValues(Element.Id, FirstNodeId)[0])
DesignAssessment.Helper.AppendToSolverOutputFile(Text2)
Text = "solve"
RunDA()