ross.stochastic.ST_ForcedResponseResults#

class ross.stochastic.ST_ForcedResponseResults(forced_resp, velc_resp, accl_resp, frequency_range, number_dof, nodes, link_nodes)#

Store stochastic results and provide plots for Forced Response.

Parameters:
force_resparray

Array with the force response for each node for each frequency.

frequency_rangearray

Array with the frequencies.

velc_resparray

Array with the forced response (velocity) for each node for each frequency.

accl_resparray

Array with the forced response (acceleration) for each node for each frequency.

number_dof = int

Number of degrees of freedom per shaft element’s node.

nodeslist

List of shaft nodes.

link_nodeslist

List of n_link nodes.

Returns:
subplotsPlotly graph_objects.make_subplots()

Plotly figure with amplitude vs frequency phase angle vs frequency.

Methods

__init__(forced_resp, velc_resp, accl_resp, frequency_range, number_dof, nodes, link_nodes)#
classmethod load(file)#

Load results from a .toml or .json file.

This function will load the simulation results from a .toml or .json file. The file must have all the argument’s names and values that are needed to reinstantiate the class.

Parameters:
filestr, pathlib.Path

The name of the file the results will be loaded from.

Examples

>>> # Example running a stochastic unbalance response
>>> from tempfile import tempdir
>>> from pathlib import Path
>>> import ross.stochastic as srs
>>> # Running an example
>>> rotors = srs.st_rotor_example()
>>> freq_range = np.linspace(0, 500, 31)
>>> n = 3
>>> m = np.random.uniform(0.001, 0.002, 10)
>>> p = 0.0
>>> results = rotors.run_unbalance_response(n, m, p, freq_range)
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'results.toml'
>>> results.save(file)
>>> # Loading file
>>> results2 = srs.ST_ForcedResponseResults.load(file)
>>> results2.forced_resp.all() == results.forced_resp.all()
True
plot(probe, percentile=[], conf_interval=[], probe_units='rad', frequency_units='rad/s', amplitude_units='m', phase_units='rad', mag_kwargs=None, phase_kwargs=None, polar_kwargs=None, subplot_kwargs=None)#

Plot stochastic forced response using Plotly.

This method plots the forced response given a set of probes.

Parameters:
probelist of tuples

List with tuples (node, orientation angle, tag). node : int

indicate the node where the probe is located.

orientationfloat

probe orientation angle about the shaft. The 0 refers to +X direction.

tagstr, optional

probe tag to be displayed at the legend.

percentilelist, optional

Sequence of percentiles to compute, which must be between 0 and 100 inclusive.

conf_intervallist, optional

Sequence of confidence intervals to compute, which must be between 0 and 100 inclusive.

probe_unitsstr, option

Units for probe orientation. Default is “rad”.

frequency_unitsstr, optional

Frequency units. Default is “rad/s”

amplitude_unitsstr, optional

Units for the y axis. Acceptable units dimensionality are:

‘[length]’ - Displays the displacement; ‘[speed]’ - Displays the velocity; ‘[acceleration]’ - Displays the acceleration.

Default is “m” 0 to peak. To use peak to peak use the prefix ‘pkpk_’ (e.g. pkpk_m)

phase_unitsstr, optional

Phase units. Default is “rad”

mag_kwargsoptional

Additional key word arguments can be passed to change the magnitude plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

phase_kwargsoptional

Additional key word arguments can be passed to change the phase plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

polar_kwargsoptional

Additional key word arguments can be passed to change the polar plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

subplot_kwargsoptional

Additional key word arguments can be passed to change the plot layout only (e.g. width=1000, height=800, …). This kwargs override “mag_kwargs” and “phase_kwargs” dictionaries. *See Plotly Python Figure Reference for more information.

Returns:
subplotsPlotly graph_objects.make_subplots()

Plotly figure with amplitude vs frequency phase angle vs frequency.

plot_magnitude(probe, percentile=[], conf_interval=[], probe_units='rad', frequency_units='rad/s', amplitude_units='m', fig=None, line_shape='linear', **kwargs)#

Plot stochastic frequency response.

This method plots the unbalance response magnitude.

Parameters:
probelist of tuples

List with tuples (node, orientation angle, tag). node : int

indicate the node where the probe is located.

orientationfloat

probe orientation angle about the shaft. The 0 refers to +X direction.

tagstr, optional

probe tag to be displayed at the legend.

percentilelist, optional

Sequence of percentiles to compute, which must be between 0 and 100 inclusive.

conf_intervallist, optional

Sequence of confidence intervals to compute, which must be between 0% and 100% inclusive.

probe_unitsstr, option

Units for probe orientation. Default is “rad”.

frequency_unitsstr, optional

Units for the x axis. Default is “rad/s”

