7.1.1. Hello World Example

The following is a basic example showing how structural objects can be loaded and acted on by design codes.

First we import the base limitstates library, and a design library we’re working with, in this case CSA’s S16 steel from 2024. Design libraries are stand-alone modules, and will often be imported separately.

import limitstates as ls
import limitstates.design.csa.s16.c24 as s16

We define some variables that define the element. In this example units will be set later when instantiating the object

L = 6
Fy = 350
sectionName = 'W310x118'

We then define a material and it’s units. In this example we will use a code specific material from our design library, but there are also code - agnostic materials that canbe used from the base library. See object:. We also import a steel section database from the availible databases: . All sections are code-agnostic.

mat = s16.MaterialSteelCsa24(Fy, sUnit='MPa')
steelSections   = ls.getSteelSections(mat, 'csa', 'cisc_12', 'w')
section         = ls.getByName(steelSections, sectionName)

See the getSteelSections() and getSteelSections()

We define a simply supported member for our section using a helper function. Members represent where an element is in space, how many spans it has, it’s support condition, etc. Complicated members, but in this case we are happy to initialize a simply supported member

member = ls.initSimplySupportedMember(L, 'm')

Finally, we define a code specific design element. Elements combine sections and members and there are two type of elements: generic elements, and design elements. Further details about generic elements can be found in the object section. Design elements like the one we will use (BeamColumnSteelCsa24) are found in design libraries, and contain design specific information. In this case, the beam’s lateral support conditon has been set on initialization.

beam = s16.BeamColumnSteelCsa24(member, section)

Once it is defined, we use code checks from the design library on our element. Each code function will return an output with a specific unit set, in this case Nm are returned.

Mr = s16.checkBeamMrSupported(beam) / 1000

The full example is seen below:

"""
The following is a basic example showing how structural objects can be loaded 
and acted on by design codes.

"""

# Import the base library, and the design library to be used
import limitstates as ls
import limitstates.design.csa.s16.c24 as s16

L = 6
Fy = 350
sectionName = 'W310x118'

# Define the material, in this case a code specific steel with Fy = 350 MPa
mat = s16.MaterialSteelCsa24(Fy, sUnit='MPa')

# Define a steel section from a database, in this case a cisc 12 w section.
steelSections   = ls.getSteelSections(mat, 'csa', 'cisc_12', 'w')
section         = ls.getByName(steelSections, sectionName)

# make a member, in this case a simplely supported beam 6m long beam.
member = ls.initSimplySupportedMember(L, 'm')

# Make a element, which the design library can act on.
beam = s16.BeamColumnSteelCsa24(member, section)

# Check capacity assuming it's laterally supported using CSA's s16 standard.
Mr = s16.checkBeamMrSupported(beam) / 1000

# Make a Plot of the Section.
fig, ax = ls.plotElementSection(beam, True)