Repository: ross-rotordynamics/ross
Pull request #631 (2020-07-15 19:44:27)

Formatting __str__methods to include units
`__str__` methods will highlight the unit system ROSS is using.
Since it's automatically converted to the SI, it's important to show the user, what exactly are the units.

- class `Material` - fix `__str__` unit indication
- class `ShaftElement`- format `__str__` output and add unit indication
- class `DiskElement`- add `__str__` method with unit indication
- class `PointMass`- add `__str__` method with unit indication

class `BearingElement `is not included yet. As the parameters are not floats or ints, but list, I need to work around it to convert them to string format.


Patch:
diff --git a/ross/disk_element.py b/ross/disk_element.py
index 4b43465c..17473f81 100644
--- a/ross/disk_element.py
+++ b/ross/disk_element.py
@@ -123,6 +123,30 @@ class DiskElement(Element):
             f"n={self.n}, tag={self.tag!r})"
         )
 
+    def __str__(self):
+        """Convert object into string.
+
+        Returns
+        -------
+        The object's parameters translated to strings
+
+        Example
+        -------
+        >>> print(DiskElement(n=0, m=32, Id=0.223, Ip=0.31223, tag="Disk"))
+        Tag:                      Disk
+        Node:                     0
+        Mass           (kg):      32.0
+        Diam. inertia  (kg*m**2): 0.223
+        Polar. inertia (kg*m**2): 0.31223
+        """
+        return (
+            f"Tag:                      {self.tag}"
+            f"\nNode:                     {self.n}"
+            f"\nMass           (kg):      {self.m:{2}.{5}}"
+            f"\nDiam. inertia  (kg*m**2): {self.Id:{2}.{5}}"
+            f"\nPolar. inertia (kg*m**2): {self.Ip:{2}.{5}}"
+        )
+
     def __hash__(self):
         return hash(self.tag)
 
diff --git a/ross/materials.py b/ross/materials.py
index 91233fc5..09add4bc 100644
--- a/ross/materials.py
+++ b/ross/materials.py
@@ -144,18 +144,18 @@ class Material:
         >>> print(rs.Material.use_material('Steel'))
         Steel
         -----------------------------------
-        Density         (N/m**3): 7810.0
-        Young`s modulus (N/m**2): 2.11e+11
-        Shear modulus   (N/m**2): 8.12e+10
-        Poisson coefficient     : 0.29926108
+        Density         (kg/m**3): 7810.0
+        Young`s modulus (N/m**2):  2.11e+11
+        Shear modulus   (N/m**2):  8.12e+10
+        Poisson coefficient     :  0.29926108
         """
         return (
             f"{self.name}"
             f'\n{35*"-"}'
-            f"\nDensity         (N/m**3): {self.rho:{2}.{8}}"
-            f"\nYoung`s modulus (N/m**2): {self.E:{2}.{8}}"
-            f"\nShear modulus   (N/m**2): {self.G_s:{2}.{8}}"
-            f"\nPoisson coefficient     : {self.Poisson:{2}.{8}}"
+            f"\nDensity         (kg/m**3): {self.rho:{2}.{8}}"
+            f"\nYoung`s modulus (N/m**2):  {self.E:{2}.{8}}"
+            f"\nShear modulus   (N/m**2):  {self.G_s:{2}.{8}}"
+            f"\nPoisson coefficient     :  {self.Poisson:{2}.{8}}"
         )
 
     @staticmethod
diff --git a/ross/point_mass.py b/ross/point_mass.py
index 4d76d918..804b3734 100644
--- a/ross/point_mass.py
+++ b/ross/point_mass.py
@@ -113,6 +113,28 @@ class PointMass(Element):
             f" my={self.my:{0}.{5}}, tag={self.tag!r})"
         )
 
+    def __str__(self):
+        """Convert object into string.
+
+        Returns
+        -------
+        The object's parameters translated to strings
+
+        Example
+        -------
+        >>> print(PointMass(n=0, mx=2.5, my=3.25, tag="PointMass"))
+        Tag:              PointMass
+        Node:             0
+        Mass X dir. (kg): 2.5
+        Mass Y dir. (kg): 3.25
+        """
+        return (
+            f"Tag:              {self.tag}"
+            f"\nNode:             {self.n}"
+            f"\nMass X dir. (kg): {self.mx:{2}.{5}}"
+            f"\nMass Y dir. (kg): {self.my:{2}.{5}}"
+        )
+
     def M(self):
         """Mass matrix for an instance of a point mass element.
 
