karthikmn commited on
Commit
5f197f6
·
verified ·
1 Parent(s): 623819b

Update apdl_generator/apdl_beam.py

Browse files
Files changed (1) hide show
  1. 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
- ! 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
 
 
 
 
 
 
 
 
 
 
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"