Plotting resin front velocity in a resin filling simulation in LS-DYNA
Adya
Member, Employee Posts: 3
✭✭✭
in Structures
This examples shows how the level_set parameter can be extracted from d3plot in pydpf. The level_set parameter has a positive value where the fluid phase exists and negative everywhere else. In this example, the level_set is cast as a parameter with either 0 or 1 and an iso surface of the value is extracted. This gives us just the resin domain. The minimum y coordinate of this domain is the boundary of the wave front. By tracking this coordinate, the displacement and in turn the velocity of the resin flow can be computed.
from ansys.dpf import core as dpf from ansys.dpf.core import examples from ansys.dpf.core import operators as ops import matplotlib.pyplot as plt import numpy as np #### Load d3plot as 'ms' data dpf.load_library(r'D:\PYDYNA_PUBLIC_RELEASE_0.4\Ans.Dpf.LSDYNAHGP_2024_4_18\Ans.Dpf.LSDYNAHGP.dll', 'lsdyna') ds = dpf.DataSources() ds.set_result_file_path(r'C:\Users\sadya\Downloads\2Adya\d3plot') model = dpf.Model(ds) print(model) #### Extract the number of states in d3plot tf = model.metadata.time_freq_support.time_frequencies.data level_set = model.results.level_set.on_all_time_freqs().eval() print(level_set) #### Loop through the states to get the level_set results distance = [0] velocity = [] count =1 for i in range(len(tf)-1): level_set[i].data = np.where(level_set[i].data > 0,1,0 #### Extract iso surface with current level_set as the field op = dpf.operators.mesh.iso_surfaces( field=level_set[i], num_surfaces=1, mesh=model.metadata.meshed_region, ) #### get the mesh from the operator result = op.outputs.meshes().get_mesh(0).grid #### compute distance and velocity distance.append(np.min(result.points[:,1])) if count > 1: velocity.append((distance[count]-distance[count-1])/(tf[count]-tf[count-1])) count+=1 plt.plot(tf[2:],velocity) plt.xlabel('Time') plt.ylabel('Velocity of resin front') plt.show() level_set.animate(show_edges=False,clim = [-0.5,1],opacity="linear")
1