ross.FrequencyResponseResults#

class ross.FrequencyResponseResults(freq_resp, velc_resp, accl_resp, speed_range, number_dof)#

Class used to store results and provide plots for Frequency Response.

Parameters
freq_resparray

Array with the frequency response (displacement).

velc_resparray

Array with the frequency response (velocity).

accl_resparray

Array with the frequency response (acceleration).

speed_rangearray

Array with the speed range in rad/s.

number_dofint

Number of degrees of freedom per node.

Returns
subplotsPlotly graph_objects.make_subplots()

Plotly figure with Amplitude vs Frequency and Phase vs Frequency plots.

Methods

__init__(freq_resp, velc_resp, accl_resp, speed_range, number_dof)#
classmethod load(file)#

Load results from a .toml file.

This function will load the simulation results from a .toml 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 as rs
>>> # Running an example
>>> rotor = rs.rotor_example()
>>> freq_range = np.linspace(0, 500, 31)
>>> n = 3
>>> m = 0.01
>>> p = 0.0
>>> results = rotor.run_unbalance_response(n, m, p, freq_range)
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'unb_resp.toml'
>>> results.save(file)
>>> # Loading file
>>> results2 = rs.ForcedResponseResults.load(file)
>>> abs(results2.forced_resp).all() == abs(results.forced_resp).all()
True
plot(inp, out, 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 response given an output and an input using Plotly.

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

  • Frequency vs Phase Angle;

  • Polar plot Amplitude vs Phase Angle;

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

Parameters
inpint

Input.

outint

Output.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the response magnitude. Acceptable units dimensionality are:

‘[length]’ - Displays the magnitude with units (m/N);

‘[speed]’ - Displays the magnitude with units (m/s/N);

‘[acceleration]’ - Displays the magnitude with units (m/s**2/N).

Default is “m/N” 0 to peak. To use peak to peak use ‘<unit> pkpk’ (e.g. ‘m/N pkpk’)

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
subplotsPlotly graph_objects.make_subplots()

Plotly figure with Amplitude vs Frequency and Phase vs Frequency and polar Amplitude vs Phase plots.

plot_magnitude(inp, out, frequency_units='rad/s', amplitude_units='m/N', fig=None, **mag_kwargs)#

Plot 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 the magnitude with different units, depending on the unit entered in ‘amplitude_units’. If ‘[length]/[force]’, it displays the displacement unit (m); If ‘[speed]/[force]’, it displays the velocity unit (m/s); If ‘[acceleration]/[force]’, it displays the acceleration unit (m/s**2).

Parameters
inpint

Input.

outint

Output.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the response magnitude. Acceptable units dimensionality are:

‘[length]’ - Displays the magnitude with units (m/N);

‘[speed]’ - Displays the magnitude with units (m/s/N);

‘[acceleration]’ - Displays the magnitude with units (m/s**2/N).

Default is “m/N” 0 to peak. To use peak to peak use ‘<unit> pkpk’ (e.g. ‘m/N pkpk’)

figPlotly graph_objects.Figure()

The figure object with the plot.

mag_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(inp, out, frequency_units='rad/s', amplitude_units='m/N', phase_units='rad', fig=None, **phase_kwargs)#

Plot frequency response (phase) using Plotly.

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

Parameters
inpint

Input.

outint

Output.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the response magnitude. Acceptable units dimensionality are:

‘[length]’ - Displays the magnitude with units (m/N);

‘[speed]’ - Displays the magnitude with units (m/s/N);

‘[acceleration]’ - Displays the magnitude with units (m/s**2/N).

Default is “m/N” 0 to peak. To use peak to peak use ‘<unit> pkpk’ (e.g. ‘m/N pkpk’)

phase_unitsstr, optional

Units for the x axis. Default is “rad”

figPlotly graph_objects.Figure()

The figure object with the plot.

phase_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(inp, out, frequency_units='rad/s', amplitude_units='m/N', phase_units='rad', fig=None, **polar_kwargs)#

Plot 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
inpint

Input.

outint

Output.

frequency_unitsstr, optional

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

amplitude_unitsstr, optional

Units for the response magnitude. Acceptable units dimensionality are:

‘[length]’ - Displays the displacement;

‘[speed]’ - Displays the velocity;

‘[acceleration]’ - Displays the acceleration.

Default is “m/N” 0 to peak. To use peak to peak use ‘<unit> pkpk’ (e.g. ‘m/N pkpk’)

phase_unitsstr, optional

Units for the x axis. Default is “rad”

figPlotly graph_objects.Figure()

The figure object with the plot.

polar_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 file.

This function will save the simulation results to a .toml 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.

Examples

>>> # Example running a unbalance response
>>> from tempfile import tempdir
>>> from pathlib import Path
>>> import ross as rs
>>> # Running an example
>>> rotor = rs.rotor_example()
>>> speed = np.linspace(0, 1000, 101)
>>> response = rotor.run_unbalance_response(node=3,
...                                         unbalance_magnitude=0.001,
...                                         unbalance_phase=0.0,
...                                         frequency=speed)
>>> # create path for a temporary file
>>> file = Path(tempdir) / 'unb_resp.toml'
>>> response.save(file)