diff --git a/ross/shaft_element.py b/ross/shaft_element.py
index 474f5d5f..542b8a4a 100644
--- a/ross/shaft_element.py
+++ b/ross/shaft_element.py
@@ -365,17 +365,33 @@ class ShaftElement(Element):
         Returns
         -------
         The object's parameters translated to strings
+
+        Example
+        -------
+        >>> print(ShaftElement(L=0.25, idl=0, odl=0.05, odr=0.08, material=steel))
+        Element Number:             None
+        Element Lenght   (m):       0.25
+        Left Int. Diam.  (m):        0.0
+        Left Out. Diam.  (m):       0.05
+        Right Int. Diam. (m):        0.0
+        Right Out. Diam. (m):       0.08
+        -----------------------------------
+        Steel
+        -----------------------------------
+        Density         (kg/m**3): 7810.0
+        Young`s modulus (N/m**2):  2.11e+11
+        Shear modulus   (N/m**2):  8.12e+10
+        Poisson coefficient     :  0.29926108
         """
         return (
-            f"\nElem. N:    {self.n}"
-            f"\nLenght:     {self.L:{10}.{5}}"
-            f"\nLeft Int. Diam.: {self.idl:{10}.{5}}"
-            f"\nLeft Out. Diam.: {self.odl:{10}.{5}}"
-            f"\nRight Int. Diam.: {self.idr:{10}.{5}}"
-            f"\nRight Out. Diam.: {self.odr:{10}.{5}}"
+            f"Element Number:             {self.n}"
+            f"\nElement Lenght   (m): {self.L:{10}.{5}}"
+            f"\nLeft Int. Diam.  (m): {self.idl:{10}.{5}}"
+            f"\nLeft Out. Diam.  (m): {self.odl:{10}.{5}}"
+            f"\nRight Int. Diam. (m): {self.idr:{10}.{5}}"
+            f"\nRight Out. Diam. (m): {self.odr:{10}.{5}}"
             f'\n{35*"-"}'
             f"\n{self.material}"
-            f"\n"
         )
 
     def __hash__(self):
@@ -1438,19 +1454,37 @@ class ShaftElement6DoF(ShaftElement):
         Returns
         -------
         The object's parameters translated to strings
+
+        Example
+        -------
+        >>> print(ShaftElement6DoF(L=0.25, idl=0, odl=0.05, odr=0.08, material=steel))
+        Element Number:             None
+        Element Lenght   (m):       0.25
+        Left Int. Diam.  (m):        0.0
+        Left Out. Diam.  (m):       0.05
+        Right Int. Diam. (m):        0.0
+        Right Out. Diam. (m):       0.08
+        Alpha damp. factor:          0.0
+        Beta damp. factor:           0.0
+        -----------------------------------
+        Steel
+        -----------------------------------
+        Density         (kg/m**3): 7810.0
+        Young`s modulus (N/m**2):  2.11e+11
+        Shear modulus   (N/m**2):  8.12e+10
+        Poisson coefficient     :  0.29926108
         """
         return (
-            f"\nElem. N:    {self.n}"
-            f"\nLenght:     {self.L:{10}.{5}}"
-            f"\nLeft Int. Diam.: {self.idl:{10}.{5}}"
-            f"\nLeft Out. Diam.: {self.odl:{10}.{5}}"
-            f"\nRight Int. Diam.: {self.idr:{10}.{5}}"
-            f"\nRight Out. Diam.: {self.odr:{10}.{5}}"
-            f"\nAlpha damp. factor: {self.alpha:{10}.{5}}"
-            f"\nBeta damp. factor: {self.beta:{10}.{5}}"
+            f"Element Number:             {self.n}"
+            f"\nElement Lenght   (m): {self.L:{10}.{5}}"
+            f"\nLeft Int. Diam.  (m): {self.idl:{10}.{5}}"
+            f"\nLeft Out. Diam.  (m): {self.odl:{10}.{5}}"
+            f"\nRight Int. Diam. (m): {self.idr:{10}.{5}}"
+            f"\nRight Out. Diam. (m): {self.odr:{10}.{5}}"
+            f"\nAlpha damp. factor:   {self.alpha:{10}.{5}}"
+            f"\nBeta damp. factor:    {self.beta:{10}.{5}}"
             f'\n{35*"-"}'
             f"\n{self.material}"
-            f"\n"
         )
 
     def save(self, file):
diff --git a/ross/stochastic/st_bearing_seal_element.py b/ross/stochastic/st_bearing_seal_element.py
index 4f67c6b1..88f50286 100644
--- a/ross/stochastic/st_bearing_seal_element.py
+++ b/ross/stochastic/st_bearing_seal_element.py
@@ -7,8 +7,8 @@ import numpy as np
 
 from ross.bearing_seal_element import BearingElement
 from ross.fluid_flow import fluid_flow as flow
-from ross.fluid_flow.fluid_flow_coefficients import \
-    calculate_stiffness_and_damping_coefficients
+from ross.fluid_flow.fluid_flow_coefficients import (
+    calculate_short_damping_matrix, calculate_short_stiffness_matrix)
 from ross.stochastic.st_results_elements import plot_histogram
 
 # fmt: on
@@ -297,7 +297,7 @@ class ST_BearingElement:
 
         return f_list
 
-    def plot_random_var(self, var_list=None, histogram_kwargs=None, plot_kwargs=None):
+    def plot_random_var(self, var_list=[], histogram_kwargs={}, plot_kwargs={}):
         """Plot histogram and the PDF.
 
         This function creates a histogram to display the random variable
