Spaces:
Build error
Build error
Update apdl_generator/apdl_plate.py
Browse files- apdl_generator/apdl_plate.py +24 -40
apdl_generator/apdl_plate.py
CHANGED
|
@@ -1,42 +1,26 @@
|
|
| 1 |
-
# apdl_generator/apdl_plate.py
|
| 2 |
-
|
| 3 |
def generate_plate_apdl(thickness, length, width, hole_diameter, force):
|
| 4 |
-
"""
|
| 5 |
-
Generate APDL script for a plate with an optional hole.
|
| 6 |
-
|
| 7 |
-
Parameters:
|
| 8 |
-
thickness (float): Thickness of the plate in mm.
|
| 9 |
-
length (float): Length of the plate in mm.
|
| 10 |
-
width (float): Width of the plate in mm.
|
| 11 |
-
hole_diameter (float): Diameter of the hole (0 if no hole).
|
| 12 |
-
force (float): Force applied to the plate in N.
|
| 13 |
-
|
| 14 |
-
Returns:
|
| 15 |
-
str: Path to the generated APDL file.
|
| 16 |
-
"""
|
| 17 |
-
# Generate the APDL script for a plate
|
| 18 |
apdl_script = f"""
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
return
|
|
|
|
|
|
|
|
|
|
| 1 |
def generate_plate_apdl(thickness, length, width, hole_diameter, force):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
CYLIND,0,{hole_diameter/2},0,0,{thickness}
|
| 8 |
+
VSUB,ALL
|
| 9 |
+
ET,1,SOLID185
|
| 10 |
+
ESIZE,5
|
| 11 |
+
VMESH,ALL
|
| 12 |
+
NSEL,S,LOC,Z,0
|
| 13 |
+
D,ALL,ALL
|
| 14 |
+
NSEL,S,LOC,Z,{thickness}
|
| 15 |
+
F,ALL,FY,-{force}
|
| 16 |
+
/SOLU
|
| 17 |
+
ANTYPE,STATIC
|
| 18 |
+
SOLVE
|
| 19 |
+
/POST1
|
| 20 |
+
PRNSOL,S,EQV
|
| 21 |
+
PRNSOL,U,SUM
|
| 22 |
+
/EXIT
|
| 23 |
+
"""
|
| 24 |
+
with open("plate_simulation.inp", "w") as file:
|
| 25 |
+
file.write(apdl_script)
|
| 26 |
+
return "plate_simulation.inp"
|