Step 1 — Find the magic numbers
Open 01_start.mac. You'll find expressions like:
MP,EX,1,210E9
BLOCK,0,1.0,0,0.10,0,0.05
ESIZE,0.025
F,ALL,FY,-1000/n_tip
The values are not incorrect, but their meaning is hidden and they appear within the instructions.
Changing the length requires finding each occurrence of 1.0 and deciding whether it represents length,
coordinate or anything else.
Gather the entries at the beginning:
! --- INPUTS: SI units ---
beam_l=1.0
beam_h=0.10
beam_b=0.05
young=210E9
nu=0.30
tip_force=-1000
mesh_h=0.025Then replace the physical numbers:
MP,EX,1,young
MP,PRXY,1,nu
BLOCK,0,beam_l,0,beam_h,0,beam_b
ESIZE,mesh_h
NSEL,S,LOC,X,beam_l
F,ALL,FY,tip_force/n_tipPractical rules for names
- Use names that indicate object and quantity:
beam_h, noth1. - Preserves a language and style throughout the project.
- Do not encode different units within the name if the entire contract uses a consistent system.
- Reserve names such as
ifor short loop indices. - Do not reuse an input parameter to store a result.
Step 2 — Build verifiable expressions
Calculate the inertia first:
inertia=beam_b*beam_h**3/12
In APDL, ** represents power. beam_h*3 is not an alternative form:
is another operation.
Add references:
uy_ref=tip_force*beam_l**3/(3*young*inertia)
uy_ref_abs=ABS(uy_ref)
sigma_ref=ABS(tip_force)*beam_l*(beam_h/2)/inertiaFor the base case, approximately:
| Parameter | Expected value | Interpretation |
|---|---|---|
inertia | 4.1667E-6 m⁴ | Geometric property |
uy_ref | -3.8095E-4 m | Sign towards −Y |
uy_ref_abs | 0.381 mm | Magnitude of comparison |
sigma_ref | 12.0 MPa | Rated bending stress |
The Millimeter Trap
If you write beam_h=100 within this model, MAPDL doesn't know what you meant
100 mm. It will interpret 100 meters. /UNITS,SI documents the convention, but does not convert inputs.
Step 3 — Reject invalid inputs
Wait until VMESH to discover that a dimension is zero produces messages far from the cause.
It is better to check the contract immediately:
*IF,beam_h,LE,0,THEN
/COM,ERROR: beam_h must be positive
/EOF
*ENDIF
*IF,mesh_h,GT,beam_h/2,THEN
/COM,WARNING: mesh_h is larger than beam_h/2
*ENDIFThe first block represents an error that prevents you from continuing. The second is a warning: the model can be executed, but cross discretization deserves attention.
Controlled Experiment
- Temporarily change
beam_hpractically zero. - Run the script.
- Check that no geometry is created.
- Restaura.
beam_h=0.10.
Don't celebrate that MAPDL “failed correctly.” Celebrate that your program spotted the issue before handing over absurd data to the modeler.