def test_st_bearing_elements_odd_length(): tim0 = ShaftElement( L=0.25, idl=0, odl=0.05, material=steel, ) tim1 = ShaftElement( L=0.25, idl=0, odl=0.05, material=steel, ) shaft_elm = [tim0, tim1] disk0 = DiskElement(n=1, m=20, Id=1, Ip=1) brg0 = ST_BearingElement( n=0, kxx=[1e6, 2e6], cxx=[1e3, 2e3], is_random=["kxx", "cxx"], ) brg1 = ST_BearingElement( n=2, kxx=[1e6, 2e6, 3e6], cxx=[1e3, 2e3, 3e3], is_random=["kxx", "cxx"], ) with pytest.raises(ValueError) as ex: ST_Rotor(shaft_elm, [disk0], [brg0, brg1]) assert "not all random bearing elements lists have same length." in str( ex.value)
def test_save_load(tim, tap_tim): file = Path(tempdir) / "tim.toml" tim.save(file) tim_loaded = ShaftElement.load(file) assert tim == tim_loaded file = Path(tempdir) / "tap_tim.toml" tap_tim.save(file) tap_tim_loaded = ShaftElement.load(file) assert tap_tim == tap_tim_loaded
def test_st_disk_elements_odd_length(): tim0 = ShaftElement(L=0.25, idl=0, odl=0.05, material=steel) tim1 = ShaftElement(L=0.25, idl=0, odl=0.05, material=steel) shaft_elm = [tim0, tim1] disk0 = ST_DiskElement(n=0, m=[20, 30], Id=1, Ip=1, is_random=["m"]) disk1 = ST_DiskElement(n=2, m=[20, 30, 40], Id=1, Ip=1, is_random=["m"]) with pytest.raises(ValueError) as ex: ST_Rotor(shaft_elm, [disk0, disk1]) assert "not all random disk elements lists have same length." in str( ex.value)
def rotor1(): # rotor with 6 shaft elements, 2 disks and 2 random bearings i_d = 0 o_d = 0.05 n = 6 L = [0.25 for _ in range(n)] shaft_elem = [ShaftElement(l, i_d, o_d, material=steel) for l in L] disk0 = DiskElement.from_geometry(n=2, material=steel, width=0.07, i_d=0.05, o_d=0.28) disk1 = DiskElement.from_geometry(n=4, material=steel, width=0.07, i_d=0.05, o_d=0.28) kxx = [1e6, 2e6] cxx = [1e3, 2e3] bearing0 = ST_BearingElement(n=0, kxx=kxx, cxx=cxx, is_random=["kxx", "cxx"]) bearing1 = ST_BearingElement(n=6, kxx=kxx, cxx=cxx, is_random=["kxx", "cxx"]) return ST_Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1])
def random_var(self, 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.ShaftElement. Parameters ---------- is_random : list List of the object attributes to become stochastic. *args : dict Dictionary instanciating the ross.ShaftElement class. The attributes that are supposed to be stochastic should be set as lists of random variables. Returns ------- f_list : generator Generator of random objects. """ args_dict = args[0] new_args = [] for i in range(len(args_dict[is_random[0]])): arg = [] for key, value in args_dict.items(): if key in is_random: arg.append(value[i]) else: arg.append(value) new_args.append(arg) f_list = (ShaftElement(*arg) for arg in new_args) return f_list
def tim2(): # Timoshenko element le_ = 0.4 i_d_ = 0 o_d_ = 0.25 return ShaftElement( le_, i_d_, o_d_, material=steel, rotary_inertia=True, shear_effects=True )
def test_st_point_mass_elements_odd_length(): tim0 = ShaftElement(L=0.25, idl=0, odl=0.05, material=steel) tim1 = ShaftElement(L=0.25, idl=0, odl=0.05, material=steel) shaft_elm = [tim0, tim1] disk0 = DiskElement(n=1, m=20, Id=1, Ip=1) brg0 = BearingElement(n=0, kxx=1e6, cxx=1e3, n_link=3) brg1 = BearingElement(n=2, kxx=1e6, cxx=1e3, n_link=4) sup0 = BearingElement(n=3, kxx=1e6, cxx=1e3) sup1 = BearingElement(n=4, kxx=1e6, cxx=1e3) pm0 = ST_PointMass(n=3, m=[1, 2], is_random=["m"]) pm1 = ST_PointMass(n=4, m=[1, 2, 3], is_random=["m"]) with pytest.raises(ValueError) as ex: ST_Rotor(shaft_elm, [disk0], [brg0, brg1, sup0, sup1], [pm0, pm1]) assert "not all random point mass lists have same length." in str(ex.value)
def tim(): # Timoshenko element z_ = 0 le_ = 0.25 i_d_l = 0 o_d_l = 0.05 i_d_r = 0 o_d_r = 0.05 return ShaftElement( le_, i_d_l, o_d_l, i_d_r, o_d_r, steel, rotary_inertia=True, shear_effects=True )
def tap2(): # Timoshenko element L = 0.4 i_d_l = 0.0 i_d_r = 0.0 o_d_l = 0.25 o_d_r = 0.25 return ShaftElement( L, i_d_l, o_d_l, i_d_r, o_d_r, steel, shear_effects=True, rotary_inertia=True )
def eb(): # Euler-Bernoulli element le_ = 0.25 i_d_ = 0 o_d_ = 0.05 return ShaftElement(le_, i_d_, o_d_, steel, shear_effects=False, rotary_inertia=False)
def report2(): # rotor type: single double overhung i_d = 0.0 o_d = 0.05 n = 50 L = [0.03 for _ in range(n)] shaft_elem = [ ShaftElement(l, i_d, o_d, material=steel, shear_effects=True, rotary_inertia=True, gyroscopic=True) for l in L ] disk0 = DiskElement.from_geometry(n=0, material=steel, width=0.07, i_d=0.05, o_d=0.28) disk1 = DiskElement.from_geometry(n=50, material=steel, width=0.07, i_d=0.05, o_d=0.35) stfx = 1e6 stfy = 0.8e6 bearing0 = BearingElement(15, kxx=stfx, kyy=stfy, cxx=1000) bearing1 = BearingElement(35, kxx=stfx, kyy=stfy, cxx=1000) rotor = Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1]) minspeed = 3820.0 maxspeed = 9550.0 machine_type = "pump" units = "rpm" return Report(rotor, minspeed, maxspeed, machine_type, units)
def report0(): # rotor type: between bearings i_d = 0.0 o_d = 0.05 n = 50 L = [0.03 for _ in range(n)] shaft_elem = [ ShaftElement(l, i_d, o_d, material=steel, shear_effects=True, rotary_inertia=True, gyroscopic=True) for l in L ] disk0 = DiskElement.from_geometry(n=15, material=steel, width=0.07, i_d=0.05, o_d=0.28) disk1 = DiskElement.from_geometry(n=35, material=steel, width=0.07, i_d=0.05, o_d=0.35) stfx = 1e6 stfy = 0.8e6 bearing0 = BearingElement(0, kxx=stfx, kyy=stfy, cxx=1000) bearing1 = BearingElement(50, kxx=stfx, kyy=stfy, cxx=1000) rotor = Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1]) minspeed = 400.0 maxspeed = 1000.0 machine_type = "compressor" units = "rad/s" return Report(rotor, minspeed, maxspeed, machine_type, units)
def test_from_table(): for shaft_file in [ os.path.dirname(os.path.realpath(__file__)) + "/data/shaft_us.xls", os.path.dirname(os.path.realpath(__file__)) + "/data/shaft_si.xls", ]: shaft = ShaftElement.from_table(shaft_file, sheet_type="Model", sheet_name="Model") el0 = shaft[0] assert el0.n == 0 assert_allclose(el0.i_d, 0.1409954) assert_allclose(el0.o_d, 0.151003) mat0 = el0.material assert_allclose(mat0.rho, 7833.41, atol=0.003) assert_allclose(mat0.E, 206842718795.05, rtol=3e-06) assert_allclose(mat0.G_s, 82737087518.02, rtol=2e-06) # test if node is the same for elements in different layers assert shaft[8].n == 8 assert shaft[9].n == 8 assert_allclose(shaft[8].material.E, 206842718795.05, rtol=3e-06) assert_allclose(shaft[9].material.E, 6894.75, atol=0.008)
def report2(): # rotor type: double overhung i_d = 0 o_d = 0.05 n = 6 L = [0.25 for _ in range(n)] shaft_elem = [ ShaftElement( l, i_d, o_d, material=steel, shear_effects=True, rotary_inertia=True, gyroscopic=True, ) for l in L ] disk0 = DiskElement.from_geometry(n=0, material=steel, width=0.07, i_d=0.05, o_d=0.28) disk1 = DiskElement.from_geometry(n=6, material=steel, width=0.07, i_d=0.05, o_d=0.28) stfx = [0.4e7, 0.5e7, 0.6e7, 0.7e7] stfy = [0.8e7, 0.9e7, 1.0e7, 1.1e7] freq = [400, 800, 1200, 1600] bearing0 = BearingElement(2, kxx=stfx, kyy=stfy, cxx=2e3, frequency=freq) bearing1 = BearingElement(4, kxx=stfx, kyy=stfy, cxx=2e3, frequency=freq) oper_clerance_brg = [bearing0, bearing1] rotor = Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1]) # coefficients for minimum clearance stfx = [0.7e7, 0.8e7, 0.9e7, 1.0e7] dampx = [2.0e3, 1.9e3, 1.8e3, 1.7e3] freq = [400, 800, 1200, 1600] bearing0 = BearingElement(2, kxx=stfx, cxx=dampx, frequency=freq) bearing1 = BearingElement(4, kxx=stfx, cxx=dampx, frequency=freq) min_clearance_brg = [bearing0, bearing1] # coefficients for maximum clearance stfx = [0.4e7, 0.5e7, 0.6e7, 0.7e7] dampx = [2.8e3, 2.7e3, 2.6e3, 2.5e3] freq = [400, 800, 1200, 1600] bearing0 = BearingElement(2, kxx=stfx, cxx=dampx, frequency=freq) bearing1 = BearingElement(4, kxx=stfx, cxx=dampx, frequency=freq) max_clearance_brg = [bearing0, bearing1] config = Config() config.update_config( rotor_properties={ "rotor_speeds": { "min_speed": 3820.0, "max_speed": 9550.0, "oper_speed": 8000.0, "trip_speed": 10500.0, "unit": "rpm", }, "rotor_id": { "type": "axial_flow" }, }, bearings={ "oper_clearance": oper_clerance_brg, "min_clearance": min_clearance_brg, "max_clearance": max_clearance_brg, }, run_campbell={"speed_range": np.linspace(0, 1500, 51)}, run_unbalance_response={ "probes": { "node": [1, 4], "orientation": [np.pi / 2, np.pi / 2], "unit": "rad", }, "frequency_range": np.linspace(0, 1500, 101), "plot_deflected_shape": { "speed": [615] }, }, plot_ucs={"stiffness_range": (5, 8)}, stability_level1={ "D": [0.35, 0.35], "H": [0.08, 0.08], "rated_power": [6000, 8000], "rho_ratio": [1.11, 1.14], "rho_suction": 30.45, "rho_discharge": 37.65, "length_unit": "m", "power_unit": "hp", "density_unit": "kg/m**3", }, ) return Report(rotor, config)
def report1(): # rotor type: single overhung i_d = 0.0 o_d = 0.05 n = 50 L = [0.03 for _ in range(n)] shaft_elem = [ ShaftElement( l, i_d, o_d, material=steel, shear_effects=True, rotary_inertia=True, gyroscopic=True, ) for l in L ] disk0 = DiskElement.from_geometry( n=0, material=steel, width=0.07, i_d=0.05, o_d=0.28 ) stfx = 1e6 stfy = 0.8e6 bearing0 = BearingElement(15, kxx=stfx, kyy=stfy, cxx=1000) bearing1 = BearingElement(50, kxx=stfx, kyy=stfy, cxx=1000) rotor = Rotor(shaft_elem, [disk0], [bearing0, bearing1]) # coefficients for minimum clearance stfx = [0.7e7, 0.8e7, 0.9e7, 1.0e7] dampx = [2.0e3, 1.9e3, 1.8e3, 1.7e3] freq = [400, 800, 1200, 1600] bearing0 = BearingElement(0, kxx=stfx, cxx=dampx, frequency=freq) bearing1 = BearingElement(6, kxx=stfx, cxx=dampx, frequency=freq) min_clearance_brg = [bearing0, bearing1] # coefficients for maximum clearance stfx = [0.4e7, 0.5e7, 0.6e7, 0.7e7] dampx = [2.8e3, 2.7e3, 2.6e3, 2.5e3] freq = [400, 800, 1200, 1600] bearing0 = BearingElement(0, kxx=stfx, cxx=dampx, frequency=freq) bearing1 = BearingElement(6, kxx=stfx, cxx=dampx, frequency=freq) max_clearance_brg = [bearing0, bearing1] bearing_clearance_lists = [min_clearance_brg, max_clearance_brg] bearing_stiffness_range = (5, 8) speed_range = (400, 1000) tripspeed = 1200 machine_type = "turbine" units = "rad/s" return Report( rotor, speed_range, tripspeed, bearing_stiffness_range, bearing_clearance_lists, machine_type, units, )