opstool package index

opstool.vis module

class opstool.vis.FiberSecVis(ele_tag: int, sec_tag: int, results_dir: str = 'opstool_output', line_width: float = 0.75, line_color: str = 'k', colormap: str = 'viridis', opacity: float = 0.75)[source]

Bases: object

A class to vis the fiber section in OpenSeesPy.

Parameters

ele_tag: int

The element tag to which the section is to be displayed.

sec_tag: int

Which integration point section is displayed, tag from 1 from segment i to j.

results_dir: str, default=”opstool_output”

The dir that results saved.

line_width: float, default = 0.75

The line width of mesh edges.

line_color: str, default = “k”

The color of mesh edges.

colormap: str, default = “jet”

Color map used to display the response.

opacity: float, default=0.75

Transparency of mesh.

Returns

FiberSecVis instance.

animation(analysis_tag: int, output_file: str, show_variable: str = 'strain', show_mats: Optional[Union[int, list[int], tuple[int]]] = None, framerate: int = 24)[source]

fiber section response animation.

Parameters

analysis_tag: int

Analysis tag.

output_file: str

The output file name, must end with .gif.

show_variable: str, default=’strain

Response type to display, optional “stress” or “strain”.

show_mats: Union[int, list[int], tuple[int]], default=None

Mat tag to dispaly. If None, all tags will display.

framerate: int, default=24

The number of frames per second.

Returns

None

resp_vis(analysis_tag: int, step: Optional[int] = None, show_variable: str = 'strain', show_mats: Optional[Union[int, list[int], tuple[int]]] = None)[source]

fiber section response vis.

Parameters

analysis_tag: int

Analysis tag.

step: int, default = None

Analysis step to display. If None, the step that max response; If -1, the final step; Else, the other step.

show_variable: str, default = ‘srain’

Response type to display, optional “stress” or “strain”.

show_mats: Union[int, list[int], tuple[int]]

matTags to dispaly. matTag is the material tag defined in openseespy, bu it must in the section. If None, all tags will display.

Returns

None

sec_vis(mat_color: Optional[dict] = None)[source]

plot the fiber section.

Parameters

mat_color: dict

Dict for assign color by matTag, {matTag1:color1,matTag2:color2, and so on} matTag is the material tag defined in openseespy, bu it must in the section.

Returns

None

class opstool.vis.GetFEMdata(results_dir: str = 'opstool_output')[source]

Bases: object

Get the data in the openseespy model domain.

Parameters

results_dir: str, default=”opstool_output”

The dir that results saved.

get_eigen_data(mode_tag: int = 1, solver: str = '-genBandArpack')[source]

Get eigenvalue Analysis Data. The data will saved to file EigenData.dat.

Parameters

mode_tag: int

mode tag.

solver: str, default ‘-genBandArpack’

type of solver, optional ‘-genBandArpack’, ‘-fullGenLapack’, see https://openseespydoc.readthedocs.io/en/latest/src/eigen.html.

Returns

None

get_fiber_data(ele_sec: list[tuple[int, int]])[source]

Get data from the section assigned by parameter ele_sec. The data will saved to file FiberData.dat.

Parameters

ele_sec: list[tuple[int, int]]

A list or tuple composed of element tag and sectag. e.g., [(ele1, sec1), (ele2, sec2), … , (elen, secn)], The section is attached to an element in the order from end i to end j of that element.

Returns

None

get_fiber_resp_step(analysis_tag: int, num_steps: int = 10000000000, total_time: float = 10000000000)[source]

Get analysis step data for fiber section. The data will saved to file FiberRespStepData-{analysis_tag}.dat.

Parameters

analysis_tag: int

num_steps: int, default=10000000000

Total number of steps, set to determine when to save data.

total_time: float, default=10000000000

Total analysis time, set to determine when to save data. You can specify one of the parameters num_steps and total_time. If both are used, it depends on which one arrives first.

Returns

None

get_frame_resp_step(analysis_tag: int, num_steps: int = 10000000000, total_time: float = 10000000000)[source]

