Skip to content

Commit 3ab9d85

Browse files
committed
pass ruff
1 parent 7711807 commit 3ab9d85

7 files changed

Lines changed: 86 additions & 74 deletions

File tree

docs/user_guide/tutorial_part_5.ipynb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4592,10 +4592,8 @@
45924592
"metadata": {},
45934593
"outputs": [],
45944594
"source": [
4595-
"A = [[0, 1],\n",
4596-
" [-2, -0.5]]\n",
4597-
"B = [[0],\n",
4598-
" [1]]\n",
4595+
"A = [[0, 1], [-2, -0.5]]\n",
4596+
"B = [[0], [1]]\n",
45994597
"C = [[1, 0]]\n",
46004598
"\n",
46014599
"Q_lqr = np.diag([10, 1])\n",
@@ -4631,7 +4629,7 @@
46314629
"outputs": [],
46324630
"source": [
46334631
"C_lead = lead_lag(tau=0.02, alpha=0.1, k=2.0)\n",
4634-
"C_lag = lead_lag(tau=0.5, alpha=5.0, k=1.0)"
4632+
"C_lag = lead_lag(tau=0.5, alpha=5.0, k=1.0)"
46354633
]
46364634
},
46374635
{
@@ -4723,7 +4721,7 @@
47234721
" pid(2, 1, 0.02, n_f=200),\n",
47244722
" lead_lag(0.03, 0.1),\n",
47254723
" notch_filter(120, 0.02, 0.2),\n",
4726-
" low_pass_filter(400)\n",
4724+
" low_pass_filter(400),\n",
47274725
")"
47284726
]
47294727
},
@@ -4784,12 +4782,14 @@
47844782
],
47854783
"source": [
47864784
"plot_frequency_response(\n",
4787-
" C, N, C * N,\n",
4785+
" C,\n",
4786+
" N,\n",
4787+
" C * N,\n",
47884788
" legends=[\"Controller\", \"Filter\", \"Combined\"],\n",
47894789
" w_min=1e-1,\n",
47904790
" w_max=1e5,\n",
47914791
" n_points=1500,\n",
4792-
" title=\"Bode (Controller / Filter / Combined)\"\n",
4792+
" title=\"Bode (Controller / Filter / Combined)\",\n",
47934793
")"
47944794
]
47954795
},

ross/bearing_seal_element.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,6 @@ def __init__(
14871487
):
14881488
self.seal_leakage = seal_leakage
14891489

1490-
14911490
super().__init__(
14921491
n=n,
14931492
frequency=frequency,

ross/bearings/magnetic/controllers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def plot_frequency_response(*systems, **kwargs):
8585
]
8686

8787
if legends is None:
88-
legends = [f"System {i+1}" for i in range(len(systems))]
88+
legends = [f"System {i + 1}" for i in range(len(systems))]
8989
elif len(legends) != len(systems):
9090
raise ValueError("O número de legendas deve ser igual ao número de sistemas.")
9191

