Skip to content
Marc & Structures
Index

Save your progress

Enter your email and we will send a secure sign-in link. There is no password and the first link creates your account.

Demonstration ~10 min · ~42 min remaining

Parameters, expressions, and validation

Centralize inputs, build verifiable expressions, and reject impossible values.

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.025

Then 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_tip
Practical rules for names
  • Use names that indicate object and quantity: beam_h, not h1.
  • 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 i for 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)/inertia

For the base case, approximately:

ParameterExpected valueInterpretation
inertia4.1667E-6 m⁴Geometric property
uy_ref-3.8095E-4 mSign towards −Y
uy_ref_abs0.381 mmMagnitude of comparison
sigma_ref12.0 MPaRated 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
*ENDIF

The 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

  1. Temporarily change beam_h practically zero.
  2. Run the script.
  3. Check that no geometry is created.
  4. 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.

MAPDL practice

Practice: change one decision, not ten lines

Change one geometry parameter and record your prediction before running.

Execution cycle

  1. 1 Copy 01_start.mac.
  2. 2 Predict sign and order of change.
  3. 3 Edit only the governing parameter.
  4. 4 Run and compare reference with FE.
Evidence to retain

Graduated hints

1 · Concept hint

Separate input, derived value, and decision rule.

2 · Command hint

Centralize inputs before calculating references.

3 · Explained solution

One input block governs geometry, references, and output.

Your reflection stays in this browser.