Get the response data step by step. The data will saved to file BeamRespStepData-{analysis_tag}.dat.

Parameters

analysis_tag: int

Analysis tag used to assign the analysis data.

num_steps: int, default=10000000000

Total number of steps, set to determine when to save data.

total_time: float, default=10000000000

Total analysis time, set to determine when to save data. You can specify one of the parameters num_steps and total_time. If both are used, it depends on which one arrives first.

Returns

None

Note

You need to call this function at each analysis step in OpenSees. The advantage is that you can modify the iterative algorithm at each analysis step to facilitate convergence.

get_model_data(save_file: bool = True)[source]

Get data from the current model domain. The data will saved to file ModelData.dat.

Parameters

save_file: bool, default=True

Wether to save model infomation data.

get_node_resp_step(analysis_tag: int, num_steps: int = 10000000000, total_time: float = 10000000000, model_update: bool = False)[source]

Get the response data step by step. The data will saved to file NodeRespStepData-{analysis_tag}.dat.

Tip

You need to call this function at each analysis step in OpenSees. The advantage is that you can modify the iterative algorithm at each analysis step to facilitate convergence.

Parameters

analysis_tag: int

Analysis tag used to assign the analysis data.

num_steps: int, default=10000000000

Total number of steps, set to determine when to save data.

total_time: float, default=10000000000

Total analysis time, set to determine when to save data. You can specify one of the parameters num_steps and total_time. If both are used, it depends on which one arrives first.

model_update: bool, default False

whether to update the model domain data at each analysis step, this will be useful if model data has changed.

Returns

None

Note

You need to call this function at each analysis step in OpenSees. The advantage is that you can modify the iterative algorithm at each analysis step to facilitate convergence.

reset_eigen_state()[source]

Reset the state of results extract of eigen data.

reset_model_state()[source]

Reset the state of results extract of model data.

reset_steps_state()[source]

Reset the state of results extract in analysis step

class opstool.vis.OpsVisPlotly(point_size: float = 5, line_width: float = 5, colors_dict: Optional[dict] = None, theme: str = 'plotly', color_map: str = 'jet', on_notebook: bool = False, results_dir: str = 'opstool_output')[source]

Bases: object

A class to visualize OpenSeesPy model based on plotly.

Parameters

point_size: float

The render size of node.

line_width: float

The width of line element;

colors_dict: dict,