@@ -307,7 +307,6 @@ class ST_BearingElement:
         ----------
         var_list : list, optional
             List of random variables, in string format, to plot.
-            Default is plotting all the random variables.
         histogram_kwargs : dict, optional
             Additional key word arguments can be passed to change
             the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
@@ -330,26 +329,24 @@ class ST_BearingElement:
         >>> # fig.show()
         """
         label = dict(
-            kxx="Kxx",
-            kxy="Kxy",
-            kyx="Kyx",
-            kyy="Kyy",
-            cxx="Cxx",
-            cxy="Cxy",
-            cyx="Cyx",
-            cyy="Cyy",
+            kxx="Direct stiffness in the X direction",
+            kxy="Cross coupled stiffness in the X direction",
+            kyx="Cross coupled stiffness in the Y direction",
+            kyy="Direct stiffness in the Y direction",
+            cxx="Direct damping in the X direction",
+            cxy="Cross coupled damping in the X direction",
+            cyx="Cross coupled damping in the Y direction",
+            cyy="Direct damping in the y direction",
         )
-        if var_list is None:
-            var_list = self.is_random
-        elif not all(var in self.is_random for var in var_list):
+        if not all(var in self.is_random for var in var_list):
             raise ValueError(
-                "Random variable not in var_list. Select variables from {}".format(
+                "Not random variable in var_list. Select variables from {}".format(
                     self.is_random
                 )
             )
 
         return plot_histogram(
-            self.attribute_dict, label, var_list, histogram_kwargs, plot_kwargs
+            self.attribute_dict, label, var_list, histogram_kwargs={}, plot_kwargs={}
         )
 
     @classmethod
@@ -358,19 +355,17 @@ class ST_BearingElement:
         n,
         nz,
         ntheta,
+        nradius,
         length,
         omega,
         p_in,
         p_out,
         radius_rotor,
         radius_stator,
-        viscosity,
-        density,
-        attitude_angle=None,
+        visc,
+        rho,
         eccentricity=None,
         load=None,
-        omegap=None,
-        immediately_calculate_pressure_matrix_numerically=True,
         tag=None,
         n_link=None,
         scale_factor=1,
@@ -386,8 +381,7 @@ class ST_BearingElement:
             List of the object attributes to become random.
             Possibilities:
                 ["length", "omega", "p_in", "p_out", "radius_rotor",
-                 "radius_stator", "viscosity", "density", "attitude_angle",
-                 "eccentricity", "load", "omegap"]
+                 "radius_stator", "visc", "rho", "eccentricity", "load"]
         tag: str, optional
             A tag to name the element
             Default is None.
@@ -446,10 +440,10 @@ class ST_BearingElement:
         Fluid characteristics
         ^^^^^^^^^^^^^^^^^^^^^
         Describes the fluid characteristics.
-        viscosity: float, list
+        visc: float, list
             Viscosity (Pa.s).
             Input a list to make it random.
-        density: float, list
+        rho: float, list
             Fluid density(Kg/m^3).
             Input a list to make it random.
 
@@ -462,23 +456,23 @@ class ST_BearingElement:
         --------
         >>> import numpy as np
         >>> import ross.stochastic as srs
-        >>> nz = 8
-        >>> ntheta = 64
-        >>> length = 0.01
+        >>> nz = 30
+        >>> ntheta = 20
+        >>> nradius = 11
+        >>> length = 0.03
         >>> omega = 157.1
         >>> p_in = 0.
         >>> p_out = 0.
-        >>> radius_rotor = 0.08
-        >>> radius_stator = 0.1
-        >>> viscosity = np.random.uniform(0.01, 0.02, 5)
-        >>> density = 860.
-        >>> eccentricity = 0.001
-        >>> attitude_angle = np.pi
-        >>> elms = ST_BearingElement.from_fluid_flow(
-        ...     0, nz, ntheta, length,
+        >>> radius_rotor = 0.0499
+        >>> radius_stator = 0.05
+        >>> eccentricity = (radius_stator - radius_rotor)*0.2663
+        >>> visc = np.random.uniform(0.1, 0.2, 5)
+        >>> rho = 860.0
+        >>> elms = srs.ST_BearingElement.from_fluid_flow(
+        ...     0, nz, ntheta, nradius, length,
         ...     omega, p_in, p_out, radius_rotor,
-        ...     radius_stator, viscosity, density, attitude_angle,
-        ...     eccentricity, is_random=["viscosity"]
+        ...     radius_stator, visc, rho,
+        ...     eccentricity=eccentricity, is_random=["visc"]
         ... )
         >>> len(list(iter(elms)))
         5
@@ -506,21 +500,20 @@ class ST_BearingElement:
             fluid_flow = flow.FluidFlow(
                 attribute_dict["nz"][i],
                 attribute_dict["ntheta"][i],
+                attribute_dict["nradius"][i],
                 attribute_dict["length"][i],
                 attribute_dict["omega"][i],
                 attribute_dict["p_in"][i],
                 attribute_dict["p_out"][i],
                 attribute_dict["radius_rotor"][i],
                 attribute_dict["radius_stator"][i],
-                attribute_dict["viscosity"][i],
-                attribute_dict["density"][i],
-                attribute_dict["attitude_angle"][i],
-                attribute_dict["eccentricity"][i],
-                attribute_dict["load"][i],
-                attribute_dict["omegap"][i],
-                attribute_dict["immediately_calculate_pressure_matrix_numerically"][i],
+                attribute_dict["visc"][i],
+                attribute_dict["rho"][i],
+                eccentricity=attribute_dict["eccentricity"][i],
+                load=attribute_dict["load"][i],
             )
-            k, c = calculate_stiffness_and_damping_coefficients(fluid_flow)
+            c = calculate_short_damping_matrix(fluid_flow)
+            k = calculate_short_stiffness_matrix(fluid_flow)
             args_dict["kxx"].append(k[0])
             args_dict["kxy"].append(k[1])
             args_dict["kyx"].append(k[2])
diff --git a/ross/stochastic/st_disk_element.py b/ross/stochastic/st_disk_element.py
index fa057d80..0c14a003 100644
--- a/ross/stochastic/st_disk_element.py
+++ b/ross/stochastic/st_disk_element.py
@@ -185,7 +185,7 @@ class ST_DiskElement:
 
         return f_list
 
-    def plot_random_var(self, var_list=None, histogram_kwargs=None, plot_kwargs=None):
+    def plot_random_var(self, var_list=[], histogram_kwargs={}, plot_kwargs={}):
         """Plot histogram and the PDF.
 
         This function creates a histogram to display the random variable
