Spaces:
Build error
Build error
Update apdl_generator/apdl_beam.py
Browse files- apdl_generator/apdl_beam.py +22 -30
apdl_generator/apdl_beam.py
CHANGED
|
@@ -1,32 +1,24 @@
|
|
| 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 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
def generate_beam_apdl(length, width, thickness, load):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
apdl_script = f"""
|
| 3 |
+
/PREP7
|
| 4 |
+
MP,EX,1,2E11
|
| 5 |
+
MP,PRXY,1,0.3
|
| 6 |
+
BLOCK,0,{length},0,{width},0,{thickness}
|
| 7 |
+
ET,1,SOLID185
|
| 8 |
+
ESIZE,5
|
| 9 |
+
VMESH,ALL
|
| 10 |
+
NSEL,S,LOC,X,0
|
| 11 |
+
D,ALL,ALL
|
| 12 |
+
NSEL,S,LOC,X,{length}
|
| 13 |
+
F,ALL,FY,-{load}
|
| 14 |
+
/SOLU
|
| 15 |
+
ANTYPE,STATIC
|
| 16 |
+
SOLVE
|
| 17 |
+
/POST1
|
| 18 |
+
PRNSOL,S,EQV
|
| 19 |
+
PRNSOL,U,SUM
|
| 20 |
+
/EXIT
|
| 21 |
+
"""
|
| 22 |
+
with open("beam_simulation.inp", "w") as file:
|
| 23 |
+
file.write(apdl_script)
|
| 24 |
+
return "beam_simulation.inp"
|