default: dict(point=’#840000’, line=’#0165fc’, face=’#06c2ac’, solid=’#f48924’, truss=”#7552cc”, link=”#00c16e”) The dict for ele color.

theme: str, default=plotly

Plot theme, optional “plotly”, “plotly_white”, “plotly_dark”, “ggplot2”, “seaborn”, “simple_white”, “none”.

color_map: str, default=”jet”

color map to display the cloud plot. Optional, [‘aggrnyl’, ‘agsunset’, ‘algae’, ‘amp’, ‘armyrose’, ‘balance’, ‘blackbody’, ‘bluered’, ‘blues’, ‘blugrn’, ‘bluyl’, ‘brbg’, ‘brwnyl’, ‘bugn’, ‘bupu’, ‘burg’, ‘burgyl’, ‘cividis’, ‘curl’, ‘darkmint’, ‘deep’, ‘delta’, ‘dense’, ‘earth’, ‘edge’, ‘electric’, ‘emrld’, ‘fall’, ‘geyser’, ‘gnbu’, ‘gray’, ‘greens’, ‘greys’, ‘haline’, ‘hot’, ‘hsv’, ‘ice’, ‘icefire’, ‘inferno’, ‘jet’, ‘magenta’, ‘magma’, ‘matter’, ‘mint’, ‘mrybm’, ‘mygbm’, ‘oranges’, ‘orrd’, ‘oryel’, ‘oxy’, ‘peach’, ‘phase’, ‘picnic’, ‘pinkyl’, ‘piyg’, ‘plasma’, ‘plotly3’, ‘portland’, ‘prgn’, ‘pubu’, ‘pubugn’, ‘puor’, ‘purd’, ‘purp’, ‘purples’, ‘purpor’, ‘rainbow’, ‘rdbu’, ‘rdgy’, ‘rdpu’, ‘rdylbu’, ‘rdylgn’, ‘redor’, ‘reds’, ‘solar’, ‘spectral’, ‘speed’, ‘sunset’, ‘sunsetdark’, ‘teal’, ‘tealgrn’, ‘tealrose’, ‘tempo’, ‘temps’, ‘thermal’, ‘tropic’, ‘turbid’, ‘turbo’, ‘twilight’, ‘viridis’, ‘ylgn’, ‘ylgnbu’, ‘ylorbr’, ‘ylorrd’].

on_notebook: bool, default=False

Whether work in a jupyter notebook.

results_dir: str, default=”opstool_output”

The dir that results saved.

Returns

None

deform_anim(analysis_tag: int, response: str = 'disp', alpha: Optional[float] = None, show_outline: bool = False, opacity: float = 1, framerate: int = 24, show_face_line: bool = True, save_html: str = 'DefoAnimation', model_update: bool = False)[source]

Deformation animation of the model.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

response: str, default=’disp’

Response type. Optional, “disp”, “vel”, “accel”.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

framerate: int, default=24

The number of frames per second.

opacity: float, default=1.0

Plane and solid element transparency.

save_html: str, default=’DefoAnimation.html’

The html file name to output. If False, the html file will not be generated.

Returns

None

deform_vis(analysis_tag: int, slider: bool = False, response: str = 'disp', alpha: Optional[float] = None, show_outline: bool = False, show_origin: bool = False, show_face_line: bool = True, opacity: float = 1, save_html: str = 'DefoVis', model_update: bool = False)[source]

Visualize the deformation of the model at a certain analysis step.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

slider: bool, default=False

If True, responses in all steps will display by slider style. If False, the step that max response will display.

response: str, default=’disp’

Response type. Optional, “disp”, “vel”, “accel”.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

show_origin: bool, default=False

Whether to show undeformed shape.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

opacity: float, default=1.0

Plane and solid element transparency.

save_html: str, default=’DefoVis.html’

The html file name to output. If False, the html file will not be generated.

Returns

None

eigen_anim(mode_tag: int = 1, alpha: Optional[float] = None, show_outline: bool = False, opacity: float = 1, framerate: int = 3, show_face_line: bool = True, save_html: str = 'EigenAnimation')[source]

Animation of Modal Analysis.

Parameters

mode_tag: int

The mode tag.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

opacity: float, default=1.0

Plane and solid element transparency.

framerate: int

The number of frames per second.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

save_html: str, default=’EigenAnimation.html’

The html file name to output. If False, the html file will not be generated.

Returns

None

eigen_vis(mode_tags: list[int], subplots: bool = False, alpha: Optional[float] = None, show_outline: bool = False, show_origin: bool = False, opacity: float = 1.0, show_face_line: bool = True, save_html: str = 'EigenVis')[source]

Eigenvalue Analysis Visualization.

Parameters

mode_tags: list[int], or tuple[int]

Mode tags to be shown, if list or tuple [mode1, mode2], display the multiple modes from mode1 to mode2.

subplots: bool, default=False

If True, subplots in a figure. If False, plot in a slide style.

alpha: float, default=None

Model scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=True

Whether to display the axes.

show_origin: bool, default=False

Whether to show undeformed shape.

opacity: float, default=1.0

Plane and solid element transparency.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

save_html: str, default=’EigenVis.html’

The html file name to output. If False, the html file will not be generated.

Returns

None

frame_resp_vis(analysis_tag: int, ele_tags: Optional[list[int]] = None, slider: bool = False, response: str = 'Mz', show_values=True, alpha: Optional[float] = None, opacity: float = 1, save_html: str = 'FrameRespVis')[source]

Display the force response of frame elements.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

ele_tags: int or list[int], default=None

Element tags to display, if None, all frame elements will display.

slider: bool, default=False

If True, responses in all steps will display by slider style. If False, the step that max response will display.

response: str, default=’Mz’

Response type. Optional, “Fx”, “Fy”, “Fz”, “My”, “Mz”, “Mx”.

show_values: bool, default=True

If True, will show the response values.

alpha: float, default=None

Scaling factor.

opacity: float, default=1.0

Plane and solid element transparency.

save_html: str, default=’FrameRespVis.html’

The html file name to output. If False, the html file will not be generated.

model_vis(show_node_label: bool = False, show_ele_label: bool = False, show_local_crd: bool = False, label_size: float = 8, show_outline: bool = True, opacity: float = 1.0, save_html: str = 'ModelVis.html')[source]

Visualize the model in the current domain.

Parameters

show_node_label: bool, default=False

Whether to display the node label.

show_ele_label: bool, default=False

Whether to display the ele label.

show_local_crd: bool, default=False

Whether to display the local coordinate system.

label_size: float, default=8

The foontsize of node and ele label.

show_outline: bool, default=True

Whether to show the axis frame.

opacity: float, default=1.0

Plane and solid element transparency.

save_html: str, default=’ModelVis.html’

The html file name to output. If False, the html file will not be generated.

Returns

None

class opstool.vis.OpsVisPyvista(point_size: float = 1, line_width: float = 3, colors_dict: Optional[dict] = None, theme: str = 'document', color_map: str = 'jet', on_notebook: bool = False, results_dir: str = 'opstool_output')[source]

Bases: object

A class to visualize OpenSeesPy model based on pyvista.

Parameters

point_size: float, default=1

The render size of node.

line_width: float, default=3

The width of line element.

colors_dict: dict,

default: dict(point=’#840000’, line=’#0165fc’, face=’#06c2ac’, solid=’#f48924’, truss=”#7552cc”, link=”#00c16e”) The dict for ele color.

theme: str, default=’document’

Plot theme for pyvista, optional ‘default’, ‘paraview’, ‘document’, ‘dark’.

color_map: str, default=”jet”

color map to display the cloud plot for pyvista. optional ‘jet’, ‘rainbow’, ‘hot’, ‘afmhot’, ‘copper’, ‘winter’, ‘cool’, ‘coolwarm’, ‘gist_earth’, ‘bone’, ‘binary’, ‘gray’, or any Matplotlib colormap .

on_notebook: bool, default=False

Whether work in a notebook.

results_dir: str, default=”opstool_output”

The dir that results saved.

Returns

None

deform_anim(analysis_tag: int, response: str = 'disp', alpha: Optional[float] = None, show_outline: bool = False, opacity: float = 1, framerate: int = 24, show_face_line: bool = True, save_fig: str = 'DefoAnimation.gif', model_update: bool = False)[source]

Deformation animation of the model.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

response: str, default=’disp’

Response type. Optional, “disp”, “vel”, “accel”.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

framerate: int, default=24

The number of frames per second.

opacity: float, default=1.0

Plane and solid element transparency.

save_fig: str, default=’DefoAnimation.gif’

The output file name, must end with .gif or .mp4. You can export to any folder, such as “C:mydir/myfile.gif”, but the folder mydir must exist.

Returns

None

deform_vis(analysis_tag: int, slider: bool = False, response: str = 'disp', alpha: Optional[float] = None, show_outline: bool = False, show_origin: bool = False, show_face_line: bool = True, opacity: float = 1, save_fig: str = 'DefoVis.svg', model_update: bool = False)[source]

Visualize the deformation of the model at a certain analysis step.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

slider: bool, default=False

If True, responses in all steps will display by slider style. If False, the step that max response will display.

response: str, default=’disp’

Response type. Optional, “disp”, “vel”, “accel”.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

show_origin: bool, default=False

Whether to show undeformed shape.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

opacity: float, default=1.0

Plane and solid element transparency.

save_fig: str, default=’DefoVis.svg’

The file name to output. If False or None, the file will not be generated. The supported formats are:

  • ‘.svg’

  • ‘.eps’

  • ‘.ps’

  • ‘.pdf’

  • ‘.tex’

Returns

None

eigen_anim(mode_tag: int = 1, alpha: Optional[float] = None, show_outline: bool = False, opacity: float = 1, framerate: int = 3, show_face_line: bool = True, save_fig: str = 'EigenAnimation.gif')[source]

Animation of Modal Analysis.

Parameters

mode_tag: int

The mode tag.

alpha: float, default=None

Scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=False

Whether to display the axes.

opacity: float, default=1.0

Plane and solid element transparency.

framerate: int

The number of frames per second.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

save_fig: str, default=’EigenAnimation.gif’

The output file name, must end with .gif or .mp4. You can export to any folder, such as “C:mydir/myfile.gif”, but the folder mydir must exist.

Returns

None

eigen_vis(mode_tags: list[int], subplots: bool = False, alpha: Optional[float] = None, show_outline: bool = False, show_origin: bool = False, opacity: float = 1.0, show_face_line: bool = True, save_fig: str = 'EigenVis.svg')[source]

Eigenvalue Analysis Visualization.

Parameters

mode_tags: list[int], or tuple[int]

Mode tags to be shown, if list or tuple [mode1, mode2], display the multiple modes from mode1 to mode2.

subplots: bool, default=False

If True, subplots in a figure. If False, plot in a slider style.

alpha: float, default=None

Model scaling factor, the default value is 1/5 of the model boundary according to the maximum deformation.

show_outline: bool, default=True

Whether to display the axes.

show_origin: bool, default=False

Whether to show undeformed shape.

opacity: float, default=1.0

Plane and solid element transparency.

show_face_line: bool, default=True

If True, the edges of plate and solid elements will be displayed.

save_fig: str, default=’EigenVis.svg’

The file name to output. If False or None, the file will not be generated. The supported formats are:

  • ‘.svg’

  • ‘.eps’

  • ‘.ps’

  • ‘.pdf’

  • ‘.tex’

Returns

None

frame_resp_vis(analysis_tag: int, ele_tags: Optional[list[int]] = None, slider: bool = False, response: str = 'Mz', show_values=True, alpha: Optional[float] = None, opacity: float = 1, save_fig: str = 'FrameRespVis.svg')[source]

Display the force response of frame elements.

Parameters

analysis_tag: int

Analysis tag in get_node_resp_step() method.

ele_tags: int or list[int], default=None

Element tags to display, if None, all frame elements will display.

slider: bool, default=False

If True, responses in all steps will display by slider style. If False, the step that max response will display.

response: str, default=’Mz’

Response type. Optional, “Fx”, “Fy”, “Fz”, “My”, “Mz”, “Mx”.

show_values: bool, default=True

If True, will show the response values.

alpha: float, default=None

Scaling factor.

opacity: float, default=1.0

Plane and solid element transparency.

save_fig: str, default=’FrameRespVis.svg’

The file name to output. If False or None, the file will not be generated. The supported formats are:

  • ‘.svg’

  • ‘.eps’

  • ‘.ps’

  • ‘.pdf’

  • ‘.tex’

Returns

None

model_vis(show_node_label: bool = False, show_ele_label: bool = False, show_local_crd: bool = False, label_size: float = 8, show_outline: bool = True, opacity: float = 1.0, save_fig: str = 'ModelVis.svg')[source]

Visualize the model in the current domain.

Parameters

show_node_label: bool, default=False

Whether to display the node label.

show_ele_label: bool, default=False

Whether to display the ele label.

show_local_crd: bool, default=False

Whether to display the local coordinate system.

label_size: float, default=8

The foontsize of node and ele label.

show_outline: bool, default=True

Whether to show the axis frame.

opacity: float, default=1.0

Plane and solid element transparency.

save_fig: str, default=’ModelVis.svg’

The file name to output. If False or None, the file will not be generated. The supported formats are:

  • ‘.svg’

  • ‘.eps’

  • ‘.ps’

  • ‘.pdf’

  • ‘.tex’

Returns

None

opstool.preprocessing module

class opstool.preprocessing.Rebars[source]

Bases: object

A class to create the rebar point.

add_rebar_circle(xo: list[float, float], radius: float, dia: float, gap: float, angle1=0.0, angle2=360, matTag: Optional[int] = None, color: str = 'black', group_name: Optional[str] = None)[source]

Add the rebars along a circle.

Parameters

xolist[float, float]

Center coords, [(xc, yc)].

radius: float

radius.

diafloat

rebar dia.

angle1float

The start angle, degree

angle2float

The end angle, deree

gapfloat

Rebar space

matTagint

OpenSees mat Tag for rebar previously defined.

colorstr or rgb tuple.

Color to plot rebar.

group_namestr

Assign rebar group name.

Returns

None

add_rebar_line(points: list[list[float, float]], dia: float, gap: float, closure: bool = False, matTag: Optional[int] = None, color: str = 'black', group_name: Optional[str] = None)[source]

Add rebar along a line, can be a line or polygon.

Parameters

pointslist[list[float, float]]

A list of rebar coords, [(x1, y1), (x2, y2),…,(xn, yn)]

diafloat

Rebar dia.

gapfloat

Rebar space.

closure: bool, default=False

If True, the rebar line is a closed loop.

matTagint

OpenSees mat Tag for rebar previously defined.

colorstr or rgb tuple.

Color to plot rebar.

group_namestr

Assign rebar group name

Returns

None

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

Bases: object

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

Parameters

sec_namestr

Assign a name to the section

Returns

None

Examples

>>> outlines = [[0, 0], [-0.5, 1], [1.5, 1], [1, 0]]
>>> outlines2 = offset(outlines, d=0.05)
>>> holes1 = [[0.2, 0.2], [0.4, 0.2], [0.4, 0.4], [0.2, 0.4]]
>>> holes2 = [[0.6, 0.2], [0.8, 0.2], [0.8, 0.5], [0.6, 0.5]]
>>> cover = add_polygon(outlines, holes=[outlines2])
>>> core = add_polygon(outlines2, holes=[holes1, holes2])
>>> # create section obj
>>> sec = SecMesh(sec_name="My Section")
>>> sec.assign_group(dict(cover=cover, core=core))
>>> sec.assign_mesh_size(dict(cover=0.001, core=0.005))
>>> sec.assign_ops_matTag(dict(cover=1, core=2))
>>> sec.mesh()
>>> # create rebars data
>>> rebar_lines1 = offset(outlines, d=0.05 + 0.032 / 2)
>>> rebar_lines2 = [[0.2, 0.2], [0.8, 0.8]]
>>> rebars = Rebars()
>>> rebars.add_rebar_line(points=rebar_lines1, dia=0.032, gap=0.1, color="red", matTag=3)
>>> rebars.add_rebar_line(points=rebar_lines2, dia=0.020, gap=0.1, color="black", matTag=3)
>>> sec.add_rebars(rebars)
>>> # get section properties
>>> sec.get_sec_props(plot_centroids=False)
>>> sec.centring()
>>> # sec.rotate(45)
>>> sec.to_file("mysec.py", secTag=1, GJ=10000)
>>> sec.view()
add_rebars(rebars_obj)[source]

Assign the mesh size dict for each mesh

Parameters

rebars_objmesh obj

The instance of Rebars class.

Returns

None

assign_group(group: dict[str, any])[source]

Assign the group dict for each mesh.

Parameters

groupdict

A dict of name as key, mesh 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: dict[str, float])[source]

Assign the mesh size dict for each mesh.

Parameters

mesh_sizedict[str, float]

A dict of name as key, mesh size as value.

Returns

instance

assign_ops_matTag(mat_tag: dict[str, int])[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

get_sec_props(Eref: float = 1.0, display_results: bool = False, plot_centroids: bool = False)[source]

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

Parameters

Eref: float, default=1.0

Reference modulus of elasticity, it is important to analyze the composite section. See sectionproperties doc

display_resultsbool, default=True

whether to display the results.

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)

  • Torsion constant (J)

  • Principal axis angle (phi)

  • ratio of reinforcement (rho_rebar)

  • Effective Material Properties (Effective elastic modulus: E_eff; Effective shear modulus: G_eff; Effective Poisson’s ratio: Nu_eff)

If materials are specified for the cross-section, the area, second moments of area and torsion constant are elastic modulus weighted.

mesh()[source]

Mesh the section.

Returns

mesh_obj : mesh object.

opspy_cmds(secTag: int, GJ: float)[source]

Generate openseespy fiber section command.

Parameters

secTagint

The section tag assigned in OpenSees.

GJfloat

Torsion stiffness.

Returns

None

rotate(theta: float = 0)[source]

Rotate the section clockwise.

Parameters

thetafloat, default=0

Rotation angle, unit: degree.

Returns

None

to_file(output_path: str, secTag: int, GJ: float)[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

Torsion stiffness.

Returns

None

Notes

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

view(fill: bool = True, engine: str = 'plotly', save_html: str = 'SecMesh.html', on_notebook: bool = 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.

Returns

None

opstool.preprocessing.add_circle(xo: list[float, float], radius: float, holes=None, angle1=0.0, angle2=360, n_sub=40, material=None)[source]

Add the circle geom obj.

Parameters

xolist[float, float]

Center coords, [(xc, yc)].

radius: float

radius.

holes: list[list[list[float, float]]].

Hole of the section, a list of multiple hole coords, [hole1, hole2,…holeN], holeN=[(x1, y1), (x2, y2),…,(xn, yn)].

angle1float

The start angle, degree

angle2float

The end angle, deree

n_sub: int

The partition number of the perimeter.

material: material obj

The instance from add_material().

Returns

None

opstool.preprocessing.add_material(name='default', elastic_modulus=1, poissons_ratio=0, yield_strength=1, density=1, color='w')[source]

Add a meterial.

Parameters

namestr, default=’default’

meterial name.

elastic_modulusfloat, default==1

elastic_modulus.

poissons_ratiofloat, default=0

poissons_ratio

yield_strengthfloat, default==1

yield_strength

densityfloat, default=1

density

colorstr or rgb tuple, default==’w’

color for plot this material.

Returns

Material instance

opstool.preprocessing.add_polygon(outline: list[list[float, float]], holes: Optional[list[list[list[float, float]]]] = None, material=None)[source]

Add polygon plane geom obj.

Parameters

outlinelist[list[float, float]]

The coords list of polygon points, [(x1, y1), (x2, y2),…,(xn, yn)]

holes: list[list[list[float, float]]].

Hole of the section, a list of multiple hole coords, [hole1, hole2,…holeN], holeN=[(x1, y1), (x2, y2),…,(xn, yn)].

material: material obj

The instance from add_material().

Returns

polygon obj

opstool.preprocessing.gen_grav_load(ts_tag: int, pattern_tag: int, direction: str = 'Z', factor: float = -9.81)[source]

Applying the gravity loads.

Notes

The mass values are from nodeMass(nodeTag) command, i.e., ones set in mass() command.

Parameters

ts_tag: int

The timeSeries tag you must assign.

pattern_tag: int

The pattern tag you must assign.

direction: str, default=”Z”

The gravity load direction.

factor: float, default=-9.81

The factor applied to the mass values, it should be the multiplication of gravitational acceleration and directional indicators, e.g., -9.81, where 9.81 is the gravitational acceleration and -1 indicates along the negative Z axis. Of course, it can be multiplied by an additional factor to account for additional constant loads, e.g., 1.05 * (-9.81).

Returns

None

opstool.preprocessing.offset(points: list[list[float, float]], d: float)[source]

Offsets closed polygons

Parameters

pointslist[list[float, float]]

A list containing the coordinate points, [(x1, y1),(x2, y2),…,(xn.yn)].

dfloat

Offsets closed polygons, positive values offset inwards, negative values outwards.

Returns

coords: list[[float, float]]

opstool module contents

opstool.load_ops_examples(name: str)[source]

load the examples.

Parameters:

name: str,

Optional, “ArchBridge”, “CableStayedBridge”, “Dam”, “Frame3D”, “Igloo”, “Pier”, “SuspensionBridge”, “SDOF”, “DamBreak”,

Returns:

None