I would like to extract Principal stresses, von Mises stress and directional displacements fields from LS-DYNA using PyDPF-Core. Below is my implementation, but currently, I can only plot one displacement field, and it’s unclear which type of displacement it represents. Additionally, when trying to extract von Mises stress, I encounter an “AttributeError: ‘CommonResults’ object has no attribute ‘von_mises_stress’.”
path0 = r'C:\my_path'
path = os.path.join(path0, "d3plot")
act_units = os.path.join(path0, "file.actunits")
ds = dpf.DataSources()
ds.set_result_file_path(path, "d3plot")
ds.add_file_path(act_units , "actunits")
model = dpf.Model(ds)
print(model)
cpos_list = ['xy' ,'xz', 'yz', 'yx', 'zx', 'zy', 'iso']
cpos = cpos_list[0]
cpos =[(1, 1, 50),
(10, 10, 0),
(0, 1, 0)
N = model.results.stress(time_scoping=[12]).eval()
u = model.results.displacement(time_scoping=[12]).eval()
eqv_stress = model.results.von_mises_stress(time_scoping=[12]).eval()
fields_d_= u[0]
pl = DpfPlotter(notebook=False, off_screen=True)
Add the field to the plotter
pl.add_field(fields_d_, model.metadata.meshed_region,how_edges=True, opacity=0.8,
show_max=True,show_min=True,label_text_size=10)
output_image_path_d = os.path.join(os.getcwd(), 'Visualizations/disp.png')
pl.show_figure(cpos=cpos, screenshot=output_image_path_d,auto_close=False)