How do I apply pressure calculated as a function of polar coordinates of the element centroid in WB

Member, Moderator, Employee Posts: 442
✭✭✭✭
edited June 2023

The pressure load object in WB LS-Dyna applies a constant pressure value on all the selected elements. How can I vary the pressure value as a function of polar coordinates (theta, phi) of the element the pressure is applied on?

Tagged:

• Member, Moderator, Employee Posts: 442
✭✭✭✭

This is not natively supported in WB LS-Dyna. However, one can use the following script to retrieve the element centroid and the geometry origin to convert cartesian to polar coordinates and apply a calculated pressure on individual elements using command snippets `*DEFINE_CURVE` and `*LOAD_SEGMENT_ID`

NOTE:

1. Please adjust the script to retrieve the origin from the geometry object in the DataModelTree. This script uses (0.0, 0.0, 0.0) as the origin.
2. Define a Named selection of all the elements pressure is to be applied on and name it "elements_ns"
```import math

# Get elements
ns = ExtAPI.DataModel.GetObjectsByName("elements_ns")[0]

mesh_data = ExtAPI.DataModel.MeshDataByName("Global")

analysis = Model.Analyses[0]

# Loop over all the elements

origin = (0.0, 0.0, 0.0)  # Retrieve from Geometry Properties
elements = ns.Ids
for index, element in enumerate(elements, start=100):
element = mesh_data.ElementById(element)

element_centroid = element.Centroid

u"""
Convert cartesian coordinates to polar coordinates.
"""
# R
r = ((element_centroid[0] - origin[0]) ** 2 + (element_centroid[1] - origin[1]) ** 2 + (
element_centroid[2] - origin[2]) ** 2) ** 0.5
# THETA - Please check and convert the units if needed
theta = math.acos((element_centroid[2] - origin[2]) / r) * (180.0 / math.pi)
# PHI
phi = math.atan((element_centroid[1] - origin[1]) / (element_centroid[0] - origin[0])) * (180.0 / math.pi)

# Corner Nodes
corner_node_ids = element.CornerNodeIds

# Calculate Pressure on basis of a function -> f(theta, phi)
p = 0.3 * math.sin(phi)

\$#lcid, sidr, sfa, sfo, offa, offo, dattyp, lcint
{0}, 0, 1.0, 1.0, 0.0, 0.0, 0, 0
\$#a1, o1
0.0, {1}
1.0, {1}
10.0, {1}
""".format(index, p))