### Install uv Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Use the standalone installer to set up the uv project manager. ```shell curl -LsSf https://astral.sh/uv/install.sh | sh ``` -------------------------------- ### Install project extras Source: https://github.com/robbievanleeuwen/section-properties/blob/master/CONTRIBUTING.md Install specific or all optional dependencies using the sync command. ```shell uv sync --extra numba uv sync --all-extras ``` -------------------------------- ### Install sectionproperties using pip Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/index.rst Install the sectionproperties package from PyPI using pip. ```shell pip install sectionproperties ``` -------------------------------- ### Install Python with uv Source: https://github.com/robbievanleeuwen/section-properties/blob/master/CONTRIBUTING.md Install a specific version of Python using the uv manager. ```shell uv python install 3.14 ``` -------------------------------- ### Install sectionproperties with DXF support Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst To enable DXF file import functionality, install the sectionproperties library with the 'dxf' extra. ```shell pip install sectionproperties[dxf] ``` -------------------------------- ### Sync project dependencies Source: https://github.com/robbievanleeuwen/section-properties/blob/master/CONTRIBUTING.md Install project dependencies and development tools. ```shell uv sync ``` -------------------------------- ### Install sectionproperties with Numba Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/installation.rst Installs the package with Numba support to enhance the performance of analysis functions. ```shell pip install sectionproperties[numba] ``` -------------------------------- ### Configure Python and Dependencies Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Install the required Python version and project dependencies. ```shell uv python install 3.14 ``` ```shell uv sync ``` ```shell uv sync --extra numba uv sync --all-extras ``` -------------------------------- ### Install sectionproperties with Rhino support Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst To enable Rhino file import functionality, install the sectionproperties library with the 'rhino' extra. ```shell pip install sectionproperties[rhino] ``` -------------------------------- ### Install sectionproperties with PARDISO solver Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/installation.rst Installs the package with the PARDISO solver for improved performance on large matrices. Requires MKL and is limited to Linux and Windows. ```shell pip install sectionproperties[pardiso] ``` -------------------------------- ### Install sectionproperties with CAD support Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/installation.rst Installs additional dependencies for importing DXF or Rhino 3DM files. ```shell pip install sectionproperties[dxf] pip install sectionproperties[rhino] ``` -------------------------------- ### Run Example Section Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/trapezoidal_torsion.ipynb Executes the analysis for a specific trapezoidal section and prints the results. ```python b, s = 4.0, 0.3 jt, jr, d1, d2 = do_section(b=b, s=s, plot_geom=True) print(f"{b=:.1f}; {s=:.1f}; {jr=:.3f}; {jt=:.3f}; {jr/jt=:.3f}") ``` -------------------------------- ### Manage Pre-commit Hooks Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Run pre-commit checks manually or install the git hook. ```shell uv run pre-commit run --all-files ``` ```shell uv run pre-commit install ``` -------------------------------- ### Run Analysis Script Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/export_fibre_section.ipynb Executes the suanPan analysis if the software is installed. ```python # from os.path import exists # write the fibre section to a file with material tag replaced # uncomment below to write file # with open('200UB25.4.sp', 'w') as f: # f.write(commands) # run the analysis # if which("suanpan") is not None: # from subprocess import run # result_available = True # run(["suanpan", "-f", "torsion_analysis.sp"]) # else: # result_available = exists("R1-RF42.txt") # print("suanPan is not installed.") result_available = False ``` -------------------------------- ### Create Geometry from Shapely Polygon Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Instantiate a Geometry object directly from a shapely Polygon. Ensure shapely is installed. ```python from shapely import Polygon from sectionproperties.pre import Geometry poly = Polygon([(0, 0), (5, 2), (3, 7), (1, 6)]) geom = Geometry(geom=poly) geom.plot_geometry() ``` -------------------------------- ### Build Documentation Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Generate the project documentation locally using Sphinx. ```shell uv run sphinx-build docs docs/_build ``` -------------------------------- ### Initialize Analysis Parameters Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/rectangle_torsion.ipynb Sets up the range of aspect ratios using logspace and initializes storage for results. ```python import numpy as np # list of aspect ratios to analyse (10^0 = 1 to 10^1.301 = 20) # logspace used to concentrate data near aspect ratio = 1 aspect_ratios = np.logspace(0, 1.301, 50) torsion_constants = [] # list of torsion constant results area = 1 # cross-section area n = 100 # approximate number of finite elements in each analysis ``` -------------------------------- ### GET /stress/all Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/results.rst Retrieves all calculated stresses within the cross-section, grouped by material. ```APIDOC ## GET /stress/all ### Description Returns a comprehensive data structure containing all stresses within the cross-section, organized by material. Must be called after a stress analysis. ### Method GET ### Response #### Success Response (200) - **data** (object) - Data structure containing stress results grouped by material ``` -------------------------------- ### Initialize Loop Variables Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/trapezoidal_torsion.ipynb Sets up the ranges for width and slope to iterate through different section configurations. ```python b_list = np.logspace(0, np.log10(10.0), 10) s_list = np.linspace(0.0, 1.0, 10) j_rect = np.zeros((len(b_list), len(s_list))) j_trap = np.zeros((len(b_list), len(s_list))) ``` -------------------------------- ### GET /section/properties/composite Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/results.rst Retrieves modulus-weighted centroidal second moments of area for composite sections. ```APIDOC ## GET /section/properties/composite ### Description Retrieves the modulus-weighted centroidal second moments of area. If a reference elastic modulus (e_ref) is provided, it returns the transformed second moment of area. ### Method GET ### Parameters #### Query Parameters - **e_ref** (float) - Optional - The reference elastic modulus used to transform the section properties. ### Request Example GET /section/properties/composite?e_ref=200000 ### Response #### Success Response (200) - **ei_gross** (float) - The modulus-weighted centroidal second moment of area. ``` -------------------------------- ### Create Mesh and Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Generate a mesh for the geometry and initialize the Section object. ```python from sectionproperties.analysis import Section geom.create_mesh(mesh_sizes=0.1) sec = Section(geometry=geom) sec.plot_mesh() ``` -------------------------------- ### GET /stress/points Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/results.rst Retrieves numerical stress values at specific coordinate points within the cross-section. ```APIDOC ## GET /stress/points ### Description Obtains the stress values at one or multiple specified points. Requires prior geometric and (if shear/torsion is present) warping analysis. ### Method GET ### Query Parameters - **points** (list) - Required - List of (x, y) coordinates to query ### Response #### Success Response (200) - **stresses** (list) - List of stress values corresponding to the requested points ``` -------------------------------- ### Create Geometry and Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/display_results.ipynb Demonstrates creating a circular hollow section and its mesh, then initializing a Section object. Plots the mesh for visualization. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import circular_hollow_section geom = circular_hollow_section(d=165.1, t=5.4, n=64) geom.create_mesh(mesh_sizes=10) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Create Hollow Polygonal Section Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/frame_analysis.ipynb Creates a 12-sided hollow polygonal section geometry and its mesh. Ensure the 'sectionproperties' library is installed. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import polygon_hollow_section geom = polygon_hollow_section(d=600, t=12, n_sides=12, r_in=20, n_r=8) geom.create_mesh(mesh_sizes=20) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Run Benchmarks Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Execute specific benchmarking suites for geometry, meshing, or analysis. ```shell uv run pytest -m benchmark_geom uv run pytest -m benchmark_mesh uv run pytest -m benchmark_analysis ``` -------------------------------- ### Create Mesh and Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/advanced_plot.ipynb Generates a mesh for the geometry and initializes the Section object. ```python from sectionproperties.analysis import Section geom.create_mesh(mesh_sizes=[5]) sec = Section(geometry=geom) ``` -------------------------------- ### Get Transformed Section Properties Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/composite_analysis.ipynb Retrieves transformed second moments of area with respect to a specified reference material (e.g., timber or steel). ```python ixx_timber, _, _ = sec.get_eic(e_ref=timber) ixx_steel, _, _ = sec.get_eic(e_ref=steel) print(f"Ixx,t = {ixx_timber:.3e} mm4") print(f"Ixx,s = {ixx_steel:.3e} mm4") ``` -------------------------------- ### Run Type Checking Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Execute pyright to perform static type analysis on the project files. ```shell uv run pyright ``` -------------------------------- ### Assign Materials to CompoundGeometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/assign_materials.ipynb Materials must be assigned to individual Geometry objects before they are combined into a CompoundGeometry. This example creates a beam with steel plates using predefined materials. ```python # create a timber material timber = Material( name="Timber", elastic_modulus=8e3, poissons_ratio=0.35, density=6.5e-7, yield_strength=20, color="burlywood", ) # create individual geometries with material properties applied beam = rectangular_section(d=35, b=170, material=timber) plate1 = rectangular_section(d=35, b=16, material=steel) plate2 = rectangular_section(d=35, b=16, material=steel) # combine geometries, maintaining assigned materials geom = ( beam + plate1.align_to(other=beam, on="left") + plate2.align_to(other=beam, on="right") ) # mesh and plot geom.create_mesh(mesh_sizes=[20, 10, 10]) Section(geometry=geom).plot_mesh() ``` -------------------------------- ### Get Stresses at Specific Points for Z-Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/peery.ipynb Applies biaxial bending moments (mxx, myy) to the Z-section and calculates stresses at specified points (A, B, C) using get_stress_at_points. ```python pt_a = (-5, 4) pt_b = (-5, 6) pt_c = (1, 6) stresses = sec.get_stress_at_points(pts=[pt_a, pt_b, pt_c], mxx=-1e5, myy=1e4) ``` -------------------------------- ### Execute Main Analysis Loop Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/trapezoidal_torsion.ipynb Iterates through the defined ranges to populate the torsion constant matrices. ```python for i, b in enumerate(b_list): for j, s in enumerate(s_list): jt, jr, d1, d2 = do_section(b=b, s=s) j_trap[i][j] = jt j_rect[i][j] = jr ``` -------------------------------- ### Get Modulus Weighted Second Moments of Area Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/composite_analysis.ipynb Retrieves the modulus-weighted second moments of area for a composite section. A reference elastic modulus can be provided to obtain transformed properties. ```python # get modulus weighted second moments of area eixx, eiyy, eixy = rect_sec.get_eic() print(f"E.Ixx = {eixx:.5e} N.mm2") # use reference elastic modulus to get transformed properties ixx, iyy, ixy = rect_sec.get_eic(e_ref=steel) print(f"Ixx = {ixx:.5e} mm4") ``` -------------------------------- ### Change Materials in CompoundGeometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/assign_materials.ipynb Materials can be changed in a CompoundGeometry after its creation by iterating through its constituent Geometry objects and assigning new materials. This example shows changing materials for two rectangular sections. ```python # create CompoundGeometry without materials rect1 = rectangular_section(d=10, b=10) rect2 = rectangular_section(d=20, b=20).align_to(other=rect1, on="right") geom = rect1 + rect2 geom.create_mesh(mesh_sizes=[1]) Section(geometry=geom).plot_mesh() # create list of materials mat_list = [steel, timber] ``` -------------------------------- ### Initialize Section Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Creates a finite element mesh and initializes the Section object for analysis. ```python from sectionproperties.analysis import Section geom.create_mesh(mesh_sizes=5) sec = Section(geometry=geom) ``` -------------------------------- ### Create Channel Section Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Initializes a 150PFC channel section and displays its geometry. ```python from sectionproperties.pre.library import channel_section # create 150 pfc geometry pfc = channel_section(d=150, b=75, t_f=9.5, t_w=6, r=10, n_r=8) pfc.plot_geometry(legend=False) ``` -------------------------------- ### Assign Material to Library Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/assign_materials.ipynb When creating geometries from the section library (e.g., polygon_hollow_section), pass the desired Material object to the material argument. This example uses a hollow polygon section. ```python from sectionproperties.pre.library import polygon_hollow_section geom = polygon_hollow_section(d=200, t=6, n_sides=8, r_in=20, n_r=12, material=steel) geom.create_mesh(mesh_sizes=10) Section(geometry=geom).plot_mesh() ``` -------------------------------- ### Initialize Geometry and Mesh Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/plot_stress.ipynb Create an elliptical section and generate its mesh. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import elliptical_section geom = elliptical_section(d_x=75, d_y=150, n=64) geom.create_mesh(mesh_sizes=20) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Create Rectangular Section Geometry and Mesh Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/get_stress.ipynb Initializes a 100mm x 100mm rectangular section and generates a mesh for analysis. ```python from sectionproperties.pre.library import rectangular_section geom = rectangular_section(d=100, b=100) geom.create_mesh(mesh_sizes=50) sec = Section(geometry=geom) ``` -------------------------------- ### Geometry Object Creation Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Demonstrates how to create Geometry objects from Shapely Polygons and CompoundGeometry objects from multiple Geometry objects. ```APIDOC ## Geometry Object Creation from Shapely ### Description Creates a `Geometry` object directly from a shapely `Polygon`. ### Method `Geometry.__init__` ### Endpoint N/A (Class constructor) ### Request Example ```python from shapely import Polygon from sectionproperties.pre import Geometry poly = Polygon([(0, 0), (5, 2), (3, 7), (1, 6)]) geom = Geometry(geom=poly) ``` ## CompoundGeometry Object Creation ### Description Creates a `CompoundGeometry` object by combining multiple `Geometry` objects. ### Method `CompoundGeometry.__init__` ### Endpoint N/A (Class constructor) ### Request Example ```python from shapely import Polygon from sectionproperties.pre import Geometry, CompoundGeometry sq1 = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) sq2 = Polygon([(2, 0), (6, 0), (6, 4), (2, 4)]) geom_sq1 = Geometry(geom=sq1) geom_sq2 = Geometry(geom=sq2) geom = CompoundGeometry(geoms=[geom_sq1, geom_sq2]) ``` ``` -------------------------------- ### Create Nested Geometries Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/advanced_geometry.ipynb Demonstrates nested geometry creation, highlighting the differences between shapely z-ordering and CyTriangle planar regions. ```python sq1 = rectangular_section(d=80, b=80, material=mat1).align_center() sq2 = rectangular_section(d=100, b=100, material=mat2).align_center() sq2 = sq2 - sq1 sq2 = sq2.shift_section(x_offset=-50, y_offset=-50).rotate_section(angle=30) sq1 + sq2 ``` -------------------------------- ### Export Geometry to Fibre Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/export_fibre_section.ipynb Demonstrates how to create a mesh for an I-section and generate fibre section commands for suanPan. ```python from sectionproperties.post.fibre import to_fibre_section from sectionproperties.pre.library import i_section geom = i_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8) geom.create_mesh(mesh_sizes=10) commands = to_fibre_section(geom, analysis_type="3DOS") print(commands[:3000]) ``` -------------------------------- ### Initialize and Mesh a Bulb Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/plot_centroids.ipynb Creates a bulb section geometry and generates a finite element mesh for analysis. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import bulb_section geom = bulb_section(d=200, b=50, t=12, r=10, n_r=8) geom.create_mesh(mesh_sizes=20) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Create Concrete Mesh and Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/section_library.ipynb Generates a mesh and initializes the Section object for the concrete beam. ```python geom.create_mesh(mesh_sizes=[200]) sec = Section(geometry=geom) sec.plot_mesh() ``` -------------------------------- ### Create Geometry from DXF file Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Load a DXF file and create a Geometry object from its contents using the from_dxf class method. Ensure the DXF file path is correct. ```python from sectionproperties.pre import Geometry # the following path is a .dxf file that describes a box section with two holes dxf_path = "../_static/cad_files/box_section.dxf" # load dxf file into a Geometry object geom = Geometry.from_dxf(dxf_filepath=dxf_path) geom.plot_geometry() ``` -------------------------------- ### Write Analysis Files Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/export_fibre_section.ipynb Shows how to save the generated fibre section data and define a suanPan analysis script. ```python # write the fibre section to a file # uncomment below to write file # with open('200UB25.4.sp', 'w') as f: # f.write(commands) # write the main analysis file # since we assigned '3DOS' analysis type, # we need to use compatible elements, for example, 'B31OS'. model = """# Example torsion analysis node 1 0 0 0 node 2 1 0 0 material ElasticOS 1 200. .25 file 200UB25.4.sp orientation B3DOSL 1 0. 0. 1. element B31OS 1 1 2 1 1 6 fix2 1 E 1 displacement 1 0 1E-1 4 2 plainrecorder 1 Node RF4 2 plainrecorder 2 Element BEAMS 1 step static 1 set ini_step_size 1E-1 set fixed_step_size true converger RelIncreDisp 1 1E-10 5 1 analyze save recorder 1 2 exit """ # uncomment below to write file # with open('torsion_analysis.sp', 'w') as f: # f.write(model) ``` -------------------------------- ### Create Mesh and Section Object Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/section_library.ipynb Generates a mesh for the geometry and initializes the Section object for analysis. ```python geom_maj.create_mesh(mesh_sizes=[200]) sec_maj = Section(geometry=geom_maj) sec_maj.plot_mesh() ``` ```python geom_min.create_mesh(mesh_sizes=[200]) sec_min = Section(geometry=geom_min) sec_min.plot_mesh() ``` -------------------------------- ### Slice and Combine Geometries Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/advanced_geometry.ipynb Demonstrates slicing one geometry with another and combining them. This method can create 'floating nodes' along common edges, which may lead to analytical issues. ```python ((i_sec2 - i_sec1) + i_sec1).plot_geometry() ``` -------------------------------- ### Run Scripts Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Execute scripts within the development virtual environment. ```shell uv run example.py ``` -------------------------------- ### Analytical Comparison Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Compare the analytical solution with the calculated results. ```python mu = 18.5 / 10.4 j_an = 1 / 3 * (b + mu * b) * d**3 - 3.361 * (d**4) / (16) * (1 + mu**2) / (1 + mu) print(f"J_an = {j_an:.4f} mm4") print(f"J_sp = {sectionproperties['j_ref']:.4f} mm4") print(f"J_pi = {pilkey['j_ref']:.4f} mm4") ``` -------------------------------- ### Mesh and Initialize Section Object for Composite Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/composite_analysis.ipynb Creates a mesh for the combined composite geometry with specified mesh sizes for different components and initializes a Section object. ```python # 10 mm2 mesh for UB, 500 mm2 mesh for timber geom.create_mesh(mesh_sizes=[10, 500]) sec = Section(geometry=geom) sec.plot_mesh() ``` -------------------------------- ### Plot Mesh with Sample Points and Lines Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/get_stress.ipynb Visualizes the section mesh along with the defined point and lines for stress sampling. Requires `matplotlib`. ```python import matplotlib.pyplot as plt ax = sec.plot_mesh(materials=False, render=False) ax.plot(pt[0], pt[1], "r*", label="Point") ax.plot(x1, y1, "bo-", label="Line 1") ax.plot(x2, y2, "go-", label="Line 2") ax.legend() plt.show() ``` -------------------------------- ### Assign Material to Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Loads a 3DM file into a Geometry object and assigns a material. Ensure the 'example.3dm' file exists and the 'steel' material is defined. ```python geom = Geometry.from_3dm(filepath="example.3dm") geom.material = steel ``` -------------------------------- ### Create Geometric Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/composite_analysis.ipynb Initializes a rectangular geometry with default material properties for geometric-only analysis. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import rectangular_section rect_geom = rectangular_section(d=100, b=50) rect_geom.material ``` -------------------------------- ### Run Tests Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/contributing.rst Execute the pytest suite, excluding benchmarks by default. ```shell uv run pytest -m 'not benchmark_suite' ``` -------------------------------- ### Create Geometry and Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/stress_analysis.ipynb Initializes a rectangular hollow section, generates a mesh, and creates the Section object. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import rectangular_hollow_section geom = rectangular_hollow_section(d=100, b=150, t=6, r_out=15, n_r=8) geom.create_mesh(mesh_sizes=[2]) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Calculate and Display All Properties Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/display_results.ipynb Performs warping and plastic analyses, then displays all calculated results for the section. ```python sec.calculate_warping_properties() sec.calculate_plastic_properties() sec.display_results() ``` -------------------------------- ### Create Mesh and Section Object Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/plastic_analysis.ipynb Creates a mesh for the geometry and initializes a Section object. Mesh size 0 indicates mesh independence. ```python from sectionproperties.analysis import Section geom.create_mesh(mesh_sizes=0) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Create Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/advanced_plot.ipynb Initializes a rectangular hollow section geometry. ```python from sectionproperties.pre.library import rectangular_hollow_section geom = rectangular_hollow_section(d=100, b=100, t=6, r_out=15, n_r=8) ``` -------------------------------- ### Import Modules for Geometry and Section Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_coordinates.ipynb Import the CompoundGeometry object for creating geometry and the Section object for analysis. Ensure these modules are available in your environment. ```python from sectionproperties.analysis import Section from sectionproperties.pre import CompoundGeometry ``` -------------------------------- ### Import Necessary Modules Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/create_mesh.ipynb Import the required classes and functions from the sectionproperties library to begin creating and analyzing sections. ```python from sectionproperties.analysis import Section from sectionproperties.pre import CompoundGeometry from sectionproperties.pre.library import ( box_girder_section, rectangular_hollow_section, rectangular_section, ) ``` -------------------------------- ### Import Necessary Modules Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_cad.ipynb Import the Section, CompoundGeometry, and Geometry classes from the sectionproperties library. ```python from sectionproperties.analysis import Section from sectionproperties.pre import CompoundGeometry, Geometry ``` -------------------------------- ### Geometry Creation from DXF Files Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Loads geometry data from a DXF file to create a Geometry object. ```APIDOC ## Geometry Creation from DXF File ### Description Creates a `Geometry` object by loading data from a specified `.dxf` file. ### Method `Geometry.from_dxf` ### Endpoint N/A (Class method) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **dxf_filepath** (str) - Required - The file path to the `.dxf` file. ### Request Example ```python from sectionproperties.pre import Geometry dxf_path = "../_static/cad_files/box_section.dxf" geom = Geometry.from_dxf(dxf_filepath=dxf_path) ``` ### Response #### Success Response (200) - **Geometry object** - A `sectionproperties.pre.geometry.Geometry` object representing the loaded DXF data. ### Response Example ```json { "message": "Geometry object created successfully" } ``` ### Note Loading multiple regions from a single `.dxf` file into a `CompoundGeometry` is not currently supported. ``` -------------------------------- ### Import Concrete Section Modules Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/section_library.ipynb Imports necessary classes and functions for concrete section analysis. ```python from sectionproperties.pre import Material from sectionproperties.pre.library import concrete_rectangular_section ``` -------------------------------- ### Perform Section Analysis Loop Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/advanced/rectangle_torsion.ipynb Iterates through aspect ratios to generate geometry, create a mesh, and calculate frame properties for each section. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import rectangular_section for ar in aspect_ratios: # calculate rectangle dimensions d = np.sqrt(ar) b = 1 / d geom = rectangular_section(d=d, b=b) # create mesh and Section object ms = d * b / n geom.create_mesh(mesh_sizes=[ms]) sec = Section(geometry=geom) # perform analysis sec.calculate_frame_properties() # save the torsion constant torsion_constants.append(sec.get_j()) ``` -------------------------------- ### Create Angle Section and Perform Plastic Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/plastic_analysis.ipynb Demonstrates plastic analysis on an angle section, including geometric and plastic property calculations and plotting the plastic centroid. This is used to compare global and principal axis bending. ```python from sectionproperties.pre.library import angle_section geom = angle_section(d=150, b=90, t=12, r_r=10, r_t=5, n_r=8) geom.create_mesh(mesh_sizes=0) sec = Section(geometry=geom) sec.calculate_geometric_properties() sec.calculate_plastic_properties() sec.plot_centroids() ``` -------------------------------- ### Compare Z-Section Properties Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/peery.ipynb Prints a comparison table of theoretical and numerical section properties (ixx_g, iyy_g, ixy_g, i11_c, i22_c) for the Z-section. ```python props = sec.section_props print(" Property | Theoretical | Numerical") print(f" ixx_g | {693.3:<12.1f}| {props.ixx_g:<.1f}") print(f" iyy_g | {173.3:<12.1f}| {props.iyy_g:<.1f}") print(f" ixy_g | {-240:<12.1f}| {props.ixy_g:<.1f}") print(f" i11_c | {787:<12.1f}| {props.i11_c:<.1f}") print(f" i22_c | {79.5:<12.1f}| {props.i22_c:<.1f}") ``` -------------------------------- ### Create Section Object and Plot Mesh Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_coordinates.ipynb Initialize a Section object with the generated geometry. The mesh can then be visualized using plot_mesh, optionally showing material assignments. ```python sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Assign Material Properties to Geometries Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Demonstrates assigning material properties to various geometry types including Shapely polygons, geometries created from points, and predefined library sections. Ensure the Material class and Geometry are imported. ```python from shapely import Polygon from sectionproperties.pre import Material from sectionproperties.pre import Geometry from sectionproperties.pre.library import rectangular_section # create a steel material steel = Material( name="Steel", elastic_modulus=200e3, poissons_ratio=0.3, density=7.85e-6, yield_strength=500, color="grey", ) # assign steel to a shapely generated geometry poly = Polygon([(0, 0), (5, 2), (3, 7), (1, 6)]) geom = Geometry(geom=poly, material=steel) # assign steel to a geometry from points points = [(0, 0), (10, 5), (15, 15), (5, 10), (6, 6), (9, 7), (7, 9)] facets = [(0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 4)] control_points = [(4, 4)] holes = [(7, 7)] geom = Geometry.from_points( points=points, facets=facets, control_points=control_points, holes=holes, material=steel, ) # assign steel to a rectangular section geom = rectangular_section(d=100, b=50, material=steel) ``` -------------------------------- ### Compare Results Table Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Generate a comparison table using the rich library. ```python from rich.console import Console from rich.table import Table from rich.text import Text # setup table table = Table(title="Comparison of Results") table.add_column("Property", justify="left", style="cyan", no_wrap=True) table.add_column(Text("Pilkey", justify="center"), justify="right", style="green") table.add_column(Text("sectionproperties", style="i"), justify="right", style="green") table.add_column(Text("Error", justify="center"), justify="right", style="green") # create a row for each property for key in pilkey: # get results p_res = pilkey[key] sp_res = sectionproperties[key] # calculate relative error rel_error = (sp_res - p_res) / p_res if p_res != 0 else sp_res # print row table.add_row(key, f"{p_res:.4e}", f"{sp_res:.4e}", f"{rel_error:.2e}") console = Console() console.print(table) ``` -------------------------------- ### Importing Geometry Modules Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_manipulation.ipynb Required imports for creating primitive and steel sections. ```python from sectionproperties.pre.library import ( channel_section, rectangular_hollow_section, rectangular_section, ) ``` -------------------------------- ### Calculate Section Properties Results Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Calculate properties using sectionproperties with aluminium as the reference material. ```python sectionproperties = { "area": sec.get_area(), "ea_ref": sec.get_ea(e_ref=al), "j_ref": sec.get_ej(e_ref=al), } ``` -------------------------------- ### Create Rectangular Hollow Section Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/results/get_stress.ipynb Initializes a rectangular hollow section geometry, creates a mesh, and sets up a Section object for analysis. Requires `sectionproperties` library. ```python from sectionproperties.analysis import Section from sectionproperties.pre.library import rectangular_hollow_section geom = rectangular_hollow_section(d=100, b=150, t=6, r_out=15, n_r=8) geom.create_mesh(mesh_sizes=3) sec = Section(geometry=geom) ``` -------------------------------- ### Create Compound Geometry from Points Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_coordinates.ipynb Instantiate a CompoundGeometry object using points, facets, and control points. Use CompoundGeometry.from_points for sections with multiple distinct regions. ```python geom = CompoundGeometry.from_points( points=points, facets=facets, control_points=control_points, ) geom.plot_geometry() ``` -------------------------------- ### Generate Mesh and Section Object Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/warping_analysis.ipynb Creates a finite element mesh and initializes the Section object. Warping results are mesh-dependent, so ensure sufficient element density. ```python from sectionproperties.analysis import Section geom.create_mesh(mesh_sizes=7) sec = Section(geometry=geom) sec.plot_mesh(materials=False) ``` -------------------------------- ### Mesh Independent Analysis Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Demonstrates creating a mesh with no area constraints by setting mesh_sizes to 0. ```python geom.create_mesh(mesh_sizes=0) sec = Section(geometry=geom) sec.display_mesh_info() sec.plot_mesh(materials=False) ``` -------------------------------- ### Create I-Section Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Initializes a 200UB25.4 steel I-beam geometry using the library's pre-defined shapes. ```python from sectionproperties.pre.library import i_section geom = i_section(d=203, b=133, t_f=7.8, t_w=5.8, r=8.9, n_r=8) ``` -------------------------------- ### Create Channel Section Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/warping_analysis.ipynb Initializes a 250PFC channel section geometry using the library's pre-defined functions. ```python from sectionproperties.pre.library import channel_section geom = channel_section(d=250, b=90, t_f=15, t_w=8, r=12, n_r=8) ``` -------------------------------- ### Tabulate Results with Rich Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Formats and prints the comparison data using the rich library. ```python from rich.console import Console from rich.table import Table # setup table table = Table(title="Section Properties Comparison") table.add_column("Property", justify="left", style="cyan", no_wrap=True) table.add_column("PFC", justify="right", style="green") table.add_column("Truss", justify="right", style="green") table.add_column("Ratio", justify="right", style="green") # add data to the table table.add_row( "area", f"{sec_pfc.get_area():.0f}", f"{sec_truss.get_area():.0f}", f"{area_ratio:.2f}", ) table.add_row( "ixx", f"{sec_pfc.get_ic()[0]:.3e}", f"{sec_truss.get_ic()[0]:.3e}", f"{ixx_ratio:.2f}", ) table.add_row( "iyy", f"{sec_pfc.get_ic()[1]:.3e}", f"{sec_truss.get_ic()[1]:.3e}", f"{iyy_ratio:.2f}", ) table.add_row( "zyy", f"{sec_pfc.get_z()[2]:.3e}", f"{sec_truss.get_z()[2]:.3e}", f"{zyy_ratio:.2f}", ) table.add_row( "ry", f"{sec_pfc.get_rc()[1]:.0f}", f"{sec_truss.get_rc()[1]:.0f}", f"{ry_ratio:.2f}", ) # print table console = Console() console.print(table) ``` -------------------------------- ### Section Properties Modules Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/api.rst Overview of the available modules within the section-properties API. ```APIDOC ## Section Properties API Reference This API provides functionalities for section properties analysis, divided into three main modules: ### Modules - **sectionproperties.pre**: Handles pre-processing tasks. - **sectionproperties.analysis**: Contains core analysis functionalities. - **sectionproperties.post**: Manages post-processing and result handling. Each module may contain various functions and classes for specific operations. Refer to the respective module documentation for detailed information. ``` -------------------------------- ### Define Concrete and Steel Materials and Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/section_library.ipynb Sets up material properties and creates a reinforced concrete rectangular section. ```python # define the concrete material concrete = Material( name="Concrete", elastic_modulus=30.1e3, poissons_ratio=0.2, density=2.4e-6, yield_strength=32, color="lightgrey", ) # define the steel material steel = Material( name="Steel", elastic_modulus=200e3, poissons_ratio=0.3, yield_strength=500, density=7.85e-6, color="grey", ) # create the geometry geom = concrete_rectangular_section( d=600, b=300, dia_top=16, area_top=200, n_top=3, c_top=32, dia_bot=20, area_bot=310, n_bot=3, c_bot=42, dia_side=12, area_side=110, n_side=3, c_side=57, n_circle=16, conc_mat=concrete, steel_mat=steel, ) ``` -------------------------------- ### Print Second Moment of Inertia (Ix) Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/peery.ipynb Prints the calculated second moment of inertia (Ix) for the symmetric I-section, formatted to two decimal places. ```python print(f"Ix = {sec.section_props.ixx_g:.2f} in4") ``` -------------------------------- ### Display Mesh Image Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_channel.ipynb Display the channel mesh image using IPython. ```python display(Image(filename="images/channel-mesh.png")) ``` -------------------------------- ### Import Material Object Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/assign_materials.ipynb Import the Material object from the sectionproperties.pre module to define material properties. ```python from sectionproperties.pre import Material ``` -------------------------------- ### Load Geometry from DXF Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_cad.ipynb Load a single region from a .dxf file using Geometry.from_dxf(). Mesh the geometry and plot it. Note: Loading multiple regions from a single .dxf is not supported. ```python geom = Geometry.from_dxf(dxf_filepath="../../_static/cad_files/box_section.dxf") ``` ```python geom.create_mesh(mesh_sizes=[0.5]) Section(geometry=geom).plot_mesh(materials=False) ``` -------------------------------- ### Display Mesh Image Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Display the mesh image using IPython. ```python display(Image(filename="images/comp-mesh.png")) ``` -------------------------------- ### Create Geometry from Rhino BREP encoding Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Loads a JSON file containing a Rhino BREP encoding to create a Geometry object. ```python import json from sectionproperties.pre import Geometry # the following path is a .json file that is a BREP describing a 1 x 1 square rhino_path = "../_static/cad_files/rhino_brep.json" with open(rhino_path) as rhino_file: brep_encoded = json.load(rhino_file) # load BREP file into a Geometry object geom = Geometry.from_rhino_encoding(r3dm_brep=brep_encoded) geom.plot_geometry() ``` -------------------------------- ### Calculate Property Ratios Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/analysis/geometric_analysis.ipynb Computes ratios between the truss section and the single PFC section properties. ```python area_ratio = sec_truss.get_area() / sec_pfc.get_area() ixx_ratio = sec_truss.get_ic()[0] / sec_pfc.get_ic()[0] iyy_ratio = sec_truss.get_ic()[1] / sec_pfc.get_ic()[1] zyy_ratio = sec_truss.get_z()[2] / sec_pfc.get_z()[2] ry_ratio = sec_truss.get_rc()[1] / sec_pfc.get_rc()[1] ``` -------------------------------- ### Assign Material to Arbitrary Geometry Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/materials/assign_materials.ipynb Use the Geometry.from_points() method to create a geometry from points, facets, and control points, optionally assigning a material during creation. Ensure all necessary lists (points, facets, control_points, holes) are defined. ```python # create list of points, facets and holes points = [(0, 0), (10, 5), (15, 15), (5, 10), (6, 6), (9, 7), (7, 9)] facets = [(0, 1), (1, 2), (2, 3), (3, 0), (4, 5), (5, 6), (6, 4)] control_points = [(4, 4)] holes = [(7, 7)] # create geometry object, specifying material geom = Geometry.from_points( points=points, facets=facets, control_points=control_points, holes=holes, material=steel, ) geom.create_mesh(mesh_sizes=1) Section(geometry=geom).plot_mesh() ``` -------------------------------- ### Import Modules for Rectangular Timber CLT Section Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/section_library.ipynb Imports the necessary components for creating and analyzing rectangular timber crosslaminated (CLT) sections, including the section creation function and the Material object. ```python from sectionproperties.analysis import Section from sectionproperties.pre import Material from sectionproperties.pre.library import clt_rectangular_section ``` -------------------------------- ### Define Geometry and Materials Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_composite.ipynb Define material properties and create the composite rectangular geometry. ```python from sectionproperties.pre import Material from sectionproperties.pre.library import rectangular_section d = 2 # depth of rectangles b = 15 # width of each rectangle # aluminium material al = Material( name="Aluminium", elastic_modulus=10.4e6, poissons_ratio=0.3, yield_strength=1.0, density=1.0, color="lightgrey", ) # aluminium material cu = Material( name="Copper", elastic_modulus=18.5e6, poissons_ratio=0.3, yield_strength=1.0, density=1.0, color="gold", ) # create two rectangles and add geometry together geom_al = rectangular_section(d=d, b=b, material=al) geom_cu = rectangular_section(d=d, b=b, material=cu).align_to(other=geom_al, on="right") geom = geom_al + geom_cu # plot geometry geom.plot_geometry() ``` -------------------------------- ### Load CompoundGeometry from 3DM Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/geometry/geometry_cad.ipynb Load multiple regions from a .3dm (Rhino) file using CompoundGeometry.from_3dm(). Rotate the compound geometry, then mesh and plot it. ```python geom = CompoundGeometry.from_3dm(filepath="../../_static/cad_files/rhino_compound.3dm") geom = geom.rotate_section(angle=90) # rotate for viewability ``` ```python geom.create_mesh(mesh_sizes=[0.005]) Section(geometry=geom).plot_mesh(materials=False) ``` -------------------------------- ### Define Geometry and Material Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/examples/validation/pilkey_channel.ipynb Create a shapely Polygon and a sectionproperties Geometry object with defined material properties. ```python from shapely import Polygon from sectionproperties.pre import Geometry, Material t = 1 # channel thickness h = 18 # distance between centreline of channel flanges b = 8 # distance from edge of flange to centreline of web # steel material mat = Material( name="Steel", elastic_modulus=2.1e8, poissons_ratio=0.33333, yield_strength=1.0, density=1.0, color="lightgrey", ) # define list of points, starting from lower left hand corner points = [ (-0.5 * t, -0.5 * h - 0.5 * t), (b, -0.5 * h - 0.5 * t), (b, -0.5 * h + 0.5 * t), (0.5 * t, -0.5 * h + 0.5 * t), (0.5 * t, 0.5 * h - 0.5 * t), (b, 0.5 * h - 0.5 * t), (b, 0.5 * h + 0.5 * t), (-0.5 * t, 0.5 * h + 0.5 * t), ] # create shapely Polygon object poly = Polygon(shell=points) # create sectionproperties Geometry object geom = Geometry(geom=poly, material=mat) # plot geometry geom.plot_geometry() ``` -------------------------------- ### Create CompoundGeometry from 3DM file Source: https://github.com/robbievanleeuwen/section-properties/blob/master/docs/user_guide/geometry.rst Loads a 3DM file containing multiple surfaces into a CompoundGeometry object. ```python from sectionproperties.pre import CompoundGeometry # the following path is a .3dm file that describes two distinct 2D surfaces rhino_path = "../_static/cad_files/rhino_compound.3dm" # load 3dm file into a CompoundGeometry object geom = CompoundGeometry.from_3dm(filepath=rhino_path) geom.plot_geometry() ```