ross.stochastic.ST_FrequencyResponseResults#

class ross.stochastic.ST_FrequencyResponseResults(speed_range, freq_resp, velc_resp, accl_resp)#

Store stochastic results and provide plots for Frequency Response.

Parameters:
speed_rangearray

Array with the speed range in rad/s.

magnitudearray

Array with the frequencies, magnitude (dB) of the frequency response for each pair input/output.

phasearray

Array with the frequencies, phase of the frequency response for each pair input/output.

Returns:
subplotsPlotly graph_objects.make_subplots()

Plotly figure with amplitude vs frequency phase angle vs frequency.

Methods

__init__(speed_range, freq_resp, velc_resp, accl_resp)#
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(percentile=[], conf_interval=[], frequency_units='rad/s', amplitude_units='m/N', phase_units='rad', fig=None, mag_kwargs=None, phase_kwargs=None, polar_kwargs=None, fig_kwargs=None)#

Plot frequency response.

This method plots the frequency and phase response given an output and an input.

This method returns a subplot with:
  • Frequency vs Amplitude;

  • Frequency vs Phase Angle;

  • Polar plot Amplitude vs Phase Angle;

Amplitude can be displacement, velocity or accelaration responses, depending on the unit entered in ‘amplitude_units’. If ‘[length]/[force]’, it displays the displacement; If ‘[speed]/[force]’, it displays the velocity; If ‘[acceleration]/[force]’, it displays the acceleration.

Parameters:
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.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the y axis. Acceptable units are:

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

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

phase_unitsstr, optional

Units for the x axis. 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.

fig_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”, “phase_kwargs” and “polar_kwargs” dictionaries. *See Plotly Python make_subplots Reference for more information.

Returns:
figPlotly graph_objects.make_subplots()

Plotly figure with amplitude vs frequency phase angle vs frequency.

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

Plot stochastic frequency response (magnitude) using Plotly.

This method plots the frequency response magnitude given an output and an input using Plotly. It is possible to plot displacement, velocity and accelaration responses, depending on the unit entered in ‘amplitude_units’. If ‘[length]/[force]’, it displays the displacement; If ‘[speed]/[force]’, it displays the velocity; If ‘[acceleration]/[force]’, it displays the acceleration.

Parameters:
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.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the y axis. Acceptable units are:

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

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

figPlotly graph_objects.Figure()

The figure object with the plot.

line_shapestr, optional

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

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_phase(percentile=[], conf_interval=[], frequency_units='rad/s', amplitude_units='m/N', phase_units='rad', fig=None, **kwargs)#

Plot stochastic frequency response (phase) using Plotly.

This method plots the phase response given an output and an input using Plotly. It is possible to plot displacement, velocity and accelaration responses, depending on the unit entered in ‘amplitude_units’. If ‘[length]/[force]’, it displays the displacement; If ‘[speed]/[force]’, it displays the velocity; If ‘[acceleration]/[force]’, it displays the acceleration.

Parameters:
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.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the y axis. Acceptable units are:

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

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

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(percentile=[], conf_interval=[], frequency_units='rad/s', amplitude_units='m/N', phase_units='rad', fig=None, **kwargs)#

Plot stochastic frequency response (polar) using Plotly.

This method plots the frequency response (polar graph) given an output and an input using Plotly. It is possible to plot displacement, velocity and accelaration responses, depending on the unit entered in ‘amplitude_units’. If ‘[length]/[force]’, it displays the displacement; If ‘[speed]/[force]’, it displays the velocity; If ‘[acceleration]/[force]’, it displays the acceleration.

Parameters:
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.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the y axis. Acceptable units are:

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

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

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)