Beam results, dpf, Mechanical
Joshua Fillion
Member Posts: 2
**
in Structures
Best Answer
-
Hello @Joshua Fillion
Here is a simple script using DPF that you can use in Mechanical Scripting Console to print beam reactions (X axis. This can be extended to Y, Z and Total as well) for all the beam connections in the Tree. You can also integrate this script into "Python Code" object with "Target Callback" --> "After Post" in Mechanical to export this data into excel (for example).
import os import wbjn analysis = DataModel.AnalysisList[0] first_solution = analysis.Solution solver_data = first_solution.SolverData allBeams = DataModel.GetObjectsByType(DataModelObjectCategory.Beam) for beam in allBeams: beamData = solver_data.GetObjectData(beam) beamMatid = beamData.MaterialId beamElem = solver_data.ElementIdsByMaterialId(str(beamMatid)) import mech_dpf import Ans.DataProcessing as dpf #Result Data dataSource = dpf.DataSources(analysis.Solution.ResultFilePath) # Read mesh in results file mesh_op = dpf.operators.mesh.mesh_provider() mesh_op.inputs.data_sources.Connect(dataSource) my_mesh = mesh_op.outputs.mesh.GetData() #time scoping timelist = dpf.operators.metadata.time_freq_provider(data_sources=dataSource).outputs.gettime_freq_support().TimeFreqs.Data my_time_scoping = range(1, len(timelist)+1) #scoping my_scoping = dpf.Scoping() my_scoping.Location = "Elemental" my_scoping.Ids = beamElem time_data = [] Contact_TotalReaction = [] for setnum in range(len(timelist)): CX = dpf.operators.result.mapdl.smisc(time_scoping=my_time_scoping,mesh=my_mesh,data_sources=dataSource,item_index = 1,mesh_scoping=my_scoping).outputs.fields_container.GetData()[setnum] #print timelist[setnum],',',(CX.Data)*sum(CX.Data) + sum(CY.Data)*sum(CY.Data) + sum(CZ.Data)*sum(CZ.Data)) #reactionTotal = sqrt(sum(CX.Data)*sum(CX.Data) + sum(CY.Data)*sum(CY.Data) + sum(CZ.Data)*sum(CZ.Data)) time_data.append(timelist[setnum]) Contact_TotalReaction.append(CX.Data) print(Contact_TotalReaction)
0
Answers
-
@Ramdane or someone in @AKD-Scripting-Team might have some thoughts here?
0 -
Hey, thanks guys. At the time I ended up utilizing data written out to .csv files for the elements of interest via Ansys scripting and then calling a dpf python script separately for plotting via fields factory. Somewhat bubblegum and duct tape, but it got the job done too!
0