Section Meshing#

class opstool.preprocessing.SecMesh(sec_name='My Section')[source]#

A class to mesh the cross-section with triangular fibers.

Parameters#

sec_namestr

Assign a name to the section.

Returns#

None

add_rebars(rebars_obj)[source]#

Add rebars.

Parameters#

rebars_objmesh obj

The instance of Rebars class.

Returns#

None

assign_group(group)[source]#

Assign the group dict for each mesh.

Parameters#

groupdict[str, any]

A dict of name as key, geometry obj as value.

Returns#

instance

assign_group_color(colors)[source]#

Assign the color dict to plot the section.

Parameters#

colorsdict[str, str]

A dict of name as key, color as value.

assign_mesh_size(mesh_size=None)[source]#

Assign the mesh size dict for each mesh.

Parameters#

mesh_sizedict[str, float], default=None

A dict of name as key, mesh size as value. The mesh sizes describe the maximum mesh element area to be used in the finite-element mesh for each Geometry object. If default None is used, the mesh size of each Geometry will be calculate by its area / 100.

Returns#

instance

assign_ops_matTag(mat_tag)[source]#

Assign the mesh size dict for each mesh.

Parameters#

mat_tagdict[str, int]

A dict of name as key, OpenSees matTag previous defined as value.

Returns#

instance

centring()[source]#

Move the section centroid to (0, 0).

Returns#

None

display_all_results(fmt='8.6e')[source]#

Prints all results that have been calculated by sectionproperties to the terminal.

Parameters#

fmtstr, optional

Number formatting string.

get_area()[source]#

Return section area.

Returns#

Float

get_fiber_data()[source]#

Return fiber data.

Returns#

Tuple(dict, dict)

fiber center dict, fiber area dict

get_frame_props(Eref=1.0, Gref=None, display_results=False, fmt='8.3E')[source]#

Calculates and returns the properties required for a frame analysis. See sectionproperties doc

This method is fast, but cannot calculate the shear area compared to the method get_sec_props().

Parameters#

Eref: float, default=1.0

Reference modulus of elasticity, it is important to analyze the composite section. If it is not a composite section, please ignore this parameter and the following Gref. See sectionproperties doc

Gref: float, default=None

Reference shear modulus, useful for torsional constant calculations of composite section. If None, Gref = 0.5 * Eref.

Deprecated since version 0.9.0: Since version 0.9.0, this parameter Gref is no longer needed and will be removed.

display_resultsbool, default=True

whether to display the results.

fmtstr, optional

Number formatting string when display_results=True.

Returns#

sec_props: dict

section props dict, including:

  • Cross-sectional area (A)

  • Elastic centroid (centroid)

  • Second moments of area about the centroidal axis (Iy, Iz, Iyz)

  • Elastic section moduli about the centroidal axis with respect to the top and bottom fibres (Wyt, Wyb, Wzt, Wzb)

  • Torsion constant (J)

  • Principal axis angle (phi)

  • Section mass (mass), only true if material density is defined, otherwise geometric area (mass density is 1)

  • ratio of reinforcement (rho_rebar)

Note

If it is not a composite section, please ignore the Eref and Gref parameters; Otherwise, please use the Eref and Gref parameters, all section properties will be converted according to the reference material, and the mechanical properties of the reference material are then used in the practical analysis.

Note that according to the OpenSees convention, the x-axis refers to the normal direction of the section, the y-axis refers to the abscissa, and the z-axis refers to the ordinate direction.

get_group()[source]#

Return the group dict for each geometry obj.

Returns#

group : dict[str, any]

get_iy()[source]#

Return Moment of inertia of the section around the y-axis.

Returns#

Float

get_iz()[source]#

Return Moment of inertia of the section around the z-axis.

Returns#

Float

get_j()[source]#

Return section torsion constant.

Returns#

Float

get_sec_props(Eref=1.0, Gref=None, display_results=False, fmt='8.3E', plot_centroids=False)[source]#

Solving Section Geometry Properties by Finite Element Method, by sectionproperties pacakge. See sectionproperties doc

This command may be slower. If you don’t need features such as shear area, you can use method get_frame_props().

Parameters#

Eref: float, default=1.0

Reference modulus of elasticity, it is important to analyze the composite section. If it is not a composite section, please ignore this parameter and the following Gref. See sectionproperties doc

Gref: float, default=None

