# Example 14 - Uncertainties on material properties¶

In this example, we use the rotor seen in Example 5.9.4 from .

This system is the same as that of Example 3, but now we’ll work with uncertainties on material properties, representing a defect in the shaft. We will apply the uncertainties at the central elements.

import ross as rs
import ross.stochastic as srs
import numpy as np

# Deterministic Shaft Elements
Steel = rs.steel
shaft = [rs.ShaftElement(L=0.25, material=Steel, idl=0, odl=0.05) for i in range(4)]

# Material with random properties
size = 50
E = np.random.uniform(low=190e9, high=210e9, size=size)
rho = np.random.uniform(low=7000, high=7810, size=size)
G_s = np.random.uniform(low=70.5e9, high=81.2e9, size=size)
rand_mat = srs.ST_Material(name="Steel", rho=rho, E=E, G_s=G_s)

# Stochastic Shaft Elements
rand_el = srs.ST_ShaftElement(
L=0.25,
idl=0,
odl=0.05,
material=rand_mat,
is_random=["material"],
)

# Inserting stochastic elements to the shaft elements list
shaft.insert(2, rand_el)
shaft.insert(3, rand_el)

# Deterministic Disk Elements
disk1 = rs.DiskElement.from_geometry(
n=2,
material=Steel,
width=0.07,
i_d=0.05,
o_d=0.28,
)

disk2 = rs.DiskElement.from_geometry(
n=4,
material=Steel,
width=0.07,
i_d=0.05,
o_d=0.35,
)
disks = [disk1, disk2]


In this example, let’s consider an uniform distribuition for the coefficients. Because it’s a demonstrative example, we’ll not use too many samples, to avoid taking too long to run the simulation.

We can use numpy.random package to generate random values for our variables.

## Stochastic Bearing Elements¶

# random variables must have the same size
bearing1 = rs.BearingElement(n=0, kxx=1e6, cxx=2e2)
bearing2 = rs.BearingElement(n=6, kxx=1e6, cxx=2e2)
bearings = [bearing1, bearing2]

# Building random instances for a rotor model

rand_rotor = srs.ST_Rotor(
shaft_elements=shaft, disk_elements=disks, bearing_elements=bearings
)

# Number of samples
print("Number of samples:", len(list(iter(rand_rotor))))

Number of samples: 50


## Plotting a random sample¶

We can use numpy.random.choice to take a random rotor object. Then, we can use the same functions than to Rotor class.

sample = np.random.choice(list(iter(rand_rotor)))
fig = sample.plot_rotor()
fig.show()