Computational Engineering / Programming and automation for engineers
The vocabulary, and what each idea buys
Use names that explain the engineering quantities.
Lesson review: expert verification remains open
This lesson has received a full-context editorial review and a check of its technical explanations. Selected arithmetic has been checked separately. This is not independent engineering sign-off.
Checks needed for project use
- A computational engineering reviewer must check algorithms, convergence claims, statistical assumptions and numerical examples beyond the cases explicitly recorded.
- Review automation specification, tests, spreadsheet dependencies and change control.
These are educational models and exercises. Check their assumptions before using the results. The full technical content and every diagram have not yet been independently verified.
Concrete and steel calculations retain their stated first-generation Eurocode teaching basis. Use the standards and amendments specified for your project; do not mix generations without an appropriate design basis.
Read the lesson register and outstanding review notesWhy this matters
A short script can generate a beam’s nodes and load cases. Naming its inputs and testing its boundaries makes that procedure understandable and reviewable.
Five nodes need four equal intervals
- Upper row
- Coordinates 0, 2.5, 5, 7.5 and 10 m include both ends.
- Lower row
- Coordinates 0, 2, 4, 6 and 8 m omit the far endpoint.
Read a program as a calculation procedure
A variable names a value. A condition chooses a branch, and a loop repeats a defined operation. A function groups a calculation behind explicit inputs and outputs. A data structure organises related information, such as members or load cases.
These ideas become concrete when generating nodes along a beam. Decide whether the input means the number of intervals or the number of nodes: n intervals need n + 1 nodes to include both ends. Test the first and last coordinates and the spacing, rather than checking only a middle node.
Specify what happens at a limit or invalid input. A sizing function needs a defined response when no catalogue section passes. Keep a known-answer case for each important calculation and rerun it after changes. Tests provide evidence for those cases; review the algorithm and assumptions as well.
Try it
Sequence, condition, loop
A member-sizing routine, assembled from its steps. Reorder it or break a condition, and read what the routine would then return.
Break a condition
Each of these is a one-character change in real code.
Use the up and down buttons beside each step to reorder the routine. Everything here works from the keyboard; nothing requires dragging.
- 1Read the inputsSpan, load, deflection limit, catalogue.
- 2Compute the design momentM = wL²/8 for this case.
- 3Sort the catalogue by massLightest first, so the first pass is the lightest that works.
- 4Loop through the catalogueOne section at a time.
- 5Check strengthIs the moment resistance at least the design moment?
- 6Check deflectionIs the deflection under the limit?
- 7Return the first section that passes bothAnd stop.
- 8If none passes, say soDo not return the last one tried.
The routine is in a working order with sound conditions. It returns the lightest section that satisfies both checks, and says so when none does.
What this shows: A broken routine does not usually crash. It returns a plausible number, which is why a test with a known answer is the only real check.
Check yourself
A colleague's script sizes beams by looping through a catalogue and returning the first section that passes. It has no tests. What is the most useful thing to do before relying on it?
Worked example
Reading a loop that runs one time too few
Given
- A script places nodes along a beam:
for i in range(n): x = i * L / n - It is asked for 5 nodes on a 10 m beam
Find
What it produces, and whether the error is visible
Worked example
A condition using the wrong scale
Given
- A script flags members whose utilisation exceeds 1.0:
if utilisation > 1.0: flag(member) - Utilisation is computed as a percentage elsewhere in the script
Find
What the script reports, and how it would be noticed
Practice
A loop for i in range(n) with x = i * L / n is asked for 5 nodes on a 10 m beam. What is the coordinate of the last node it produces, in metres?
Check yourself
How can a wrong condition hide an error even when the reported calculations are correct?
Check yourself
What should a script that generates a model always report back?
Summary
- Use names that explain the engineering quantities.
- Test boundaries and invalid inputs.
- Distinguish a node count from an interval count.
Sources & further information
The diagrams and worked explanations are original teaching material. Equations follow the stated idealisations; their assumptions and units are given with each calculation.
Reviewed 19 October 2026: explanations, teaching calculations and figures checked within the recorded course audit. This is not independent engineering approval. Review automation specification, tests, spreadsheet dependencies and change control.