@@ -195,7 +195,6 @@ class ST_DiskElement:
         ----------
         var_list : list, optional
             List of random variables, in string format, to plot.
-            Default is plotting all the random variables.
         histogram_kwargs : dict, optional
             Additional key word arguments can be passed to change
             the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
@@ -220,11 +219,9 @@ class ST_DiskElement:
         label = dict(
             m="Mass", Id="Diametral moment of inertia", Ip="Polar moment of inertia",
         )
-        if var_list is None:
-            var_list = self.is_random
-        elif not all(var in self.is_random for var in var_list):
+        if not all(var in self.is_random for var in var_list):
             raise ValueError(
-                "Random variable not in var_list. Select variables from {}".format(
+                "Not random variable in var_list. Select variables from {}".format(
                     self.is_random
                 )
             )
diff --git a/ross/stochastic/st_materials.py b/ross/stochastic/st_materials.py
index d0f95f2a..a7efd9c4 100644
--- a/ross/stochastic/st_materials.py
+++ b/ross/stochastic/st_materials.py
@@ -209,7 +209,7 @@ class ST_Material:
 
         return f_list
 
-    def plot_random_var(self, var_list=None, histogram_kwargs=None, plot_kwargs=None):
+    def plot_random_var(self, var_list=[], histogram_kwargs={}, plot_kwargs={}):
         """Plot histogram and the PDF.
 
         This function creates a histogram to display the random variable
@@ -219,7 +219,6 @@ class ST_Material:
         ----------
         var_list : list, optional
             List of random variables, in string format, to plot.
-            Default is plotting all the random variables.
         histogram_kwargs : dict, optional
             Additional key word arguments can be passed to change
             the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
@@ -246,15 +245,14 @@ class ST_Material:
             E="Young's Modulus",
             G_s="Shear Modulus",
             Poisson="Poisson coefficient",
-            rho="Density",
+            rho="density",
         )
+        is_random = self.is_random
 
-        if var_list is None:
-            var_list = self.is_random
-        elif not all(var in self.is_random for var in var_list):
+        if not all(var in self.is_random for var in var_list):
             raise ValueError(
-                "Random variable not in var_list. Select variables from {}".format(
-                    self.is_random
+                "Not random variable in var_list. Select variables from {}".format(
+                    is_random
                 )
             )
 
diff --git a/ross/stochastic/st_point_mass.py b/ross/stochastic/st_point_mass.py
index 86205b0a..9ab31bc1 100644
--- a/ross/stochastic/st_point_mass.py
+++ b/ross/stochastic/st_point_mass.py
@@ -184,7 +184,7 @@ class ST_PointMass:
 
         return f_list
 
-    def plot_random_var(self, var_list=None, histogram_kwargs=None, plot_kwargs=None):
+    def plot_random_var(self, var_list=[], histogram_kwargs={}, plot_kwargs={}):
         """Plot histogram and the PDF.
 
         This function creates a histogram to display the random variable
@@ -194,7 +194,6 @@ class ST_PointMass:
         ----------
         var_list : list, optional
             List of random variables, in string format, to plot.
-            Default is plotting all the random variables.
         histogram_kwargs : dict, optional
             Additional key word arguments can be passed to change
             the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
@@ -219,11 +218,9 @@ class ST_PointMass:
         label = dict(
             mx="Mass on the X direction", my="Mass on the Y direction", m="Mass",
         )
-        if var_list is None:
-            var_list = self.is_random
-        elif not all(var in self.is_random for var in var_list):
+        if not all(var in self.is_random for var in var_list):
             raise ValueError(
-                "Random variable not in var_list. Select variables from {}".format(
+                "Not random variable in var_list. Select variables from {}".format(
                     self.is_random
                 )
             )
diff --git a/ross/stochastic/st_results_elements.py b/ross/stochastic/st_results_elements.py
index afecd8fd..31eee27c 100644
--- a/ross/stochastic/st_results_elements.py
+++ b/ross/stochastic/st_results_elements.py
@@ -2,21 +2,17 @@
 
 This modules provides functions to plot the elements statistic data.
 """
-from copy import copy
-
 import numpy as np
 from plotly import graph_objects as go
 from plotly import io as pio
 from plotly.subplots import make_subplots
 from scipy.stats import gaussian_kde
 
-from ross.plotly_theme import tableau_colors
-
 pio.renderers.default = "browser"
 
 
 def plot_histogram(
-    attribute_dict, label={}, var_list=[], histogram_kwargs=None, plot_kwargs=None
+    attribute_dict, label={}, var_list=[], histogram_kwargs={}, plot_kwargs={}
 ):
     """Plot histogram and the PDF.
 
@@ -45,28 +41,27 @@ def plot_histogram(
     subplots : Plotly graph_objects.make_subplots()
         A figure with the histogram plots.
     """
-    histogram_kwargs = {} if histogram_kwargs is None else copy(histogram_kwargs)
-    plot_kwargs = {} if plot_kwargs is None else copy(plot_kwargs)
-
     hist_default_values = dict(
         histnorm="probability density",
         cumulative_enabled=False,
         nbinsx=20,
-        marker_color=tableau_colors["red"],
+        marker_color="red",
         opacity=1.0,
     )
     for k, v in hist_default_values.items():
         histogram_kwargs.setdefault(k, v)
 
-    plot_default_values = dict(
-        line=dict(width=4.0, color=tableau_colors["blue"]), opacity=1.0
-    )
+    plot_default_values = dict(line=dict(width=4.0, color="royalblue"), opacity=1.0)
     for k, v in plot_default_values.items():
         plot_kwargs.setdefault(k, v)
 
     rows = 1 if len(var_list) < 2 else 2
     cols = len(var_list) // 2 + len(var_list) % 2
-    fig = make_subplots(rows=rows, cols=cols)
+    fig = make_subplots(
+        rows=rows,
+        cols=cols,
+        subplot_titles=["<b>Histogram - {}<b>".format(var) for var in var_list],
+    )
 
     for i, var in enumerate(var_list):
         row = i % 2 + 1
@@ -80,13 +75,7 @@ def plot_histogram(
             y_label = "Frequency"
 
         fig.add_trace(
-            go.Histogram(
-                x=attribute_dict[var],
-                name="Histogram",
-                legendgroup="Histogram",
-                showlegend=True if i == 0 else False,
-                **histogram_kwargs,
-            ),
+            go.Histogram(x=attribute_dict[var], name="Histogram", **histogram_kwargs),
             row=row,
             col=col,
         )
@@ -103,22 +92,30 @@ def plot_histogram(
                     y=kernel(x),
                     mode="lines",
                     name="PDF Estimation",
-                    legendgroup="PDF Estimation",
-                    showlegend=True if i == 0 else False,
                     **plot_kwargs,
                 ),
                 row=row,
                 col=col,
             )
         fig.update_xaxes(
-            title=dict(text="<b>{}</b>".format(label[var])),
-            exponentformat="E",
+            title_text="{}".format(label[var]),
+            title_font=dict(family="Arial", size=20),
+            gridcolor="lightgray",
+            showline=True,
+            linewidth=2.5,
+            linecolor="black",
+            mirror=True,
             row=row,
             col=col,
         )
         fig.update_yaxes(
-            title=dict(text="<b>{}</b>".format(y_label), standoff=0),
-            exponentformat="E",
+            title_text="{}".format(y_label),
+            title_font=dict(family="Arial", size=20),
+            gridcolor="lightgray",
+            showline=True,
+            linewidth=2.5,
+            linecolor="black",
+            mirror=True,
             row=row,
             col=col,
         )
diff --git a/ross/stochastic/st_shaft_element.py b/ross/stochastic/st_shaft_element.py
index d735ddf5..09d2d3d8 100644
--- a/ross/stochastic/st_shaft_element.py
+++ b/ross/stochastic/st_shaft_element.py
@@ -260,7 +260,7 @@ class ST_ShaftElement:
 
         return f_list
 
-    def plot_random_var(self, var_list=None, histogram_kwargs=None, plot_kwargs=None):
+    def plot_random_var(self, var_list=[], histogram_kwargs={}, plot_kwargs={}):
         """Plot histogram and the PDF.
 
         This function creates a histogram to display the random variable
@@ -270,7 +270,6 @@ class ST_ShaftElement:
         ----------
         var_list : list, optional
             List of random variables, in string format, to plot.
-            Default is plotting all the random variables.
         histogram_kwargs : dict, optional
             Additional key word arguments can be passed to change
             the plotly.go.histogram (e.g. histnorm="probability density", nbinsx=20...).
@@ -303,11 +302,9 @@ class ST_ShaftElement:
         if "material" in is_random:
             is_random.remove("material")
 
-        if var_list is None:
-            var_list = is_random
-        elif not all(var in is_random for var in var_list):
+        if not all(var in self.is_random for var in var_list):
             raise ValueError(
-                "Random variable not in var_list. Select variables from {}".format(
+                "Not random variable in var_list. Select variables from {}".format(
                     is_random
                 )
             )


Test patch:
diff --git a/ross/tests/test_stochastic_elements.py b/ross/tests/test_stochastic_elements.py
index c8e8df3d..373a52e8 100644
--- a/ross/tests/test_stochastic_elements.py
+++ b/ross/tests/test_stochastic_elements.py
@@ -188,7 +188,7 @@ def test_st_bearing_error_messages(rand_bearing_constant_coefs):
     with pytest.raises(ValueError) as ex:
         rand_bearing_constant_coefs.plot_random_var(["kxy"])
     assert (
-        "Random variable not in var_list. Select variables from ['kxx', 'cxx', 'kyy', 'cyy']"
+        "Not random variable in var_list. Select variables from ['kxx', 'cxx', 'kyy', 'cyy']"
         in str(ex.value)
     )
 
@@ -205,7 +205,7 @@ def test_st_disk_error_messages(rand_disk_from_inertia):
     with pytest.raises(ValueError) as ex:
         rand_disk_from_inertia.plot_random_var(["n"])
     assert (
-        "Random variable not in var_list. Select variables from ['m', 'Id', 'Ip']"
+        "Not random variable in var_list. Select variables from ['m', 'Id', 'Ip']"
         in str(ex.value)
     )
 
@@ -222,7 +222,7 @@ def test_st_shaft_error_messages(rand_shaft):
     with pytest.raises(ValueError) as ex:
         rand_shaft.plot_random_var(["n"])
     assert (
-        "Random variable not in var_list. Select variables from ['L', 'idl', 'odl', 'idr', 'odr']"
+        "Not random variable in var_list. Select variables from ['L', 'idl', 'odl', 'idr', 'odr']"
         in str(ex.value)
     )
 
@@ -238,7 +238,7 @@ def test_st_shaft_error_messages(rand_shaft):
 def test_st_point_mass_error_messages(rand_point_mass):
     with pytest.raises(ValueError) as ex:
         rand_point_mass.plot_random_var(["n"])
-    assert "Random variable not in var_list. Select variables from ['mx', 'my']" in str(
+    assert "Not random variable in var_list. Select variables from ['mx', 'my']" in str(
         ex.value
     )