Python examples
The scripts in the console's Examples… menu. Each link below opens the app with that script in the console's editor; press Run. Every number they print comes from the engine or from a design clause the script cites.
The examples#
| Example | Runtime | Draws | Open it |
|---|---|---|---|
| Search: the lightest lipped C for a load | MicroPython | section, signature curve | ?py=lightest_section.py |
| Catalogue check: 12 sections against a load | MicroPython | signature curve | ?py=catalogue_check.py |
| DSM design study: lip depth | MicroPython | signature curve | ?py=dsm_lip_study.py |
| End conditions: S-S, C-C, S-C, C-F, C-G | MicroPython | two mode shapes | ?py=end_conditions.py |
| Distortional mode and sheathing springs | MicroPython | section, curves, mode | ?py=distortional_mode.py |
| cufsm-rs-py README quickstart, verbatim | full Python: numpy, matplotlib (25.6 MB the first time) | section, signature, mode (matplotlib) | ?py=full/readme_quickstart.py |
| Lip study, plotted | full Python: numpy, matplotlib (25.6 MB) | two matplotlib charts | ?py=full/lip_study_plots.py |
| Lightest section: numpy design space, scipy | full Python: numpy, scipy, matplotlib (38.9 MB) | a matplotlib scatter | ?py=full/lightest_numpy.py |
The download sizes are for a device with no full Python yet (the download prompt).
Every MicroPython example also runs on full Python and, with pip install "cufsm-rs-py[plot]" and
dsm.py beside it, on your own machine. The parity suite runs each example on
MicroPython, full Python and CPython with pip, and compares the numbers.
What is not verified#
The design examples apply the Direct Strength Method (AISI S100-16 Chapter E) through
dsm.py. Two parts of it are marked in the scripts as not checked against the standard,
and the scripts print the notes:
- The DSM pre-qualified limits (
dsm.prequalified), which decide where φc = 0.85 applies. The lightest-section searches and the catalogue check end with: Note: the DSM pre-qualified limits used here (AISI S100-16 Table B4.1-1) are UNVERIFIED: written from recollection, not checked against the standard. - The D-only Pcrd (
dsm.d_only). Where the signature curve has no distinct distortional minimum, Pcrd comes from a constrained cFSM analysis restricted to the distortional space (strip(..., spaces="D"), at the same half-wavelengths, its lowest minimum). The script says AISI's DSM allows this (S100-16 commentary on Appendix 2, as recalled: the clause reference is not checked against the text), and the plotted lip study prints Pcrd marked D-only comes from a constrained cFSM run (dsm.d_only): the DSM commentary reference for that is recalled, UNVERIFIED against the text. Results that use it are markedcFSM D-onlyor(Pcrd D-only).
Check both before relying on a pass. The examples show what a script can do; they are not design software.
Search: the lightest lipped C for a load#
lightest_section.py · MicroPython · open in the console
A continuously braced column (Le = 0, so no global buckling) must carry φc Pn ≥ 80 kN at fy = 450 MPa. The script
tries lipped Cs over sets of depth (100 to 250 mm), flange (50 to 90 mm), lip (0.15 to 0.40 of the flange) and
thickness (1.0 to 2.4 mm), keeps those inside the DSM pre-qualified limits, and for each runs the signature curve, picks
the local and distortional minima with cFSM and works the DSM strength. It goes thickness by thickness, lightest first,
and prints the lightest pass at each, then the winner, checked again on a finer grid, its section and its classified
signature curve. What a script does that the GUI cannot: a hundred and more analyses in a loop, each feeding a design
check. Change TARGET, FY or the sets and run it again.
Catalogue check: 12 sections against a load#
catalogue_check.py · MicroPython · open in the console
Twelve lipped Cs, each given by its depth, flange, lip and thickness, checked as continuously braced columns against
N* = 60 kN. It prints a pass/fail table sorted by mass, with Pnl, Pnd, φc Pn, the utilisation and the governing mode,
and draws the classified signature curve of the lightest that passes. The sections are generic sizes with names in
the common "depth, thickness" style, not any manufacturer's catalogue: put your supplier's dimensions in
SECTIONS to check theirs.
DSM design study: lip depth#
dsm_lip_study.py · MicroPython · open in the console
A 150 × 64 × 1.5 mm lipped C column, continuously braced, with the lip swept from 8 to 24 mm. For each lip: the signature curve, its local and distortional minima (cFSM), and the DSM strengths (§E2 Pne = Py when braced, §E3 local, §E4 distortional). It prints the elastic buckling table and the strength table, reports the lip with the highest strength per unit of steel, and draws that lip's signature curve with the minima classified.
End conditions: S-S, C-C, S-C, C-F, C-G#
end_conditions.py · MicroPython · open in the console
The signature curve assumes simply supported ends and one half-wave; real members are fixed, free or guided at their ends. A 150 × 64 × 18 × 2.4 mm lipped C at 1000, 2000 and 3000 mm is solved with CUFSM's general end conditions (pinned-pinned, fixed-fixed, pinned-fixed, fixed-free, fixed-guided) with enough longitudinal terms to reach local buckling's short half-waves. For each it prints Pcr, what cFSM says the mode is and which term carries most of it, and it ends with the mode shapes of the weakest and strongest ends at the longest length. The heaviest example: 15 coupled solves of up to 30 terms each, which the script puts at about 10 to 25 seconds in the page.
Distortional mode and sheathing springs#
distortional_mode.py · MicroPython · open in the console
Part 1 opens up the distortional mode of a 150 × 64 × 15 × 1.5 mm lipped C with
mode_shape(...).at(): which nodes move most, and how the flange and lip rotate about the web-flange corner.
Part 2 adds a continuous rotational spring at both flange-web corners, as sheathing gives, and sweeps its stiffness
until the distortional minimum disappears from the curve. It draws the section, the curve, the mode, and the curve
once the spring has removed the distortional minimum.
cufsm-rs-py README quickstart, verbatim#
full/readme_quickstart.py · full Python (numpy, matplotlib) · open in the console
The package README's quickstart as published, from import numpy as np to plot_mode:
CUFSM's tutorial C in inches and ksi, its properties, first yield, signature curve, minima and classification,
strip with several modes, a pure distortional run, general end conditions and lipped_c.
After it, a few print lines show the values the README's comments describe, and plt.show()
puts the three matplotlib figures in the output. The same script, with the same numbers, as on your own machine.
Lip study, plotted#
full/lip_study_plots.py · full Python (numpy, matplotlib) · open in the console
The DSM lip study with charts of its own: all nine lips' signature curves on one log-x axes, each lip's local and distortional minima marked; then Pn/A and Pn against lip depth, the governing mode marked, and the best lip by the lip study's rule (the shortest within 0.5 % of the top Pn/A).
Lightest section: numpy design space, scipy#
full/lightest_numpy.py · full Python (numpy, scipy, matplotlib) · open in the console
The lightest-section search with what full Python adds: numpy builds the whole design space as arrays and applies
the pre-qualified limits as masks; every analysed section's mass and φc Pn go on a scatter chart, passes against
fails, with the target and the winner marked; and scipy.optimize.brentq finds the thickness at which the
winner's shape exactly carries the target, each trial an engine run and a DSM check, to show how much of the chosen
gauge is margin.
dsm.py: the shared DSM module#
Not a script on its own: the lipped C builder and the DSM column strength that the design examples import
(import dsm). The console installs it, so your own scripts can import it too; on your own machine keep it
next to the script. Its DSM equations and the rule that picks the local and distortional minima are ported clause by
clause from the DSM compression module; every buckling load
comes from the engine. Its names:
| Name | What it does |
|---|---|
lipped_c(D, B, d, t, n_web=8, n_flange=4, n_lip=2) | A lipped C on its centreline with square corners, from out-to-out D, B, d and thickness t (mm), E = 200000 MPa, ν = 0.3. |
column(model, fy, lengths) | Py, the local and distortional minima and the DSM strengths of a continuously braced column: a dict with Py, A, local, dist, dist_src, sig, ref, Pnl, Pnd, Pn, governs. |
d_only(ref, lengths) | Pcrd from a D-only constrained run where the curve has no distinct distortional minimum (not verified). |
prequalified(D, B, d, t, fy) | The reasons a lipped C is outside the DSM pre-qualified column limits, [] inside (not verified). |
dsm_pne, dsm_pnl, dsm_pnd | AISI S100-16 §E2, §E3, §E4. |
logspace(a, b, n), grid_minima(L, f), PHI_C | n log-spaced values; a curve's minima as the page finds them; φc = 0.85. |