Spaces:
Build error
Build error
Create apdl_beam.py
Browse files- apdl_generator/apdl_beam.py +32 -0
apdl_generator/apdl_beam.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# apdl_generator/apdl_beam.py
|
| 2 |
+
|
| 3 |
+
def generate_beam_apdl(length, width, thickness, load):
|
| 4 |
+
"""
|
| 5 |
+
Generate APDL script for a beam simulation.
|
| 6 |
+
|
| 7 |
+
Parameters:
|
| 8 |
+
length (float): Length of the beam in mm.
|
| 9 |
+
width (float): Width of the beam in mm.
|
| 10 |
+
thickness (float): Thickness of the beam in mm.
|
| 11 |
+
load (float): Load applied to the beam in N.
|
| 12 |
+
|
| 13 |
+
Returns:
|
| 14 |
+
str: Path to the generated APDL file.
|
| 15 |
+
"""
|
| 16 |
+
# Generate the APDL script for a beam
|
| 17 |
+
apdl_script = f"""
|
| 18 |
+
! APDL script for Beam Simulation
|
| 19 |
+
/PREP7
|
| 20 |
+
BLC4, 0, {length}, {width}, {thickness} ! Create beam geometry
|
| 21 |
+
/SOLU
|
| 22 |
+
F, 1, FX, {load} ! Apply load at node 1
|
| 23 |
+
SOLVE
|
| 24 |
+
FINISH
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
# Save APDL script to a file
|
| 28 |
+
apdl_file_path = "/tmp/generated_beam_apdl.txt"
|
| 29 |
+
with open(apdl_file_path, "w") as f:
|
| 30 |
+
f.write(apdl_script)
|
| 31 |
+
|
| 32 |
+
return apdl_file_path
|