ross.HarmonicBalanceResults#

class ross.HarmonicBalanceResults(rotor, speed, t, Qt, Qo, dQ, dQ_s, n_harmonics)#

Class used to store results and provide plots for Harmonic Balance Analysis. Stores and provides methods for post-processing results from Harmonic Balance analysis.

Parameters:
rotorross.Rotor

Rotor object.

speedfloat

Rotor rotational speed (rad/s).

tarray

Time array (s).

Qtarray

Complex displacement vector in frequency domain.

Qoarray

Static displacement vector.

dQarray

Harmonic displacement coefficients.

dQ_sarray

Complex conjugate of harmonic coefficients.

n_harmonicsint

Number of harmonics.

Methods

__init__(rotor, speed, t, Qt, Qo, dQ, dQ_s, n_harmonics)#
data(probe, amplitude_units='m', frequency_units='rad/s')#

Return the frequency response given a list of probes in DataFrame format.

Parameters:
probelist

List with rs.Probe objects.

amplitude_unitsstr, optional

Units for the response magnitude. Default is “m”.

frequency_unitsstr

Frequency units. Default is “rad/s”.

Returns:
dfpd.DataFrame

DataFrame storing the frequency response measured by probes.

get_time_response()#

Get the time response results.

Returns:
time_respTimeResponseResults

Time response results object.

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 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(probe, amplitude_units='m', frequency_units='Hz', fig=None, **kwargs)#

Plot frequency response.

This method plots the frequency response using Plotly.

Parameters:
probelist

List with rs.Probe objects.

amplitude_unitsstr, optional

Units for the response magnitude. Default is “m”.

frequency_unitsstr

Frequency units. Default is “Hz”.

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_deflected_shape(frequency_units='rad/s', amplitude_units='m', phase_units='rad', rotor_length_units='m', moment_units='N*m', unbalance=None, shape2d_kwargs=None, shape3d_kwargs=None, bm_kwargs=None, subplot_kwargs=None)#

Plot deflected shape diagrams.

This method returns a subplot with:
  • 3D view deflected shape;

  • 2D view deflected shape - Major Axis;

  • Bending Moment Diagram;

Parameters:
harmonicint

Harmonic number to plot the deflected shape.

frequency_unitsstr, optional

Frequency units. 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_untisstr, optional

Phase units. Default is “rad”.

rotor_length_unitsstr, optional

Rotor length units. Default is ‘m’.

moment_unitsstr

Moment units. Default is ‘N*m’

unbalancearray, optional

Array containing unbalance information in the format: np.array([nodes, magnitudes, phases]), where:

  • nodeslist of int

    Node or list of nodes where the unbalance is located.

  • magnitudeslist of float

    Unbalance magnitudes (kg·m).

  • phaseslist of float

    Unbalance phase angles (rad).

shape2d_kwargsoptional

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

shape3d_kwargsoptional

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

bm_kwargsoptional

Additional key word arguments can be passed to change the bending moment diagram 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 and Phase vs Frequency and polar Amplitude vs Phase plots.

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 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)