karthikmn commited on
Commit
623819b
·
verified ·
1 Parent(s): 4f6ea23

Update apdl_generator/apdl_plate.py

Browse files
Files changed (1) hide show
  1. 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
- ! APDL script for Plate Simulation
20
- /PREP7
21
- BLC4, 0, {length}, {width}, {thickness} ! Create plate geometry
22
- ! Create hole if applicable
23
- """
24
-
25
- if hole_diameter > 0:
26
- apdl_script += f"""
27
- CIRC, {length / 2}, {width / 2}, {hole_diameter / 2} ! Create hole in the center
28
- """
29
-
30
- apdl_script += f"""
31
- /SOLU
32
- F, 1, FX, {force} ! Apply force at node 1
33
- SOLVE
34
- FINISH
35
- """
36
-
37
- # Save APDL script to a file
38
- apdl_file_path = "/tmp/generated_plate_apdl.txt"
39
- with open(apdl_file_path, "w") as f:
40
- f.write(apdl_script)
41
-
42
- return apdl_file_path
 
 
 
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"