Reference shear modulus, useful for torsional constant calculations of composite section. If None, Gref = 0.5 * Eref.

Deprecated since version 0.9.0: Since version 0.9.0, this parameter Gref is no longer needed and will be removed.

display_resultsbool, default=True

whether to display the results.

fmtstr, optional

Number formatting string when display_results=True.

plot_centroidsbool, default=False

whether to plot centroids

Returns#

sec_props: dict

section props dict, including:

  • Cross-sectional area (A)

  • Shear area (Asy, Asz)

  • Elastic centroid (centroid)

  • Second moments of area about the centroidal axis (Iy, Iz, Iyz)

  • Elastic section moduli about the centroidal axis with respect to the top and bottom fibres (Wyt, Wyb, Wzt, Wzb)

  • Torsion constant (J)

  • Principal axis angle (phi)

  • Section mass (mass), only true if material density is defined, otherwise geometric area (mass density is 1)

  • ratio of reinforcement (rho_rebar)

Note

If it is not a composite section, please ignore the Eref and Gref parameters; Otherwise, please use the Eref and Gref parameters, all section properties will be converted according to the reference material, and the mechanical properties of the reference material are then used in the practical analysis.

Note that according to the OpenSees convention, the x-axis refers to the normal direction of the section, the y-axis refers to the abscissa, and the z-axis refers to the ordinate direction.

get_stress(N=0, Vy=0, Vz=0, Myy=0, Mzz=0, Mxx=0, plot_stress='all', cmap='YlOrBr', normalize=False, fmt='{x:.4e}', colorbar_label='Stress', alpha=0.2, **kargs)[source]#

Calculates the cross-section stress resulting from design actions and returns a list of dictionaries containing the cross-section stresses for each region by method assign_group().

Note

This function is only available for elastic stress analysis, and reinforcement is ignored.

The stresses are realistic only if you specify the correct material for each geometry region.

Parameters#

Nfloat, optional

Axial force, by default 0

Vyfloat, optional

Shear force acting in the y-direction, by default 0

Vzfloat, optional

Shear force acting in the z-direction, by default 0

Myyfloat, optional

Bending moment about the centroidal yy-axis, by default 0

Mzzfloat, optional

Bending moment about the centroidal zz-axis, by default 0

Mxxfloat, optional

Torsion moment about the centroidal xx-axis, by default 0

plot_stressstr, optional

plot the various cross-section stresses, by default None. Note that according to the OpenSees convention, the x-axis refers to the normal direction of the section, the y-axis refers to the abscissa, and the z-axis refers to the ordinate direction. Optional as follows (if plot_stress=”all”, will plot all stress types):

Combined Stress Plots:

  • “xx”–combined normal stress resulting from all actions;

  • “xy”–y-component of the shear stress resulting from all actions;

  • “xz”– z-component of the shear stress resulting from all actions;

  • “xyz”–resultant shear stress resulting from all actions;

  • “p1”–major principal stress resulting from all actions;

  • “p3”– Minor principal stress resulting from all actions;

  • “vm”–von Mises stress resulting from all actions;

Primary Stress Plots:

  • “n_xx”–normal stress resulting from the axial load N;

  • “myy_xx”–normal stress resulting from the bending moment Myy;

  • “mzz_xx”–normal stress resulting from the bending moment Mzz;

  • “m_xx”–normal stress resulting from all bending moments Myy+Mzz;

  • “mxx_xy”–y-component of the shear stress resulting from the torsion moment Mxx;

  • “mxx_xz”–z-component of the shear stress resulting from the torsion moment Mxx;

  • “mxx_xyz”–resultant shear stress resulting from the torsion moment Mxx;

  • “vy_xy”–y-component of the shear stress resulting from the shear force Vy;

  • “vy_xz”–z-component of the shear stress resulting from the shear force Vy;

  • “vy_xyz”–resultant shear stress resulting from the shear force Vy;

  • “vz_xy”–y-component of the shear stress resulting from the shear force Vz;

  • “vz_xz”–z-component of the shear stress resulting from the shear force Vz;

  • “vz_xyz”–resultant shear stress resulting from the shear force Vz;

  • “v_xy”–y-component of the shear stress resulting from the sum of the applied shear forces Vy+Vz;

  • “v_xz”–z-component of the shear stress resulting from the sum of the applied shear forces Vy+Vz;

  • “v_xyz”–resultant shear stress resulting from the sum of the applied shear forces Vy+Vz;

