ross.stochastic.ST_CampbellResults
Contents
ross.stochastic.ST_CampbellResults#
- class ross.stochastic.ST_CampbellResults(speed_range, wd, log_dec, mode_type)#
Store stochastic results and provide plots for Campbell Diagram.
It’s possible to visualize multiples harmonics in a single plot to check other speeds which also excite a specific natural frequency. Two options for plooting are available: Matplotlib and Bokeh. The user chooses between them using the attribute plot_type. The default is bokeh
- Parameters:
- speed_rangearray
Array with the speed range in rad/s.
- wdarray
Array with the damped natural frequencies
- log_decarray
Array with the Logarithmic decrement
- Returns:
- subplotsPlotly graph_objects.make_subplots()
Plotly figure with diagrams for frequency and log dec.
Methods
- __init__(speed_range, wd, log_dec, mode_type)#
- 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=[], harmonics=[1], frequency_units='rad/s', freq_kwargs=None, logdec_kwargs=None, fig_kwargs=None)#
Plot Campbell Diagram.
This method plots Campbell Diagram.
- 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.
- harmonics: list, optional
List withe the harmonics to be plotted. The default is to plot 1x.
- frequency_unitsstr, optional
Frequency units. Default is “rad/s”
- freq_kwargsdict, optional
Additional key word arguments can be passed to change the natural frequency vs frequency plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.
- logdec_kwargsdict, optional
Additional key word arguments can be passed to change the log. decrement vs frequency plot layout only (e.g. width=1000, height=800, …). *See Plotly Python Figure Reference for more information.
- fig_kwargsdict, optional
Additional key word arguments can be passed to change the plot layout only (e.g. width=1000, height=800, …). This kwargs override “freq_kwargs”, “logdec_kwargs” dictionaries. *See Plotly Python make_subplots Reference for more information.
- Returns:
- subplotsPlotly graph_objects.make_subplots()
Plotly figure with diagrams for frequency and log dec.
- plot_log_dec(percentile=[], conf_interval=[], frequency_units='rad/s', **kwargs)#
Plot the log. decrement vs frequency.
- 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
Frequency units. Default is “rad/s”
- 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_nat_freq(percentile=[], conf_interval=[], harmonics=[1], frequency_units='rad/s', **kwargs)#
Plot the damped natural frequencies vs frequency.
- 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.
- harmonics: list, optional
List withe the harmonics to be plotted. The default is to plot 1x.
- frequency_unitsstr, optional
Frequency units. Default is “rad/s”
- 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)