ross/bearings/plain_journal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ def __init__(
287287
a, b = self._get_interp_coeffs(
288288
T_muI, T_muF, mu_I, mu_F
289289
) # Interpolation coefficients
290-
self.interpolate = lambda reference: a * (
291-
reference**b
290+
self.interpolate = lambda reference: (
291+
a * (reference**b)
292292
) # Interpolation function
293293
self.reference_viscosity = self.interpolate(self.reference_temperature)
294294

ross/rotor_assembly.py

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ def __init__(
156156
modal_damping=None,
157157
default_modes=None,
158158
tag=None,
159-
160159
):
161160
self.parameters = {"min_w": min_w, "max_w": max_w, "rated_w": rated_w}
162161

@@ -560,7 +559,7 @@ def flatten(l):
560559

561560
M0[np.ix_(dofs, dofs)] += elm.M()
562561
C0[np.ix_(dofs, dofs)] += elm.C()
563-
K0[np.ix_(dofs, dofs)] += elm.K()
562+
K0[np.ix_(dofs, dofs)] += elm.K()
564563
G0[np.ix_(dofs, dofs)] += elm.G()
565564

566565
if elm in self.shaft_elements:
@@ -573,7 +572,11 @@ def flatten(l):
573572
# Damping configuration
574573
self.modal_damping = modal_damping
575574
self.default_modals = default_modes
576-
self.C0 = C0 if self.modal_damping == None else self._modal_damping(self.modal_damping)
575+
self.C0 = (
576+
C0
577+
if self.modal_damping == None
578+
else self._modal_damping(self.modal_damping)
579+
)
577580
self.G0 = G0
578581
self.Ksdt0 = Ksdt0
579582

@@ -666,7 +669,7 @@ def _find_linked_bearing_node(self, node):
666669
return brg.n
667670
return None
668671

669-
def _modal_damping(self, modal_damping ):
672+
def _modal_damping(self, modal_damping):
670673
"""Compute the physical damping matrix from modal damping ratios.
671674
672675
Parameters
@@ -687,9 +690,7 @@ def _modal_damping(self, modal_damping ):
687690

688691
w = np.sqrt(evals.real)
689692
below_1rpm = Q_(np.sort(w), "rad/s").to("RPM").m < 1
690-
modal_damping = np.block(
691-
[np.zeros(below_1rpm.sum()), np.array(modal_damping)]
692-
)
693+
modal_damping = np.block([np.zeros(below_1rpm.sum()), np.array(modal_damping)])
693694
idx = np.argsort(w)
694695
w = w[idx]
695696
phi = evecs[:, idx]
@@ -996,11 +997,11 @@ def run_critical_speed(self, speed_range=None, num_modes=12, rtol=0.005):
996997
wd = np.zeros_like(_wd)
997998

998999
for i in range(len(wn)):
999-
wn_func = lambda s: (s - self.run_modal(s, num_modes).wn[i])
1000+
wn_func = lambda s: s - self.run_modal(s, num_modes).wn[i]
10001001
wn[i] = newton(func=wn_func, x0=_wn[i], rtol=rtol)
10011002

10021003
for i in range(len(wd)):
1003-
wd_func = lambda s: (s - self.run_modal(s, num_modes).wd[i])
1004+
wd_func = lambda s: s - self.run_modal(s, num_modes).wd[i]
10041005
wd[i] = newton(func=wd_func, x0=_wd[i], rtol=rtol)
10051006

10061007
log_dec = np.zeros_like(wn)
@@ -2627,26 +2628,32 @@ def integrate_system(self, speed, F, t, **kwargs):
26272628
add_to_RHS = kwargs.get("add_to_RHS")
26282629

26292630
if add_to_RHS is None:
2630-
forces = lambda step, **curr_state: F[step, :] + reduction[1](
2631-
magnetic_force(
2632-
step,
2633-
curr_state.get("dt"),
2634-
reduction[2](curr_state.get("y")),
2631+
forces = lambda step, **curr_state: (
2632+
F[step, :]
2633+
+ reduction[1](
2634+
magnetic_force(
2635+
step,
2636+
curr_state.get("dt"),
2637+
reduction[2](curr_state.get("y")),
2638+
)
26352639
)
26362640
)
26372641
else:
2638-
forces = lambda step, **curr_state: F[step, :] + reduction[1](
2639-
add_to_RHS(
2640-
step,
2641-
time_step=curr_state.get("dt"),
2642-
disp_resp=reduction[2](curr_state.get("y")),
2643-
velc_resp=reduction[2](curr_state.get("ydot")),
2644-
accl_resp=reduction[2](curr_state.get("y2dot")),
2645-
)
2646-
+ magnetic_force(
2647-
step,
2648-
curr_state.get("dt"),
2649-
reduction[2](curr_state.get("y")),
2642+
forces = lambda step, **curr_state: (
2643+
F[step, :]
2644+
+ reduction[1](
2645+
add_to_RHS(
2646+
step,
2647+
time_step=curr_state.get("dt"),
2648+
disp_resp=reduction[2](curr_state.get("y")),
2649+
velc_resp=reduction[2](curr_state.get("ydot")),
2650+
accl_resp=reduction[2](curr_state.get("y2dot")),
2651+
)
2652+
+ magnetic_force(
2653+
step,
2654+
curr_state.get("dt"),
2655+
reduction[2](curr_state.get("y")),
2656+
)
26502657
)
26512658
)
26522659

@@ -2773,8 +2780,8 @@ def _init_ambs_for_integrate(self, dt, **kwargs):
27732780
rotor = deepcopy(self)
27742781

27752782
if len(magnetic_bearings):
2776-
magnetic_force = (
2777-
lambda step, time_step, disp_resp: self.magnetic_bearing_controller(
2783+
magnetic_force = lambda step, time_step, disp_resp: (
2784+
self.magnetic_bearing_controller(
27782785
step, magnetic_bearings, time_step, disp_resp, **kwargs
27792786
)
27802787
)

ross/tests/test_gear_element.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def test_mesh_params(mesh):
140140
assert mesh.gear_ratio == 1.0
141141
assert mesh.contact_ratio == 1.7897798668330458
142142
assert mesh.hertzian_stiffness == 3555868607.9093266
143-
assert_allclose(mesh.stiffness, 4.096607e+08, rtol=1e-6, atol=1e-5)
143+
assert_allclose(mesh.stiffness, 4.096607e08, rtol=1e-6, atol=1e-5)
144144
assert_allclose(
145145
mesh.stiffness_range[:5],
146146
[

ross/tests/test_rotor_assembly.py

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,7 @@ def test_modal_6dof(rotor_6dof):
18671867
assert_almost_equal(modal.wn[:5], wn, decimal=2)
18681868
assert_almost_equal(modal.wd[:5], wd, decimal=2)
18691869

1870+
18701871
def test_modal_damping():
18711872
# Rotor with modal damping with 6 shaft elements 2 disks and 2 bearings
18721873
i_d = 0
@@ -1895,51 +1896,56 @@ def test_modal_damping():
18951896
bearing0 = BearingElement(0, kxx=stfx, kyy=stfy, cxx=0)
18961897
bearing1 = BearingElement(6, kxx=stfx, kyy=stfy, cxx=0)
18971898

1898-
modal_damping=[0.001, 0.001]
1899-
default_modes=0.01
1899+
modal_damping = [0.001, 0.001]
1900+
default_modes = 0.01
19001901

1901-
rotor=Rotor(shaft_elem, [disk0, disk1], [bearing0, bearing1],
1902-
modal_damping=modal_damping, default_modes=default_modes)
1903-
1904-
speed = Q_(np.arange(0,10001,200), "RPM").to('rad/s').m
1902+
rotor = Rotor(
1903+
shaft_elem,
1904+
[disk0, disk1],
1905+
[bearing0, bearing1],
1906+
modal_damping=modal_damping,
1907+
default_modes=default_modes,
1908+
)
1909+
1910+
speed = Q_(np.arange(0, 10001, 200), "RPM").to("rad/s").m
19051911
n1 = 2
1906-
m1 = Q_(11867,'g.mm').to('kg.m').m
1907-
p1 = Q_(0,'rad')
1912+
m1 = Q_(11867, "g.mm").to("kg.m").m
1913+
p1 = Q_(0, "rad")
19081914
n2 = 4
1909-
m2 = Q_(11867,'g.mm').to('kg.m').m
1910-
p2 = Q_(0,'rad')
1915+
m2 = Q_(11867, "g.mm").to("kg.m").m
1916+
p2 = Q_(0, "rad")
19111917

19121918
unb_response = rotor.run_freq_response(speed_range=speed)
19131919

1914-
actual_amp=abs(unb_response.freq_resp[n1*6,n1*6,:8])
1915-
actual_phase=np.angle(unb_response.freq_resp[n1*6,n1*6,:8])
1916-
1917-
expected_amp = [0.00000000e+00,
1918-
1.49507920e-06,
1919-
1.80340194e-06,
1920-
2.81943596e-06,
1921-
1.91475919e-05,
1922-
2.54885361e-06,
1923-
9.41771898e-07,
1924-
4.55762869e-07]
1925-
1926-
expected_phase = [0.00000000e+00,
1927-
-8.06802391e-05,
1928-
-1.82013808e-04,
1929-
-3.91432201e-04,
1930-
-3.59430355e-03,
1931-
-3.14083143e+00,
1932-
-3.14087742e+00,
1933-
-3.14029804e+00]
1934-
1920+
actual_amp = abs(unb_response.freq_resp[n1 * 6, n1 * 6, :8])
1921+
actual_phase = np.angle(unb_response.freq_resp[n1 * 6, n1 * 6, :8])
1922+
1923+
expected_amp = [
1924+
0.00000000e00,
1925+
1.49507920e-06,
1926+
1.80340194e-06,
1927+
2.81943596e-06,
1928+
1.91475919e-05,
1929+
2.54885361e-06,
1930+
9.41771898e-07,
1931+
4.55762869e-07,
1932+
]
19351933

1934+
expected_phase = [
1935+
0.00000000e00,
1936+
-8.06802391e-05,
1937+
-1.82013808e-04,
1938+
-3.91432201e-04,
1939+
-3.59430355e-03,
1940+
-3.14083143e00,
1941+
-3.14087742e00,
1942+
-3.14029804e00,
1943+
]
19361944

19371945
assert_allclose(actual_amp, expected_amp)
19381946
assert_allclose(actual_phase, expected_phase)
19391947

19401948

1941-
1942-
19431949
@pytest.fixture
19441950
def rotor8():
19451951
# Rotor with damping

0 commit comments

Comments
 (0)