cmapstr, optional

Matplotlib color map, by default ‘coolwarm’

normalizebool, optional

If set to true, the CenteredNorm is used to scale the colormap. If set to false, the default linear scaling is used., by default True

fmt: Number formatting string, see

https://docs.python.org/3/library/string.html

colorbar_label: Colorbar label alpha: Transparency of the mesh outlines

Returns#

list[dict]:

A list of dictionaries containing the cross-section stresses for each region by method assign_group().

mesh(plot_mesh=False)[source]#

Mesh the section.

Parameters#

plot_mesh: bool, default=False

If True, plot the mesh by sectionproperties.

Returns#

None

opspy_cmds(secTag, GJ=None, G=None)[source]#

Generate openseespy fiber section command.

Parameters#

secTagint

The section tag assigned in OpenSees.

GJfloat, default = None

Torsion stiffness. Note that at least one of GJ and G needs to be specified, and if both, it will be calculated by GJ.

Gfloat, default = None

Shear modulus.The torsion constant is automatically calculated by the program. Note that at least one of GJ and G needs to be specified, and if both, it will be calculated by GJ.

Returns#

None

rotate(theta=0)[source]#

Rotate the section clockwise.

Parameters#

thetafloat, default=0

Rotation angle, unit: degree.

Returns#

None

to_file(output_path, secTag, GJ=None, G=None, fmt=':.6E')[source]#

Output the opensees fiber code to file.

Parameters#

output_pathstr

The filepath to save, e.g., r”my_dir/my_section.py”

secTagint

The section tag assigned in OpenSees.

GJfloat, default = None

Torsion stiffness. Note that at least one of GJ and G needs to be specified, and if both, it will be calculated by GJ.

Gfloat, default = None

Shear modulus.The torsion constant is automatically calculated by the program. Note that at least one of GJ and G needs to be specified, and if both, it will be calculated by GJ.

fmtstr, default = “:.6E”

Formatting style for floating point numbers.

Returns#

None

Notes#

Notes that output_path must be endswith .py or .tcl, function will create the file by a right style.

view(fill=True, engine='plotly', save_html=None, on_notebook=False, show_hover=False)[source]#

Display the section mesh.

Parameters#

fillbool, default=True

Whether to fill the trangles.

engine: str, default=’plotly’

Plot engine, optional “plotly” or “matplotlib”.

save_html: str, default=”SecMesh.html”

If set, the figure will save as a html file, only useful for engine=”plotly”. If False or None, this parameter will be ignored.

on_notebook: bool, default=False

If True, the figure will display in a notebook.

show_hover: bool, default=False

If True, the figure will show the hover labels.

Returns#

None

Example#

import opstool as opst

outlines = [[0, 0], [2, 0], [2, 2], [0, 2]]
obj = opst.add_polygon(outlines)
sec = opst.SecMesh(sec_name='plain section')
sec.assign_group(dict(sec=obj))
sec.assign_mesh_size(dict(sec=0.1))
sec.mesh()
sec_props = sec.get_sec_props(display_results=True, plot_centroids=False)
sec.centring()
# sec.rotate(45)
sec.view(fill=True, engine='matplotlib')
                              Section Properties                               
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Symbol     Value                   Definition                             ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ A          4.000E+00               Cross-sectional area                   │
│ Asy        3.334E+00               Shear area y-axis                      │
│ Asz        3.334E+00               Shear area z-axis                      │
│ centroid   (1.000E+00, 1.000E+00)  Elastic centroid                       │
│ Iy         1.333E+00               Moment of inertia y-axis               │
│ Iz         1.333E+00               Moment of inertia z-axis               │
│ Iyz        8.882E-16               Product of inertia                     │
│ Wyt        1.333E+00               Section moduli of top fibres y-axis    │
│ Wyb        1.333E+00               Section moduli of bottom fibres y-axis │
│ Wzt        1.333E+00               Section moduli of top fibres z-axis    │
│ Wzb        1.333E+00               Section moduli of bottom fibres z-axis │
│ J          2.253E+00               Torsion constant                       │
│ phi        0.000E+00               Principal axis angle                   │
│ mass       4.000E+00               Section mass                           │
│ rho_rebar  0.000E+00               Ratio of reinforcement                 │
└───────────┴────────────────────────┴────────────────────────────────────────┘
../../_images/sec.SecMesh_0_76.png