Examples

Read the Python alongside the calculation's inputs, formulas and results.

Example view
"""Two-panel material estimate with a complete reusable calculation trace."""

from _cso_bindings.geometry import rectangle
from _cso_bindings.material import material as estimate_material
from cso_python import (
    CalculationResults,
    calculation,
    figure,
    section,
    text,
)
from quantities import (
    Density,
    FirstPanelHeight,
    PanelWidth,
    SecondPanelHeight,
    Thickness,
    TotalPanelArea,
)


@calculation(id="two-panel", title="Two-panel material estimate")
@section(id="summary", title="Inputs and totals", root=True)
def estimate(
    width: PanelWidth = 2,
    first_panel_height: FirstPanelHeight = 3,
    second_panel_height: SecondPanelHeight = 4,
    thickness: Thickness = 0.1,
    density: Density = 500,
) -> CalculationResults:
    text(
        id="assumptions",
        content="Rectangular panels; uniform thickness and density; no openings and no waste allowance. This is a material estimate, not a structural capacity calculation.",
    )
    text(
        id="notation",
        content="Symbol subscripts: pan = panel; fp = first panel; sp = second panel; rect = rectangle; tot = total; mat = material.",
    )
    figure(
        id="panels",
        path="panels.svg",
        media_type="image/svg+xml",
        caption="Two rectangular panels with shared width and uniform thickness.",
        alt="Two rectangular panels of shared width w_pan, heights h_fp and h_sp, and uniform thickness t_pan.",
    )

    first_panel = rectangle(width=width, height=first_panel_height)
    second_panel = rectangle(width=width, height=second_panel_height)

    total_area: TotalPanelArea = first_panel["area"] + second_panel["area"]

    material_quantities = estimate_material(
        area=total_area, thickness=thickness, density=density
    )

    return {
        "area": total_area,
        "volume": material_quantities["volume"],
        "mass": material_quantities["mass"],
    }
Calculation document

Two-panel material estimate

Inputs and totals

0. Shared panel width
wpan
2.00
m
1. First panel height
hfp
3.00
m
2. Second panel height
hsp
4.00
m
3. Uniform thickness
tpan
0.10000
m
4. Uniform density
ρmat
500.00
kgm3
Rectangular panels; uniform thickness and density; no openings and no waste allowance. This is a material estimate, not a structural capacity calculation.
Symbol subscripts: pan = panel; fp = first panel; sp = second panel; rect = rectangle; tot = total; mat = material.
Two rectangular panels of shared width w_pan, heights h_fp and h_sp, and uniform thickness t_pan.
Two rectangular panels with shared width and uniform thickness.

Rectangle geometry

5. Panel area
Arect,fp
6.00
m2
Arect,fp
=
wpan⋅hfp
=
2.00⋅3.00
6. Panel perimeter
Prect,fp
10.00
m
Prect,fp
=
2⋅(wpan+hfp)
=
2⋅(2.00+3.00)

Rectangle geometry

7. Panel area
Arect,sp
8.00
m2
Arect,sp
=
wpan⋅hsp
=
2.00⋅4.00
8. Panel perimeter
Prect,sp
12.00
m
Prect,sp
=
2⋅(wpan+hsp)
=
2⋅(2.00+4.00)
9. Total panel area
Atot
14.00
m2
Atot
=
Arect,fp+Arect,sp
=
6.00+8.00

Material volume and mass

10. Material volume
Vmat
1.40
m3
Vmat
=
Atot⋅tpan
=
14.00⋅0.10000
11. Material mass
mmat
700.00
kg
mmat
=
Vmat⋅ρmat
=
1.40⋅500.00