ross.stochastic.ST_Material#

class ross.stochastic.ST_Material(name, rho, E=None, G_s=None, Poisson=None, color='#525252', **kwargs)#

Create instance of Material with random parameters.

Class used to create a material and define its properties. Density and at least 2 arguments from E, G_s and Poisson should be provided.

If any material property is passed as iterable, the material becomes random. Inputing 1 or 2 arguments from E, G_s or Poisson as iterable will turn the third argument an iterable, but calculated based on the other two.

For example:

if E is iterable and G_s is float, then, Poisson is iterable and each term is calculated based on E values and G_s single value.

You can run ross.Material.available_materials() to get a list of materials already provided.

Parameters:
namestr

Material name.

rhofloat, list, pint.Quantity

Density (kg/m**3). Input a list to make it random.

Efloat, list, pint.Quantity

Young’s modulus (N/m**2). Input a list to make it random.

G_sfloat, list

Shear modulus (N/m**2). Input a list to make it random.

Poissonfloat, list

Poisson ratio (dimensionless). Input a list to make it random.

colorstr

Can be used on plots.

Examples

>>> # Steel with random Young's modulus.
>>> import ross.stochastic as srs
>>> E = np.random.uniform(208e9, 211e9, 5)
>>> st_steel = srs.ST_Material(name="Steel", rho=7810, E=E, G_s=81.2e9)
>>> len(list(iter(st_steel)))
5

Methods

__init__(name, rho, E=None, G_s=None, Poisson=None, color='#525252', **kwargs)#
plot_random_var(var_list=None, histogram_kwargs=None, plot_kwargs=None)#

Plot histogram and the PDF.

This function creates a histogram to display the random variable distribution.

Parameters:
var_listlist, optional

List of random variables, in string format, to plot. Default is plotting all the random variables.

histogram_kwargsdict, optional

Additional key word arguments can be passed to change the plotly.go.histogram (e.g. histnorm=”probability density”, nbinsx=20…). *See Plotly API to more information.

plot_kwargsdict, optional

Additional key word arguments can be passed to change the plotly go.figure (e.g. line=dict(width=4.0, color=”royalblue”), opacity=1.0, …). *See Plotly API to more information.

Returns:
figPlotly graph_objects.Figure()

A figure with the histogram plots.

Examples

>>> import ross.stochastic as srs
>>> E = np.random.uniform(208e9, 211e9, 5)
>>> st_steel = srs.ST_Material(name="Steel", rho=7810, E=E, G_s=81.2e9)
>>> fig = st_steel.plot_random_var(["E"])
>>> # fig.show()
random_var(is_random, *args)#

Generate a list of objects as random attributes.

This function creates a list of objects with random values for selected attributes from ross.Material.

Parameters:
is_randomlist

List of the object attributes to become stochastic.

*argsdict

Dictionary instanciating the ross.Material class. The attributes that are supposed to be stochastic should be set as lists of random variables.

Returns:
f_listgenerator

Generator of random objects.