import ross as rs
import numpy as np
# Elements → Rotor → Analysis → Results
steel = rs.Material(name="steel", rho=7810, E=211e9, G_s=81.2e9)
shaft = [rs.ShaftElement(L=0.05, idl=0, odl=0.05, material=steel) for _ in range(6)]
disks = [
rs.DiskElement.from_geometry(n=2, material=steel, width=0.07, i_d=0.05, o_d=0.28),
rs.DiskElement.from_geometry(n=4, material=steel, width=0.07, i_d=0.05, o_d=0.35),
]
bearings = [rs.BearingElement(n=0, kxx=1e6, cxx=0), rs.BearingElement(n=6, kxx=1e6, cxx=0)]
rotor = rs.Rotor(shaft, disks, bearings)
modal = rotor.run_modal(speed=0)
modal.plot_mode_2d(0)| Method | Purpose | Returns | Key Plots | Cookbook |
|---|---|---|---|---|
run_modal(speed) |
Natural frequencies and mode shapes | ModalResults |
plot_mode_2d(), plot_mode_3d(), plot_orbit() |
modal_analysis |
run_campbell(speed_range) |
Campbell diagram | CampbellResults |
plot(), plot_with_mode_shape() |
campbell_diagram |
run_critical_speed() |
Critical speeds and damping ratios | CriticalSpeedResults |
— | critical_speed |
run_static() |
Static deformation and forces | StaticResults |
plot_deformation(), plot_bending_moment(), plot_shearing_force(), plot_free_body_diagram() |
static_analysis |
run_unbalance_response(node, ...) |
Unbalance response | ForcedResponseResults |
plot_magnitude(probe), plot_phase(probe), plot_bode(probe), plot_deflected_shape(speed) |
unbalance_response |
run_forced_response(force, ...) |
General forced response | ForcedResponseResults |
same as above | frequency_response |
run_freq_response() |
Frequency response function (FRF) | FrequencyResponseResults |
plot_magnitude(inp, out), plot_phase(inp, out), plot_polar_bode(inp, out) |
frequency_response |
run_time_response(speed, F, t) |
Time-domain response | TimeResponseResults |
plot_1d(probe), plot_2d(node), plot_3d(), plot_dfft(probe) |
time_response |
run_ucs() |
Undamped critical speed map | UCSResults |
plot() |
ucs_and_level1 |
run_level1() |
API 617 Level 1 stability | Level1Results |
plot() |
ucs_and_level1 |
run_misalignment(...) |
Misalignment fault analysis | TimeResponseResults |
plot_1d(), plot_2d(), plot_dfft() |
faults |
run_rubbing(...) |
Rubbing fault analysis | TimeResponseResults |
same as above | faults |
run_crack(...) |
Crack fault analysis | TimeResponseResults |
same as above | faults |
run_harmonic_balance_response(...) |
Harmonic balance steady-state | HarmonicBalanceResults |
plot() |
— |
run_amb_sensitivity(...) |
AMB sensitivity analysis | SensitivityResults |
plot(), plot_time_results() |
— |
All values are SI internally:
- Speed: rad/s (convert with
rs.Q_(4000, "RPM").to("rad/s").m) - Stiffness: N/m
- Damping: N·s/m
- Unbalance magnitude: kg·m
- Mass moment of inertia: kg·m²
Use rs.Q_(value, "unit") for pint-based unit conversion.
| Function | Description |
|---|---|
rs.rotor_example() |
Simple rotor: 6 shafts, 2 disks, 2 bearings |
rs.compressor_example() |
Industrial compressor: 91 shafts, 7 disks, 14 bearings/seals |
rs.rotor_example_6dof() |
6-DOF rotor with axial stiffness |
rs.rotor_example_with_damping() |
Rotor with internal material damping |
rs.coaxrotor_example() |
Coaxial rotor (two concentric shafts) |
rs.rotor_amb_example() |
Rotor with active magnetic bearings |
rotor.save("my_rotor.toml")
rotor = rs.Rotor.load("my_rotor.toml")For complete analysis recipes, read the relevant file in docs/cookbook/. See the index for all available recipes.
ROSS (Rotordynamic Open Source Software) is a Python library for rotordynamic analysis. Package name: ross-rotordynamics.
- Main branch:
main - Upstream remote:
upstream→petrobras/ross(PRs target this repo) - Fork remote:
origin→ the developer's personal fork - Push development branches to
origin, then open PRs againstupstream/main
pip install -e ".[dev]" # development install with test/lint/docs depsRequires Python >= 3.9.
pytest ross # run from repo root- Doctests enabled via
--doctest-modules(configured inpytest.ini) - Tests live in
ross/tests/, one file per module (e.g.test_shaft_element.py,test_rotor_assembly.py) - No test classes — all tests are plain functions (
def test_*():) - Shared setup goes in
@pytest.fixturefunctions at the top of the file - Use
assert_allclose/assert_almost_equalfromnumpy.testingfor numerical comparisons - Docstring examples are tested by CI; use
# doctest: +ELLIPSISwith...for truncated output
Ruff handles both linting and formatting. Pre-commit hooks are configured.
ruff check ross # lint
ruff format ross # format
pre-commit run --all-files # run all hooks- Double quotes for strings and docstrings
- Quote style enforced in
[tool.ruff.format]and[tool.ruff.lint.flake8-quotes]
- PascalCase for classes, snake_case for functions/methods
- Names should be self-explanatory — do not use comments to split or label sections of code; rely on clear class and function names instead
- NumPy-style:
Parameters,Returns,Examples,Referencessections - First line in imperative mood, ending with a period
- Type info goes in docstrings, not type annotations
All elements inherit from Element ABC (ross/element.py) and must implement:
M()— mass matrixK(frequency)— stiffness matrixC(frequency)— damping matrixG()— gyroscopic matrixdof_mapping()— degree-of-freedom mapping
- Factory classmethods:
from_geometry(),from_table()for alternative constructors - Example functions:
*_example()returning simple instances for use in doctests @check_unitsdecorator: pint unit handling on__init__methods- Serialization: TOML-based via
save()/load()methods - Visualization: Plotly with custom ROSS theme; results objects have
.plot_*()methods - Matrix formatting: use
# fmt: off/# fmt: onto preserve matrix layout
Elements → Rotor assembly → .run_*() analysis methods → Results objects with .plot_*() methods
Key modules:
ross/element.py— baseElementABCross/shaft_element.py,ross/disk_element.py,ross/bearing_seal_element.py— core elementsross/rotor_assembly.py—Rotorclass assembling global matrices and running analysesross/results.py— results containers with plotting methods
numpy, scipy, plotly, pandas, pint, numba, toml