SmartAnalyze

class opstool.anlys.SmartAnalyze(analysis_type='Transient', **kargs)[source]

Bases: object

The SmartAnalyze is a class to provide OpenSeesPy users an easier way to conduct analyses. Original Tcl version Author: Dr. Dong Hanlin, see here. Here’s the converted python version, with some modifications.

Parameters

analysis_type: str, default=”Transient”

Assign the analysis type, “Transient” or “Static”.

Other Parameters that control convergence

Examples

The following example demonstrates how to use the SmartAnalyze class.

Note

  • test() and algorithm() will run automatically in SmartAnalyze;

  • Static analysis only supports displacement control;

  • Commands such as integrator() must be defined outside SmartAnalyze for ransient analysis.

Example 1: Basic usage for Transient

>>> import opstool as opst
>>> ops.constraints('Transformation')
>>> ops.numberer('Plain')
>>> ops.system('BandGeneral')
>>> ops.integrator('Newmark', 0.5, 0.25)  # Dynamic analysis requires external settings
>>> analysis = opst.anlys.SmartAnalyze(analysis_type="Transient")
>>> npts, dt = 1000, 0.01
>>> # Tells the program the total number of steps, which is necessary for outputting a progress bar
>>> segs = analysis.transient_split(npts)
>>> for _ in segs:
>>>     analysis.TransientAnalyze(dt)

Example 2: Basic usage for Static

>>> import opstool as opst
>>> ops.constraints('Transformation')
>>> ops.numberer('Plain')
>>> ops.system('BandGeneral')
>>> protocol=[0.5, -0.5, 1, -1, 0]  # Load Profile
>>> analysis = opst.anlys.SmartAnalyze(analysis_type="Static")
>>> segs = analysis.static_split(protocol, 0.01)  # Use a step size of 0.01 to segment the profile.
>>> print(segs)
>>> for seg in segs:
>>>     analysis.StaticAnalyze(node=1, dof=2, seg=seg)  # node tag 1, dof 2

Example 3: change control parameters

>>> analysis = opst.anlys.SmartAnalyze(
>>>    analysis_type="Transient",
>>>    tryAlterAlgoTypes=True,
>>>    algoTypes=[40, 30, 20],
>>>    tryAddTestTimes=True,
>>>    testIterTimesMore=[50, 100],
>>>    relaxation=0.5,
>>>    minStep=1e-5,
>>>    printPer=20,
>>>)

Methods

StaticAnalyze

Single step static analysis and applies to displacement control only.

TransientAnalyze

Single Step Transient Analysis.

close

Close the class.

set_sensitivity_algorithm

Set analysis sensitivity algorithm.

static_split

Returns a sequence of substeps for static analysis.

transient_split

Step Segmentation for Transient Analysis.

transient_split(npts)[source]

Step Segmentation for Transient Analysis. The main purpose of this function is to tell the program the total number of analysis steps to show progress. However, this is not necessary.

Parameters

nptsint

Total steps for transient analysis.

Returns

A list to loop.

static_split(targets, maxStep=None)[source]

Returns a sequence of substeps for static analysis.

Parameters

targetslist, tuple, or np.ndarray

Target displacements. First element should be ≥ 0.

maxStepfloat, optional

Maximum step size. If None, uses difference between first two targets.

Returns

segslist of float

Sequence of substeps to reach each target displacement.

set_sensitivity_algorithm(algorithm='-computeAtEachStep')[source]

Set analysis sensitivity algorithm. Since the Smart Static Analysis may reset the integrator, the sensitivity analysis algorithm will need to be reset afterwards.

Parameters

algorithm: Sensitivity analysis algorithm, default: “-computeAtEachStep”.

Optional: “-computeAtEachStep” or “-computeByCommand”.

Return

None

TransientAnalyze(dt)[source]

Single Step Transient Analysis.

Parameters

dtfloat

Time Step.

Returns

Return 0 if successful, otherwise returns a negative number.

StaticAnalyze(node, dof, seg)[source]

Single step static analysis and applies to displacement control only.

Parameters

nodeint

The node tag in the displacement control.

dofint

The dof in the displacement control.

segfloat

Each load step, i.e., each element returned by static_split.

Returns

Return 0 if successful, otherwise returns a negative number.

close()[source]

Close the class.

Returns:

None