How to plot fibre orientation tensor in global coordinates system?
Javier Vique
Member, Employee Posts: 86
✭✭✭✭
in Structures
When using injection molding data, Mechanical reads and makes a mapping into the mesh of the data coming from the injection software. Fibre orientation tensor can be plot in elemental orientation, however there is no option to plot it in global coordinate system. There is an example to do it outside Mechanical GUI link, but is there any way to do it inside Mechanical?
Tagged:
0
Answers
-
In Ansys 2025R1, it can be used dpf operator dpf.operators.result.stress_rotation_by_euler_nodes() to make a rotation of the elemental fibre orientation tensor. A property is also defined for selecting the specific component:
def reload_props(): this.PropertyProvider = None # comment the following return to allow the rest of the function definition to be executed and add properties #return """ Some sample code is provided below that shows how to: 1. Create an instance of the Provider. The Provider class is used to add custom properties to the details. 2. Use the Provider instance to add custom properties. 3. Configure those custom properties. """ # Create the property instance provider = Provider() # Create a new group named Group 2. group_two = provider.AddGroup("FOT") # Add an options property to the second group options_prop = group_two.AddProperty("Direction", Control.Options) # Add a couple options to the options property. options_prop.Options = {0 : "XX", 1 : "YY", 2 : "ZZ", 3 : "XY", 4 : "YZ", 5 : "XZ"} # Connects the provider instance back to the object by setting the PropertyProvider member on this, 'this' being the # current instance of the Python Code object. this.PropertyProvider = provider
Here the script to plot FOT in global CS:
def post_started(sender, analysis):# Do not edit this line define_dpf_workflow(analysis) # Uncomment this function to enable retrieving results from the table/chart # def table_retrieve_result(value):# Do not edit this line # import mech_dpf # import Ans.DataProcessing as dpf # wf = dpf.Workflow(this.WorkflowId) # wf.Connect('contour_selector', value) # this.Evaluate() def _load_plugins(): # utility function to load the dpf composites plugins import os import mech_dpf import Ans.DataProcessing as dpf version = Ansys.Utilities.ApplicationConfiguration.DefaultConfiguration.VersionInfo.VersionString dpf_root = os.path.join(os.environ["AWP_ROOT"+version], "dpf") composites_root = os.path.join(dpf_root, "plugins", "dpf_composites") dpf.DataProcessingCore.LoadLibrary('EngineeringData', os.path.join(dpf_root, 'bin', 'winx64', 'Ans.Dpf.EngineeringData.dll'), 'LoadOperators') dpf.DataProcessingCore.LoadLibrary('composites', os.path.join(composites_root, 'composite_operators.dll'), 'LoadOperators') def define_dpf_workflow(analysis): import os import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) dataSource = dpf.DataSources(analysis.ResultFileName) _load_plugins() analysis = ExtAPI.DataModel.Project.Model.Analyses[0] working_directory = analysis.WorkingDir engd_path = os.path.join(working_directory, "MatML.xml") rst_path = os.path.join(working_directory, "file.rst") dat_path = os.path.join(working_directory, "ds.dat") data_sources = dpf.DataSources() data_sources.AddFilePath(engd_path, "EngineeringData") data_sources.AddFilePath(dat_path, "dat") rst_data_source = dpf.DataSources() rst_data_source.SetResultFilePath(rst_path) model=dpf.Model(rst_data_source) mesh = model.Mesh fot_values = dpf.Operator("composite::inistate_field_variables_provider") fot_values.Connect(4, data_sources) fot_values.Connect(7, mesh) # extract a11 & a22 data extract_field = dpf.operators.utility.extract_field() extract_field.inputs.fields_container.Connect(fot_values, 0) extract_field.inputs.indices.Connect([0]) a11 = extract_field.outputs.field.GetData() extract_field.inputs.indices.Connect([1]) a22 = extract_field.outputs.field.GetData() # Read elemental stresses in elemental CS and modify op_s = dpf.operators.result.stress() op_s.inputs.data_sources.Connect(rst_data_source) op_s.inputs.bool_rotate_to_global.Connect(False) op_s.inputs.requested_location.Connect(dpf.locations.elemental) FOT_tensor = op_s.outputs.fields_container.GetData() FOT_tensor_f = FOT_tensor[0] for eid in FOT_tensor_f.ScopingIds: a11_i = a11.GetEntityDataById(eid)[0] a22_i = a22.GetEntityDataById(eid)[0] a33_i = max([0.0,1.0 - a11_i - a22_i]) eindex = FOT_tensor_f.Scoping.IndexById(eid) FOT_tensor_f.UpdateEntityDataByEntityIndex(eindex,[a11_i,a22_i,a33_i,0.0,0.0,0.0]) op_e = dpf.operators.result.stress_rotation_by_euler_nodes() op_e.inputs.fields_container.Connect(FOT_tensor) op_e.inputs.data_sources.Connect(rst_data_source) FOT_global = op_e.outputs.fields_container.GetData() FOT_global[0].Unit = '' component = int(this.GetCustomPropertyByPath("FOT/Direction").Value) op_comp = dpf.operators.logic.component_selector_fc() op_comp.inputs.fields_container.Connect(FOT_global) op_comp.inputs.component_number.Connect(component) dpf_workflow = dpf.Workflow() dpf_workflow.Add(op_comp) # dpf_workflow.SetInputName(u, 0, 'time') # dpf_workflow.Connect('time', timeScop) dpf_workflow.SetOutputContour(op_comp) dpf_workflow.Record('wf_id', False) this.WorkflowId = dpf_workflow.GetRecordedId()
0