### Load Example Rotor Model and Plot (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_2_1.ipynb Loads a pre-defined example rotor model ('compressor_example') from the ROSS library and visualizes its geometry with specified node increments. ```python rotor3 = rs.compressor_example() node_increment = 5 rotor3.plot_rotor(nodes=node_increment) ``` -------------------------------- ### Example using BearingElement in Python Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/elements/ross.DiskElement.md Demonstrates how to create and use a BearingElement from the ross library. It shows how to instantiate an example bearing and access its local degree of freedom indices. ```python >>> # Example using BearingElement >>> from ross.bearing_seal_element import bearing_example >>> bearing = bearing_example() >>> bearing.dof_local_index() LocalIndex(x_0=0, y_0=1, z_0=2) ``` -------------------------------- ### Example: Running Unbalance Response and Saving Results Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.TimeResponseResults.md Demonstrates how to run an unbalance response simulation and save the results to a TOML file. This example utilizes `rotor_example()`, `np.linspace`, `run_unbalance_response`, and the `save` method. ```python # 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) ``` -------------------------------- ### Install ROSS Development Version from GitHub using Pip Source: https://github.com/petrobras/ross/blob/main/docs/getting_started/installation.md Installs the most recent development version of the ROSS package directly from its GitHub repository. This is useful for users who want to test the latest features or contribute to the project. Requires Git to be installed. ```bash pip install git+https://github.com/petrobras/ross.git ``` -------------------------------- ### Example: Running and Saving Unbalance Response Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.TimeResponseResults.md Demonstrates how to run an unbalance response analysis for a rotor system, save the results to a TOML file, and then load them back. This example showcases the workflow for saving and loading simulation outputs. ```python import ross as rs from tempfile import tempdir from pathlib import Path 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) file = Path(tempdir) / 'unb_resp.toml' results.save(file) results2 = rs.ForcedResponseResults.load(file) print(abs(results2.forced_resp).all() == abs(results.forced_resp).all()) ``` -------------------------------- ### Run and Save Unbalance Response Example Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.StaticResults.md This example demonstrates running an unbalance response analysis and saving the results to a TOML file. It then loads the results back to verify integrity. This showcases the save and load functionality for analysis results. ```python from tempfile import tempdir from pathlib import Path import ross as rs import numpy as np # Running an example rotor = rs.rotor_example() freq_range = np.linspace(0, 500, 31) n = 0.01 # Example unbalance mass 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) # Verification print(np.allclose(np.abs(results2.forced_resp), np.abs(results.forced_resp))) ``` -------------------------------- ### run_harmonic_balance_response Example Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/rotor/ross.MultiRotor.md Example of running a harmonic balance response analysis for a rotor system. ```APIDOC ## run_harmonic_balance_response Example ### Description This code snippet demonstrates how to use the `run_harmonic_balance_response` method to simulate the system's time response under harmonic forces, such as unbalance. ### Method POST (Conceptual - this is a library function call, not a web API) ### Endpoint N/A (Library Function) ### Parameters This example uses the following parameters: #### Path Parameters None #### Query Parameters None #### Request Body (Conceptual - parameters passed directly to the function) - **rotor**: An instance of the Rotor class. - **speed** (float): The rotational speed of the rotor. - **t** (numpy.ndarray): Time array for the simulation. - **harmonic_forces** (list of dict): A list where each dictionary defines a harmonic force with: - **node** (int): The node where the force is applied. - **magnitudes** (list of float): List of force magnitudes. - **phases** (list of float): List of force phases in radians. - **harmonics** (list of int): List of harmonic numbers (typically 1 for unbalance). - **gravity** (bool): Whether to include gravity effects. - **n_harmonics** (int): The number of harmonics to consider in the analysis. ### Request Example ```python import ross as rs import numpy as np rotor = rs.rotor_example() speed = 200.0 unb_node = 3 unb_mag = 0.05 * speed**2 unb_phase = 0.0 unb_harmonic = 1 results = rotor.run_harmonic_balance_response( speed=speed, t=np.linspace(0, 0.5, 1001), harmonic_forces=[ { "node": unb_node, "magnitudes": [unb_mag], "phases": [unb_phase], "harmonics": [unb_harmonic], } ], gravity=False, n_harmonics=1, ) time_resp = results.get_time_response() # Example of plotting from ross.probe import Probe probe1 = Probe(3, 0) fig1 = time_resp.plot_1d(probe=[probe1]) fig2 = time_resp.plot_dfft(probe=[probe1]) ``` ### Response #### Success Response (200) - **results** (object): An object containing the results of the harmonic balance analysis, with methods like `get_time_response()`. #### Response Example (The `results` object itself is the response. Specific data would be accessed via its methods.) ```json { "message": "Harmonic balance response analysis completed successfully.", "results_object": "" } ``` ``` -------------------------------- ### Run Unbalance Response Example (Python) Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.UCSResults.md Demonstrates how to run an unbalance response simulation using the Ross library. It includes setting up a rotor example, defining speeds, and calculating the response for a specific node and unbalance parameters. The results can then be saved to a TOML file. ```python >>> # 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) ``` -------------------------------- ### Example: Running Unbalance Response Simulation Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.StaticResults.md Demonstrates how to run an unbalance response simulation using the Ross library. This example involves creating a rotor object, defining a speed range, and calculating the response to an unbalance. The results can then be saved to a TOML file. ```python from tempfile import tempdir from pathlib import Path import ross as rs import numpy as np # Example running a unbalance response 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) ``` -------------------------------- ### Run Time Response and Magnetic Bearing Control Example (Python) Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/rotor/ross.MultiRotor.md This example demonstrates how to simulate the time response of a rotor system with magnetic bearings using the 'ross' library. It initializes a rotor, applies forces, runs a Newmark integration for time response, and then calculates the magnetic force based on the response. It shows how to extract specific bearing elements and compute their control forces. ```python >>> import ross as rs >>> import numpy as np >>> rotor = rs.rotor_amb_example() >>> dt, speed, step = 1e-4, 1000, 1 >>> t = np.arange(0, 5 * dt, dt) >>> node = [27, 29] >>> mass = [10, 10] >>> F = np.zeros((len(t), rotor.ndof)) >>> for n, m in zip(node,mass): ... F[:, 6 * n + 0] = m * np.cos((speed * t)) ... F[:, 6 * n + 1] = (m-5) * np.sin((speed * t)) >>> response = rotor.run_time_response(speed, F, t, method = "newmark") Running direct method >>> magnetic_bearings = [brg for brg in rotor.bearing_elements if isinstance(brg, rs.bearing_seal_element.MagneticBearingElement)] >>> magnetic_force = rotor.magnetic_bearing_controller(step, magnetic_bearings, dt, response.yout[-1,:]) >>> np.nonzero(magnetic_force)[0] array([ 72, 73, 258, 259]) >>> magnetic_force[np.nonzero(magnetic_force)[0]] array([-1.77841057e-04, 5.15148204e-06, -2.96097989e-04, 3.35036499e-05]) ``` -------------------------------- ### Install ROSS Latest Release using Pip Source: https://github.com/petrobras/ross/blob/main/docs/getting_started/installation.md Installs the latest stable version of the ROSS package from the Python Package Index (PyPI). This is the recommended method for most users. Ensure you have pip installed and updated. ```bash pip install ross-rotordynamics ``` -------------------------------- ### Instantiate Gear Element with Mass and Inertia Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_4.ipynb Demonstrates how to create a `GearElement` by providing its mass and inertia properties. This element is a subclass of `DiskElement` and is used to model gears in rotordynamics analysis. ```python import ross as rs import numpy as np import pandas as pd from ross.units import Q_ # Make sure the default renderer is set to 'notebook' for inline plots in Jupyter import plotly.io as pio import plotly.graph_objects as go pio.renderers.default = "notebook" gear = rs.GearElement( n=0, m=5, Id=0.002, Ip=0.004, n_teeth=20, pitch_diameter=0.5, pr_angle=Q_(22.5, "deg"), tag="Gear", ) gear ``` -------------------------------- ### Create DiskElement List using zip() with Mass/Inertia (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.ipynb This snippet demonstrates creating a list of DiskElement objects by iterating over lists of mass and inertia properties using the zip() function. It assumes the existence of a 'rs' module with a DiskElement class. ```python # OPTION No.1: # Using zip() method n_list = [2, 4] m_list = [32.6, 35.8] Id_list = [0.17808928, 0.17808928] Ip_list = [0.32956362, 0.38372842] disk_elements = [ rs.DiskElement( n=n, m=m, Id=Id, Ip=Ip, ) for n, m, Id, Ip in zip(n_list, m_list, Id_list, Ip_list) ] disk_elements ``` -------------------------------- ### Import Libraries and Setup Plotting Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_22.ipynb Imports necessary libraries such as 'ross', 'numpy', 'pandas', and 'plotly.io'. It also sets the default renderer for plotly to 'notebook' for inline plots in Jupyter environments. ```python import ross as rs import numpy as np import pandas as pd from IPython.display import display # Make sure the default renderer is set to 'notebook' for inline plots in Jupyter import plotly.io as pio pio.renderers.default = "notebook" ``` -------------------------------- ### Instantiate Bearing Element with Constant Coefficients Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.ipynb Creates a bearing element with constant stiffness and damping coefficients. The 'frequency' argument is not required for constant coefficients. The example demonstrates setting stiffness (kxx, kyy) and damping (cxx) values and printing the element's properties. ```python import ross as rs stfx = 1e6 stfy = 0.8e6 bearing1 = rs.BearingElement(n=0, kxx=stfx, kyy=stfy, cxx=1e3) print(bearing1) print("=" * 55) print(f"Kxx coefficient: {bearing1.kxx}") ``` -------------------------------- ### Import Libraries and Setup Plotting - Python Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_5.ipynb Imports necessary libraries such as 'ross', 'numpy', and 'plotly' for rotor dynamics analysis and visualization. It also sets the default Plotly renderer for Jupyter notebooks. ```python import ross as rs import numpy as np import plotly.graph_objects as go # Make sure the default renderer is set to 'notebook' for inline plots in Jupyter import plotly.io as pio pio.renderers.default = "notebook" ``` -------------------------------- ### Get Time Response Data as DataFrame Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/results/ross.TimeResponseResults.md Retrieves the time response data for a list of probes and returns it in a pandas DataFrame. This method is useful for further data manipulation or custom analysis. It allows specifying units and the starting time step. ```python df = results.data_time_response(probe, probe_units='rad', displacement_units='m', time_units='s', init_step=0) ``` -------------------------------- ### Get Damping Matrix C in Python Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/rotor/ross.MultiRotor.md This snippet demonstrates how to calculate the damping matrix 'C' for a multi-rotor system at a given frequency. It uses a predefined two-shaft rotor example and prints a portion of the resulting damping matrix, scaled by 1e3. ```python import ross as rs import numpy as np # Assume two_shaft_rotor_example() is a function that returns a MultiRotor object # For demonstration, let's create a simple multi-rotor def two_shaft_rotor_example(): steel = rs.materials.steel L1 = [0.1] d1 = [0.1] shaft1 = [rs.ShaftElement(L=L1[0], idl=0.0, odl=d1[0], material=steel)] disk1 = rs.DiskElement(n=1, m=10, Id=0.1, Ip=0.2) bearing1 = rs.BearingElement(n=0, kxx=1e6, kyy=1e6, cxx=3e3) rotor1 = rs.Rotor(shaft1, [disk1], [bearing1]) L2 = [0.1] d2 = [0.1] shaft2 = [rs.ShaftElement(L=L2[0], idl=0.0, odl=d2[0], material=steel)] disk2 = rs.DiskElement(n=1, m=5, Id=0.05, Ip=0.1) bearing2 = rs.BearingElement(n=0, kxx=1e6, kyy=1e6, cxx=3e3) rotor2 = rs.Rotor(shaft2, [disk2], [bearing2]) return rs.MultiRotor(rotor1, rotor2, coupled_nodes=(1, 1), gear_mesh_stiffness=1e8) multi_rotor = two_shaft_rotor_example() # Calculate the damping matrix at frequency 0 C_matrix = multi_rotor.C(0) # Print a portion of the matrix, scaled by 1e3 print(C_matrix[:4, :4] / 1e3) ``` -------------------------------- ### Initialize ROSS and Plotting Environment Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_25.md Imports necessary libraries (ross, numpy, plotly, pandas) and sets the default Plotly renderer for inline plots in Jupyter environments. It also displays the installed version of the ROSS library. ```ipython3 import ross as rs import numpy as np import plotly.graph_objects as go import pandas as pd # Make sure the default renderer is set to 'notebook' for inline plots in Jupyter import plotly.io as pio pio.renderers.default = "notebook" Q_ = rs.Q_ rs.__version__ ``` -------------------------------- ### Instantiate SealElement (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.ipynb Provides an example of instantiating a SealElement. SealElements share many arguments with BearingElements but have different roles in rotor models, notably not generating reaction forces in static analysis. ```python import ross as rs stfx = 1e6 stfy = 0.8e6 seal = rs.SealElement(n=0, kxx=stfx, kyy=stfy, cxx=1e3, cyy=0.8e3) seal ``` -------------------------------- ### Serve Local Sphinx Documentation Source: https://github.com/petrobras/ross/blob/main/CONTRIBUTING.md Commands to serve the locally built Sphinx documentation using Python's built-in HTTP server. This allows for previewing the documentation website before deployment. ```bash cd ~/ross/docs/_build/html python -m http.server ``` -------------------------------- ### Get State Space Matrix A in Python Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/rotor/ross.MultiRotor.md This snippet shows how to obtain the state-space matrix 'A' for a given rotor instance. It takes an optional rotor speed as input. The example uses a predefined rotor_example() function to generate a rotor and then prints a rounded portion of its 'A' matrix. ```python import ross as rs import numpy as np # Assume rotor_example() is a function that returns a rotor object # For demonstration, let's create a simple rotor def rotor_example(): steel = rs.materials.steel L = [0.1, 0.2] d = [0.05, 0.05] shaft = [ rs.ShaftElement(L=L[i], idl=0.0, odl=d[i], material=steel) for i in range(len(L)) ] disk = rs.DiskElement(n=1, m=10, Id=0.1, Ip=0.2) bearing = rs.BearingElement(n=0, kxx=1e6, kyy=1e6, cxx=1e3) return rs.Rotor(shaft, [disk], [bearing]) rotor = rotor_example() # The A() method returns the state space matrix A_matrix = rotor.A() # Print a rounded portion of the matrix for demonstration print(np.round(A_matrix[75:83, :2]) + 0.) ``` -------------------------------- ### Create Rotor Elements and Assemble Rotor (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.md Demonstrates the creation of Bearing and Disk elements with specified properties and their assembly into a Rotor object. It then prints the rotor's mass and center of gravity, and plots the rotor geometry. ```python stfx = 1e6 stfy = 0.8e6 # n = 0 refers to the section 0, first node bearing0 = rs.BearingElement(n=0, kxx=stfx, kyy=stfy, cxx=1e3) # n = 3 refers to the section 2, last node bearing1 = rs.BearingElement(n=3, kxx=stfx, kyy=stfy, cxx=1e3) bearings = [bearing0, bearing1] # n = 1 refers to the section 1, first node disk0 = rs.DiskElement.from_geometry( n=1, material=steel, width=0.07, i_d=0.05, o_d=0.28 ) # n = 2 refers to the section 2, first node disk1 = rs.DiskElement.from_geometry( n=2, material=steel, width=0.07, i_d=0.05, o_d=0.28 ) disks = [disk0, disk1] rotor2 = rs.Rotor.from_section( brg_seal_data=bearings, disk_data=disks, idl_data=i_ds_data, leng_data=leng_data, odl_data=o_ds_data, nel_r=4, material_data=steel, ) print("Rotor total mass = ", np.round(rotor2.m, 2)) print("Rotor center of gravity =", np.round(rotor2.CG, 2)) rotor2.plot_rotor() ``` -------------------------------- ### Matplotlib Plotting Setup for Rotor Orbits Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_27.ipynb This snippet initializes a Matplotlib figure and axes for plotting rotor orbits. It creates a figure with three subplots arranged horizontally, suitable for displaying multiple orbit plots. The primary dependency is Matplotlib. ```python ##### PLOTTING THE ORBITS fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(13, 4)) ``` -------------------------------- ### Plotting Rotor Orbits with Plotly Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_27.ipynb This snippet demonstrates how to plot and update rotor orbits using Plotly's go.Scatter. It involves creating traces for orbits and starting points, scaling axes, and adding traces to a figure. Dependencies include Plotly (go) and NumPy. ```python orb2_curve = go.Scatter( x=x_new2, y=y_new2, mode="lines", name="orb2", showlegend=False, line=dict(color="orange"), ) orb4 = response3.plot_2d(node=4, width=500, height=500) x_new4 = orb4.data[0].x[-cutoff:] y_new4 = orb4.data[0].y[-cutoff:] starting_point4 = go.Scatter( x=[x_new4[0]], y=[y_new4[0]], marker={"size": 10, "color": "#636EFA"}, showlegend=False, name="Starting Point4", ) max_amp = max(np.max(x_new2), np.max(y_new2), np.max(x_new4), np.max(y_new4)) orb4.update_xaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_yaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_traces(x=x_new4, y=y_new4, name="orb4") orb4.update_layout(title="Response at node 2 and 4 at 2320 RPM") orb4.add_trace(starting_point4) orb4.add_trace(starting_point2) orb4.add_trace(orb2_curve) orb4 ``` -------------------------------- ### Instantiate Bearing with Speed-Dependent Parameters (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.ipynb Demonstrates how to instantiate a BearingElement with coefficients that vary based on rotation speed. Requires NumPy for array creation and the 'rs' library. The 'frequency' parameter must match the size of the coefficient arrays. ```python import numpy as np import ross as rs bearing2 = rs.BearingElement( n=0, kxx=np.array([0.5e6, 1.0e6, 2.5e6]), kyy=np.array([1.5e6, 2.0e6, 3.5e6]), cxx=np.array([0.5e3, 1.0e3, 1.5e3]), frequency=np.array([0, 1000, 2000]), ) print(bearing2) print("=" * 79) print(f"Kxx coefficient: {bearing2.kxx}") ``` -------------------------------- ### Set Up Harmonic Force for Out-of-Balancing Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_26.md Creates a time-domain force matrix representing an out-of-balancing condition, which typically results in harmonic forces. This setup is essential for simulating the dynamic response of a rotor system to such disturbances. The force is applied at a specific node and its components are calculated based on mass, speed squared, and time. ```ipython3 speed = 1346 * (2 * np.pi / 60) # Q_(496, "RPM") time_samples = 1000001 node = 2 # out-of-balancing position t = np.linspace(0, 43, time_samples) # Creating the out-of-balancing force input matrix F = np.zeros((time_samples, rotor.ndof)) # harmonic force component on x axis F[:, rotor.number_dof * node + 0] = ( m1 * speed**2 * np.cos(speed * t) ) # as out-of-balancing is a harmonic force # harmonic force component on y axis F[:, rotor.number_dof * node + 1] = ( m1 * speed**2 * np.sin(speed * t) ) # as out-of-balancing is a harmonic force ``` -------------------------------- ### Instantiate Bearing Element with Pint Units in ROSS Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.md Demonstrates the instantiation of a BearingElement with stiffness (kxx) and damping (cxx) coefficients defined using Pint for unit handling. The output displays the values converted to SI units. ```ipython3 kxx = Q_(2.54e4, "N/in") cxx = Q_(1e2, "N*s/m") brg_pint = rs.BearingElement(n=0, kxx=kxx, cxx=cxx) print(brg_pint) ``` -------------------------------- ### Plot 2D Orbit Response at Specific Nodes (1346 RPM) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_26.md Generates and customizes 2D orbit plots for the rotor's response at 1346 RPM. This function visualizes the displacement path at nodes 2 and 4, highlighting the starting point and the orbit curve. It uses `plotly.graph_objects` for plotting and `numpy` for calculations. ```ipython3 # Editing the ross plots in order to explicit the orbit whirl in node 2 orb2 = response3.plot_2d(node=2, width=500, height=500) cutoff = int(1000 * 1) x_new2 = orb2.data[0].x[-cutoff:] y_new2 = orb2.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point2 = go.Scatter( x=[x_new2[0]], y=[y_new2[0]], marker={"size": 10, "color": "orange"}, showlegend=False, name="Starting Point2", ) # Inserting the orbit of node 2 orb2_curve = go.Scatter( x=x_new2, y=y_new2, mode="lines", name="orb2", showlegend=False, line=dict(color="orange"), ) # Editing the ross plots in order to explicit the orbit whirl in node 4 orb4 = response3.plot_2d(node=4, width=500, height=500) x_new4 = orb4.data[0].x[-cutoff:] y_new4 = orb4.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point4 = go.Scatter( x=[x_new4[0]], y=[y_new4[0]], marker={"size": 10, "color": "#636EFA"}, showlegend=False, name="Starting Point4", ) # Proper scaling x and y axis max_amp = max(np.max(x_new2), np.max(y_new2), np.max(x_new4), np.max(y_new4)) # Merging orbit at node 2 and node 4 orb4.update_xaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_yaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_traces(x=x_new4, y=y_new4, name="orb4") orb4.update_layout(title="Response at node 2 and 4 at 1346 RPM") orb4.add_trace(starting_point4) orb4.add_trace(starting_point2) orb4.add_trace(orb2_curve) orb4 ``` -------------------------------- ### Create Rotor Model with Shaft Elements, Disks, and Bearings Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_15.md Defines a rotor system including material properties, shaft elements with specified dimensions and properties, disk elements with mass and inertia, and bearing elements with stiffness and damping coefficients. This setup is crucial for simulating the rotor's dynamic behavior. ```ipython3 """Create example rotor with given number of elements.""" steel2 = rs.Material(name="Steel", rho=7850, E=2.17e11, Poisson=0.2992610837438423) # Rotor with 6 DoFs, with internal damping, with 10 shaft elements, 2 disks and 2 bearings. i_d = 0 o_d = 0.019 n = 33 # fmt: off L = np.array( [0 , 25, 64, 104, 124, 143, 175, 207, 239, 271, 303, 335, 345, 355, 380, 408, 436, 466, 496, 526, 556, 586, 614, 647, 657, 667, 702, 737, 772, 807, 842, 862, 881, 914] )/ 1000 # fmt: on L = [L[i] - L[i - 1] for i in range(1, len(L))] shaft_elem = [ rs.ShaftElement( material=steel2, L=l, idl=i_d, odl=o_d, idr=i_d, odr=o_d, alpha=8.0501, beta=1.0e-5, rotary_inertia=True, shear_effects=True, ) for l in L ] Id = 0.003844540885417 Ip = 0.007513248437500 disk0 = rs.DiskElement(n=12, m=2.6375, Id=Id, Ip=Ip) disk1 = rs.DiskElement(n=24, m=2.6375, Id=Id, Ip=Ip) kxx1 = 4.40e5 kyy1 = 4.6114e5 kzz = 0 cxx1 = 27.4 cyy1 = 2.505 kxx2 = 9.50e5 kyy2 = 1.09e8 cxx2 = 50.4 cyy2 = 100.4553 bearing0 = rs.BearingElement( n=4, kxx=kxx1, kyy=kyy1, cxx=cxx1, cyy=cyy1, kzz=kzz, czz=czz ) bearing1 = rs.BearingElement( n=31, kxx=kxx2, kyy=kyy2, cxx=cxx2, cyy=cyy2, kzz=kzz, czz=czz ) rotor = rs.Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1]) ``` -------------------------------- ### Create DiskElement List using zip() with Geometry (Python) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_1.ipynb This snippet illustrates creating a list of DiskElement objects from geometrical properties using the `from_geometry` method and the zip() function to iterate over multiple lists of parameters. ```python # OPTION No.1: # Using zip() method n_list = [2, 4] width_list = [0.7, 0.7] i_d_list = [0.05, 0.05] o_d_list = [0.15, 0.18] disk_elements = [ rs.DiskElement.from_geometry( n=n, material=steel, width=width, i_d=i_d, o_d=o_d, ) for n, width, i_d, o_d in zip(n_list, width_list, i_d_list, o_d_list) ] disk_elements ``` -------------------------------- ### Plot Orbit Whirl for Node 2 and Node 4 Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_27.ipynb This snippet visualizes the orbit whirl for nodes 2 and 4 using the `plot_2d` function. It extracts specific portions of the orbit data, defines starting points, and merges the orbits into a single plot with appropriate scaling and a title. The `go.Scatter` object from Plotly is used for plotting. ```python # Editing the ross plots in order to explicit the orbit whirl in node 2 orb2 = response3.plot_2d(node=2, width=500, height=500) cutoff = int(1000 * 1.8) x_new2 = orb2.data[0].x[-cutoff:] y_new2 = orb2.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point2 = go.Scatter( x=[x_new2[0]], y=[y_new2[0]], marker={"size": 10, "color": "orange"}, showlegend=False, name="Starting Point2", ) # Inserting the orbit of node 2 orb2_curve = go.Scatter( x=x_new2, y=y_new2, mode="lines", name="orb2", showlegend=False, line=dict(color="orange"), ) # Editing the ross plots in order to explicit the orbit whirl in node 4 orb4 = response3.plot_2d(node=4, width=500, height=500) x_new4 = orb4.data[0].x[-cutoff:] y_new4 = orb4.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point4 = go.Scatter( x=[x_new4[0]], y=[y_new4[0]], marker={"size": 10, "color": "#636EFA"}, showlegend=False, name="Starting Point4", ) # Proper scaling x and y axis max_amp = max(np.max(x_new2), np.max(y_new2), np.max(x_new4), np.max(y_new4)) # Merging orbit at node 2 and node 4 orb4.update_xaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_yaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_traces(x=x_new4, y=y_new4, name="orb4") orb4.update_layout(title="Response at node 2 and 4 at 751 RPM") orb4.add_trace(starting_point4) orb4.add_trace(starting_point2) orb4.add_trace(orb2_curve) orb4 ``` ```python # Editing the ross plots in order to explicit the orbit whirl in node 2 orb2 = response3.plot_2d(node=2, width=500, height=500) cutoff = int(1000 * 1.7) x_new2 = orb2.data[0].x[-cutoff:] y_new2 = orb2.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point2 = go.Scatter( x=[x_new2[0]], y=[y_new2[0]], marker={"size": 10, "color": "orange"}, showlegend=False, name="Starting Point2", ) # Inserting the orbit of node 2 orb2_curve = go.Scatter( x=x_new2, y=y_new2, mode="lines", name="orb2", showlegend=False, line=dict(color="orange"), ) # Editing the ross plots in order to explicit the orbit whirl in node 4 orb4 = response3.plot_2d(node=4, width=500, height=500) x_new4 = orb4.data[0].x[-cutoff:] y_new4 = orb4.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point4 = go.Scatter( x=[x_new4[0]], y=[y_new4[0]], marker={"size": 10, "color": "#636EFA"}, showlegend=False, name="Starting Point4", ) # Proper scaling x and y axis max_amp = max(np.max(x_new2), np.max(y_new2), np.max(x_new4), np.max(y_new4)) # Merging orbit at node 2 and node 4 orb4.update_xaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_yaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_traces(x=x_new4, y=y_new4, name="orb4") orb4.update_layout(title="Response at node 2 and 4 at 800 RPM") orb4.add_trace(starting_point4) orb4.add_trace(starting_point2) orb4.add_trace(orb2_curve) orb4 ``` ```python # Editing the ross plots in order to explicit the orbit whirl in node 2 orb2 = response3.plot_2d(node=2, width=500, height=500) cutoff = int(1000 * 0.57) x_new2 = orb2.data[0].x[-cutoff:] y_new2 = orb2.data[0].y[-cutoff:] # Inserting the orbit starting point starting_point2 = go.Scatter( x=[x_new2[0]], y=[y_new2[0]], marker={"size": 10, "color": "orange"}, showlegend=False, name="Starting Point2", ) ``` -------------------------------- ### Create and Use ross.Material Objects Source: https://github.com/petrobras/ross/blob/main/docs/references/generated/material/ross.Material.md Demonstrates how to instantiate the Material class with various properties, including using the Q_ unit conversion utility. It also shows how to access material properties after instantiation. ```python from ross.units import Q_ from ross import Material AISI4140 = Material(name="AISI4140", rho=7850, E=203.2e9, G_s=80e9) Steel = Material(name="Steel", rho=Q_(7.81, 'g/cm**3'), E=211e9, G_s=81.2e9) print(AISI4140.Poisson) print(Steel.rho) ``` -------------------------------- ### Plotting Orbit Response using Plotly Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_26.md This snippet demonstrates how to plot the orbital response of a rotor system at specific nodes using Plotly. It involves creating Scatter traces for starting points and orbit curves, updating axes for proper scaling, and merging traces to visualize the combined response. Dependencies include the 'go' (plotly.graph_objects) and 'np' (numpy) libraries. ```python starting_point2 = go.Scatter( x=[x_new2[0]], y=[y_new2[0]], marker={"size": 10, "color": "orange"}, showlegend=False, name="Starting Point2", ) orb2_curve = go.Scatter( x=x_new2, y=y_new2, mode="lines", name="orb2", showlegend=False, line=dict(color="orange"), ) orb4 = response3.plot_2d(node=4, width=500, height=500) x_new4 = orb4.data[0].x[-cutoff:] y_new4 = orb4.data[0].y[-cutoff:] starting_point4 = go.Scatter( x=[x_new4[0]], y=[y_new4[0]], marker={"size": 10, "color": "#636EFA"}, showlegend=False, name="Starting Point4", ) max_amp = max(np.max(x_new2), np.max(y_new2), np.max(x_new4), np.max(y_new4)) orb4.update_xaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_yaxes(range=[-1.2 * max_amp, 1.2 * max_amp]) orb4.update_traces(x=x_new4, y=y_new4, name="orb4") orb4.update_layout(title="Response at node 2 and 4 at 2596 RPM") orb4.add_trace(starting_point4) orb4.add_trace(starting_point2) orb4.add_trace(orb2_curve) orb4 ``` -------------------------------- ### Instantiate ST_Rotor with Multiple Elements (IPython) Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/tutorial_part_3.md Shows how to create an ST_Rotor instance by providing lists of pre-instantiated shaft, disk, bearing, and point mass elements. This example specifically includes disk and bearing elements. ```ipython3 rotor1 = srs.ST_Rotor( shaft_elements, [disk0, disk1], [brg0, brg1], ) ``` -------------------------------- ### Plot Orbit Data with Cutoff and Scaled Axes in Python Source: https://github.com/petrobras/ross/blob/main/docs/user_guide/example_27.ipynb This Python code plots orbit data for different RPMs, applying a calculated cutoff to avoid transient data and then setting the x and y axes to use the previously defined scalar formatter for scaling. It plots the orbit path and highlights the starting point of the data segment used for the plot. ```python # Plot orbit data at 496 RPM cutoff = -int(time_samples * 0.0018) ax1.plot(x1_axis_displacement[cutoff:], y1_axis_displacement[cutoff:], label="Orbit") ax1.plot( x1_axis_displacement[cutoff:][0], y1_axis_displacement[cutoff:][0], "o", markersize=6, color="#636EFA", ) ax1.plot(x2_axis_displacement[cutoff:], y2_axis_displacement[cutoff:], label="Orbit") ax1.plot( x2_axis_displacement[cutoff:][0], y2_axis_displacement[cutoff:][0], "o", markersize=6, color="#636EFA", ) ax1.set_title("496 RPM") ax1.xaxis.set_major_formatter(formatter) ax1.yaxis.set_major_formatter(formatter) cutoff = -int(time_samples * 0.0017) # Plot orbit data at 1346 RPM ax2.plot(x3_axis_displacement[cutoff:], y3_axis_displacement[cutoff:], label="Orbit") ax2.plot( x3_axis_displacement[cutoff:][0], y3_axis_displacement[cutoff:][0], "o", markersize=10, color="#636EFA", ) ax2.plot(x4_axis_displacement[cutoff:], y4_axis_displacement[cutoff:], label="Orbit") ax2.plot( x4_axis_displacement[cutoff:][0], y4_axis_displacement[cutoff:][0], "o", markersize=10, color="#636EFA", ) ax2.set_title("1346 RPM") ax2.xaxis.set_major_formatter(formatter) ax2.yaxis.set_major_formatter(formatter) cutoff = -int(time_samples * 0.00058) # Plot orbit data at 2596 RPM ax3.plot(x5_axis_displacement[cutoff:], y5_axis_displacement[cutoff:], label="Orbit") ax3.plot( x5_axis_displacement[cutoff:][0], y5_axis_displacement[cutoff:][0], "o", markersize=10, color="#636EFA", ) ax3.plot(x6_axis_displacement[cutoff:], y6_axis_displacement[cutoff:], label="Orbit") ax3.plot( x6_axis_displacement[cutoff:][0], y6_axis_displacement[cutoff:][0], "o", markersize=10, color="#636EFA", ) ax3.set_title("2596 RPM") ax3.xaxis.set_major_formatter(formatter) ax3.yaxis.set_major_formatter(formatter) ```