How to extract data from a LSDYNA d3plot into a list using PyDPF?
DavidTR
Member, Employee Posts: 4
✭✭✭
in Structures
Comments
-
Here is an example extracting acceleration data and nodal information into a list:
from ansys.dpf import core as dpf """Adding an r or double \\ should fix path issues""" d3plot_path = r"D:\PATHTOD3PLOT\d3plot" """ACTunits file gets generated when using WB-LSDYNA to solve the analysis. It can be created manually too""" units_path = r"D:\PATHTOACTFILE\filename.actunits" ds = dpf.DataSources() ds.set_result_file_path(d3plot_path, "d3plot") ds.add_file_path(units_path, "actunits") model = dpf.Model(ds) print(model) """Time points""" print(model.metadata.time_freq_support.time_frequencies.data) num_of_states = len (model.metadata.time_freq_support.time_frequencies.data) print ("Total number of result states is = " + str(num_of_states)) """21 is the d3plot state""" acc = model.results.acceleration(time_scoping=[21]) fields_acc = acc.outputs.fields_container() """2 is the 3rd acceleration component, i.e. Z""" field_acc = fields_acc.select_component(2)[0] field_acc_data = field_acc.data print(field_acc) print("Z-acc of node 1 is = " + str(field_acc.data[0])) node = model.metadata.meshed_region.nodes[0] print("Node ID of node first node is = " + str(node.id)) print("Nodal coordinates of first node are = " + str(node.coordinates)) mesh = model.metadata.meshed_region meshes = dpf.operators.mesh.split_mesh(mesh=mesh, property="eltype").eval() print(meshes) print(meshes[0].nodes) print("Total number of nodes is = " + str(len(meshes[0].nodes))) ncoord_f = model.metadata.meshed_region.nodes.coordinates_field.data nid_f = model.metadata.meshed_region.nodes.coordinates_field.scoping.ids print(ncoord_f[0]) node_coord_acc = [] for n in range(0,len(meshes[0].nodes)): x_coord = ncoord_f[n][0] y_coord = ncoord_f[n][1] z_coord = ncoord_f[n][2] id_node = nid_f[n] acc_node = field_acc_data[n] node_coord_acc.append([id_node,x_coord,y_coord,z_coord,acc_node]) print("[Node ID, X_coord, Y_coord, Z_coord, Z_acc] at final state #21") print(node_coord_acc[0:5])
2 -
Hi David, is it possible to get part list from d3plot ?
I would to know no of parts , there names and part Ids.0