In M08, you converted the model into reusable macros. In M09, you will complete the core path
by automating the design decision: sweep several heights with
*DO, consolidate a decision CSV, and select the smallest acceptable section
without touching the GUI.
Your mission
You will evaluate at least three beam heights, validate each case against theory, and automatically choose the smallest beam_h alternative that satisfies deflection, stress, and equilibrium requirements.
Guiding question: can the script decide for you unambiguously?
Objectives
After completing M09, you will be able to:
- Orchestrate a parametric sweep with
*DOand arrays. - Rebuild the model in each iteration without residual state.
- Distinguish
validation_pass(M07–M08) fromfeasible(design limits). - Consolidate one CSV as a decision table.
- Automatically select the acceptable design with the smallest section.
- Demonstrate reproducibility in two clean runs.
- Document assumptions, validation, and limitations in a brief report.
Prerequisites and downloads
- M08: driver with
build,solve, andextractsubmacros. - M07: deflection, interior-stress, and equilibrium tolerances.
- M01: analytical references and design limits (
uy_limit,stress_limit).
09_start.mac— starting point.09_parametric_study.mac— base driver (3 designs).09_parametric_core.mac— sweep core.09_build.mac— rebuild for each case.09_solve.mac— solution.09_extract.mac— per-case validation.09_bug_hunt.mac— five sweep faults.09_challenge.mac— four-design challenge.09_expected_results.csv— self-check contract.09_project_report.md— report template.height-displacement.svg— height–deflection trend.automated-decision-flow.svg— decision flow.
How to use this lesson
| Path | Duration | Coverage |
|---|---|---|
| First win | 30–35 min | Prediction, three-height sweep, and first automatic selection. |
| Complete | 70–75 min | Also: bug hunt, four-design challenge, report, and completion of the core path. |
Session map
- Mission: objectives, downloads, and prediction for three heights.
- Mental model: automate the decision, not just the calculation.
- Demonstration: criteria, residual-state-free sweep, CSV, and selection.
- Bug hunt: residual state, mixed verdicts, and incorrect selection.
- Challenge: four designs and reproducibility in two clean runs.
- Mastery: final test completing the M00–M09 core path.
Prediction — Three heights, three decisions
With b = 0.05 m, L = 1 m, E = 210 GPa, and F = −1000 N:
I = b·h³/12
uy_ref = F·L³/(3·E·I)
sigma_ref = F·(0.8L)·(h/2)/I ! interior section| Case | h (m) | mesh_h (m) | |uy_ref| (mm) | σ_ref (MPa) | Acceptable (analytical) |
|---|---|---|---|---|---|
| 1 | 0.08 | 0.04 | 0.744 | 15.0 | no (> 0.25 mm) |
| 2 | 0.10 | 0.05 | 0.381 | 9.6 | no |
| 3 | 0.12 | 0.06 | 0.220 | 6.9 | yes |
The analytical prediction already rejects the first two designs. The FE sweep must confirm this with validation_pass and mark only case 3 as feasible.
Mental model — Automate the decision, not just the calculation
validation_pass and feasible answer different questions.A sweep that only prints contours does not automate decisions. You need a table with explicit verdicts and a selection rule that is readable in the script: the smallest acceptable beam_h.
Step 1 — Define inputs and criteria
beam_l=1.0
beam_b=0.05
young=210E9
tip_force=-1000
uy_limit=0.00025 ! 0.25 mm
stress_limit=150E6 ! 150 MPa
n_cases=3Document SI units and limits before the *DO. FE validation criteria (deflection versus analytical result, equilibrium) remain those from M07–M08; design criteria (uy_limit, stress_limit) are additional.
Step 2 — Sweep with *DO and no residual state
*DO,case_id,1,n_cases
! set beam_h and mesh_h = h/2
/INPUT,09_build,mac,,,,1
/INPUT,09_solve,mac,,,,1
/INPUT,09_extract,mac,,,,1
! store results in arrays
*ENDDOEach iteration must rebuild the geometry and mesh. In 09_build.mac, clear the previous mesh with VCLEAR and VDELE before creating a new BLOCK. Without that cleanup, the second case fails with “Volume is meshed and cannot be changed.”
Step 3 — CSV as a decision table
*CFOPEN,m09_results,csv
*VWRITE
('case_id,beam_h,...,validation_pass,feasible')
*DO,i,1,n_cases
*VWRITE,i,h_store(i),...,val_pass_store(i),feasible_store(i)
*ENDDO
*CFCLOSOnly the driver writes the CSV. If each submacro writes its own file, the last iteration overwrites the preceding ones and the selection loses its meaning.
Step 4 — Select the smallest suitable design
selected_case=0
selected_h=0
*DO,i,1,n_cases
*IF,feasible_store(i),EQ,1,THEN
*IF,selected_case,EQ,0,THEN
selected_case=i
selected_h=h_store(i)
*ELSE
*IF,h_store(i),LT,selected_h,THEN
selected_case=i
selected_h=h_store(i)
*ENDIF
*ENDIF
*ENDIF
*ENDDOFor the base sweep, the expected selection is selected_case=3, selected_h=0.12 m. Also check the trend: |uy(i+1)| < |uy(i)| as height increases.
Bug hunt
Open 09_bug_hunt.mac. It contains five common parametric-sweep defects:
| Error | Symptom | Check | Cause | Minimum fix |
|---|---|---|---|---|
| 1 | Impossible topology | Node counts | No rebuild between cases | VCLEAR + VDELE in build |
| 2 | Single-row CSV | Output file | CSV written in extract | Write only from the driver |
| 3 | h=0.08 selected | feasible | Confused with validation_pass | Filter by design limits |
| 4 | Inconsistent loop | /STATUS,PARM | /CLEAR inside *DO | Clear geometry, not the session |
| 5 | h=0.14 selected | selected_h | Largest acceptable height chosen | min(beam_h) with feasible=1 |
Verifiable challenge — Four designs, two runs
Run the base sweep twice from clean sessions and compare m09_results.csv. Then add a fourth design without duplicating construction or solution blocks:
/CLEAR,START
/FILNAME,m09_challenge,1
/UNITS,SI
n_cases=4
/INPUT,09_parametric_core,macThe fourth case (h = 0.14 m) is also analytically acceptable, but the selection must remain h = 0.12 m because it is the smallest suitable section.
Self-assessment
What is the difference between validation_pass and feasible?
validation_pass confirms that the FE model is consistent (topology, equilibrium, analytical comparison). feasible adds the deflection and stress design limits.
Why rebuild the model in each iteration?
Because accumulated geometry or residual selections contaminate later cases and break sweep reproducibility.
Which design should the base sweep select?
Case 3, h = 0.12 m: it is the first to satisfy |uy| ≤ 0.25 mm and is the smallest acceptable height among the three evaluated.
Where should m09_results.csv be written?
In the driver, after the sweep completes. A single write point prevents partial overwrites.
What do you check in addition to the design limits?
The physical trend: as h increases, tip deflection magnitude must decrease.
Learning evidence
09_parametric_study.macdriver with a three-design sweep.09_build,09_solve, and09_extractsubmacros.m09_results.csvwithvalidation_pass,feasible, and selection.- Completed height–displacement plot and brief report.
- Reproducibility demonstrated in two clean runs.
- Four-design challenge with consistent selection (
h = 0.12 m).
Exit checklist
- ☐ I documented inputs, units, and design limits.
- ☐ I implemented a
*DOsweep without residual state. - ☐ I distinguished
validation_passfromfeasible. - ☐ I wrote one consolidated CSV from the driver.
- ☐ I selected the acceptable
min(beam_h). - ☐ I verified the physical deflection trend.
- ☐ I repeated the run from a clean session.
- ☐ I completed the brief project report.
Technical traceability
This lesson uses the 2024 R1 Command Reference for *DO, *DIM, *CFOPEN, *VWRITE, and /INPUT, and inherits validation tolerances from M07–M08. Validated in MAPDL Student 2025 R2 (v252) with KEYOPT(2)=3.
Completing the core path
After completing M09, you will have covered M00–M09: from the first reproducible simulation to an automated project with a verifiable decision. Specializations M10–M17 expand the physics and advanced techniques, but the course's core path ends here.