amplitude_unitsstr, optional

Units for the y axis. Acceptable units dimensionality are:

‘[length]’ - Displays the displacement; ‘[speed]’ - Displays the velocity; ‘[acceleration]’ - Displays the acceleration.

Default is “m” 0 to peak. To use peak to peak use the prefix ‘pkpk_’ (e.g. pkpk_m)

figPlotly graph_objects.Figure()

The figure object with the plot.

kwargsoptional

Additional key word arguments can be passed to change the plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

Returns:
figPlotly graph_objects.Figure()

Bokeh plot axes with magnitude plot.

line_shapestr, optional

Line interpolation style for the Plotly traces (e.g. “linear”, “spline”). Default is “linear”.

plot_phase(probe, percentile=[], conf_interval=[], probe_units='rad', frequency_units='rad/s', amplitude_units='m', phase_units='rad', fig=None, **kwargs)#

Plot stochastic frequency response.

This method plots the phase response given a set of probes.

Parameters:
probelist of tuples

List with tuples (node, orientation angle, tag). node : int

indicate the node where the probe is located.

orientationfloat

probe orientation angle about the shaft. The 0 refers to +X direction.

tagstr, optional

probe tag to be displayed at the legend.

percentilelist, optional

Sequence of percentiles to compute, which must be between 0 and 100 inclusive.

conf_intervallist, optional

Sequence of confidence intervals to compute, which must be between 0 and 100 inclusive.

probe_unitsstr, option

Units for probe orientation. Default is “rad”.

frequency_unitsstr, optional

Units for the x axis. Default is “rad/s”

amplitude_unitsstr, optional

Units for the y axis. Acceptable units dimensionality are:

‘[length]’ - Displays the displacement; ‘[speed]’ - Displays the velocity; ‘[acceleration]’ - Displays the acceleration.

Default is “m” 0 to peak. To use peak to peak use the prefix ‘pkpk_’ (e.g. pkpk_m)

phase_unitsstr, optional

Units for the x axis. Default is “rad”

figPlotly graph_objects.Figure()

The figure object with the plot.

kwargsoptional

Additional key word arguments can be passed to change the plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

Returns:
figPlotly graph_objects.Figure()

The figure object with the plot.

plot_polar_bode(probe, percentile=[], conf_interval=[], probe_units='rad', frequency_units='rad/s', amplitude_units='m', phase_units='rad', fig=None, **kwargs)#

Plot polar forced response using Plotly.

Parameters:
probelist of tuples

List with tuples (node, orientation angle, tag). node : int

indicate the node where the probe is located.

orientationfloat

probe orientation angle about the shaft. The 0 refers to +X direction.

tagstr, optional

probe tag to be displayed at the legend.

percentilelist, optional

Sequence of percentiles to compute, which must be between 0 and 100 inclusive.

conf_intervallist, optional

Sequence of confidence intervals to compute, which must be between 0 and 100 inclusive.

probe_unitsstr, option

Units for probe orientation. Default is “rad”.

frequency_unitsstr, optional

Units for the x axis. Default is “rad/s”

amplitude_unitsstr, optional

Units for the y axis. Acceptable units dimensionality are:

‘[length]’ - Displays the displacement; ‘[speed]’ - Displays the velocity; ‘[acceleration]’ - Displays the acceleration.

Default is “m” 0 to peak. To use peak to peak use the prefix ‘pkpk_’ (e.g. pkpk_m)

phase_unitsstr, optional

Units for the x axis. Default is “rad”

figPlotly graph_objects.Figure()

The figure object with the plot.

kwargsoptional

Additional key word arguments can be passed to change the plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.

Returns:
figPlotly graph_objects.Figure()

The figure object with the plot.

classmethod read_toml_data(data)#

Read and parse data stored in a .toml file.

The data passed to this method needs to be according to the format saved in the .toml file by the .save() method.

Parameters:
datadict

Dictionary obtained from toml.load().

Returns:
The result object.
save(file)#

Save results in a .toml or .json file.

This function will save the simulation results to a .toml or .json file. The file will have all the argument’s names and values that are needed to reinstantiate the class.

Parameters:
filestr, pathlib.Path

The name of the file the results will be saved in. The format is determined by the file extension (.toml or .json).

Examples

>>> # Example running a stochastic unbalance response
>>> from tempfile import tempdir
>>> from pathlib import Path
>>> import ross.stochastic as srs
>>> # Running an example
>>> rotors = srs.st_rotor_example()
>>> freq_range = np.linspace(0, 500, 31)
>>> n = 3
>>> m = np.random.uniform(0.001, 0.002, 10)
>>> p = 0.0
>>> results = rotors.run_unbalance_response(n, m, p, freq_range)
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'results.toml'
>>> results.save(file)