Skip to content

Commit 5c4b023

Browse files
authored
Merge pull request #1230 from raphaeltimbo/optimize-test-performance
Optimize slow tests to reduce test suite execution time
2 parents 1868c0c + 9fa313c commit 5c4b023

File tree

1 file changed

+42
-158
lines changed

1 file changed

+42
-158
lines changed

ross/tests/test_rotor_assembly.py

Lines changed: 42 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,194 +2288,75 @@ def test_ucs_calc(rotor8):
22882288

22892289

22902290
def test_ucs_rotor9(rotor9):
2291+
# Simplified test: use num=5 instead of num=20 to reduce test time (~75% faster)
22912292
exp_rotor_wn = np.array(
22922293
[
22932294
[
2294-
89.61923784473375,
2295-
120.89655743664413,
2296-
162.59246554800114,
2297-
217.42553100241312,
2298-
287.6459465590863,
2299-
372.935347725518,
2300-
466.2581426686537,
2301-
551.4076269641628,
2302-
613.1237259191993,
2303-
650.4689786203988,
2304-
671.2479800816767,
2305-
682.5353774789179,
2306-
688.6485929814294,
2307-
691.965477524608,
2308-
693.7688181845082,
2309-
694.7506707995042,
2310-
695.2857209934174,
2311-
695.577438207025,
2312-
695.7365318523782,
2313-
695.8233102639163,
2295+
89.61923786,
2296+
350.42266504,
2297+
662.41928664,
2298+
694.07268245,
2299+
695.82331031,
23142300
],
23152301
[
2316-
124.8108608009496,
2317-
168.92618197956605,
2318-
228.5753022242499,
2319-
309.1399173060739,
2320-
417.7337051968829,
2321-
563.5536938601297,
2322-
757.9439326311913,
2323-
1013.3462956039914,
2324-
1338.3333635278868,
2325-
1716.48711727428,
2326-
2004.8471556137,
2327-
2078.8761601177744,
2328-
2097.725398329982,
2329-
2104.9250739620065,
2330-
2108.224809182831,
2331-
2109.8706285775806,
2332-
2110.7269388638374,
2333-
2111.182371668304,
2334-
2111.427443127732,
2335-
2111.5601496202053,
2302+
124.81086083,
2303+
523.02183296,
2304+
1891.18155397,
2305+
2108.7448203,
2306+
2111.56014972,
23362307
],
23372308
[
2338-
976.610014941276,
2339-
979.8071596437271,
2340-
985.7435440438873,
2341-
996.8720841293019,
2342-
1018.0435385669914,
2343-
1059.040021915284,
2344-
1138.8336540231767,
2345-
1287.1396017447778,
2346-
1530.728131538211,
2347-
1866.6004173519655,
2348-
2224.740955271474,
2349-
2566.1521460703593,
2350-
2812.5568536324695,
2351-
2954.956819348177,
2352-
3030.8828351975917,
2353-
3070.974195701119,
2354-
3092.3284826481,
2355-
3103.806643182663,
2356-
3110.0148616594533,
2357-
3113.3854057718704,
2309+
976.61001489,
2310+
1046.09648924,
2311+
2047.58519431,
2312+
3043.40464892,
2313+
3113.38540495,
23582314
],
23592315
[
2360-
2159.640747974065,
2361-
2159.756470270719,
2362-
2159.969971035258,
2363-
2160.366035282546,
2364-
2161.1082776995636,
2365-
2162.5260227884364,
2366-
2165.334410630516,
2367-
2171.3131180341056,
2368-
2186.1348008252444,
2369-
2238.1871377763114,
2370-
2490.9613952181917,
2371-
2978.354255657329,
2372-
3456.7805801535656,
2373-
3814.959990456543,
2374-
4040.908191796628,
2375-
4171.396315088025,
2376-
4244.09186723666,
2377-
4284.062958149884,
2378-
4305.937322108033,
2379-
4317.887004191494,
2316+
2159.64074905,
2317+
2162.07931839,
2318+
2321.68023491,
2319+
4080.81909788,
2320+
4317.88700623,
23802321
],
23812322
]
23822323
)
2383-
ucs_results = rotor9.run_ucs()
2324+
ucs_results = rotor9.run_ucs(num=5)
23842325
assert_allclose(ucs_results.wn, exp_rotor_wn)
23852326

23862327
exp_rotor_wn = np.array(
23872328
[
23882329
[
2389-
89.61947064,
2390-
120.89741889,
2391-
162.5960395,
2392-
217.44095694,
2393-
287.71229812,
2394-
373.20676063,
2395-
467.22436151,
2396-
554.01174191,
2397-
618.0228653,
2398-
657.38198264,
2399-
679.5050572,
2400-
691.58822264,
2401-
698.15087843,
2402-
701.71684971,
2403-
703.65712249,
2404-
704.71396966,
2405-
705.29001687,
2406-
705.60412456,
2407-
705.77544067,
2330+
89.61947056,
2331+
350.61514002,
2332+
670.08583401,
2333+
703.98416314,
24082334
705.86888929,
24092335
],
24102336
[
2411-
126.08902147,
2412-
170.65739193,
2413-
230.92107312,
2414-
312.32101392,
2415-
422.05546021,
2416-
569.45142419,
2417-
766.09122048,
2418-
1025.02536231,
2419-
1357.18701994,
2420-
1759.29639866,
2421-
2139.22396755,
2422-
2225.72234144,
2423-
2241.24852987,
2424-
2246.71661805,
2425-
2249.14967666,
2426-
2250.34715925,
2427-
2250.96610863,
2428-
2251.29417729,
2429-
2251.47039346,
2430-
2251.56572169,
2337+
126.08902134,
2338+
528.47472934,
2339+
1971.00830161,
2340+
2249.52916259,
2341+
2251.5657217,
24312342
],
24322343
[
24332344
1006.73169597,
2434-
1010.04096437,
2435-
1016.17902002,
2436-
1027.66388689,
2437-
1049.44232444,
2438-
1091.39953214,
2439-
1172.55460038,
2440-
1322.87033841,
2441-
1570.73575288,
2442-
1916.3041552,
2443-
2265.71692139,
2444-
2655.54276614,
2445-
2969.42618151,
2446-
3163.00092959,
2447-
3269.25575144,
2448-
3325.84538219,
2449-
3356.03761948,
2450-
3372.26520948,
2451-
3381.03936768,
2345+
1078.17877977,
2346+
2100.24701415,
2347+
3286.9082896,
24522348
3385.80171304,
24532349
],
24542350
[
24552351
2282.84557629,
2456-
2282.91523796,
2457-
2283.04371506,
2458-
2283.28189556,
2459-
2283.72771552,
2460-
2284.57736115,
2461-
2286.25338975,
2462-
2289.79373785,
2463-
2298.45136454,
2464-
2328.81587039,
2465-
2527.00408181,
2466-
3011.54457196,
2467-
3511.90570401,
2468-
3911.96812784,
2469-
4184.16765863,
2470-
4351.24520897,
2471-
4448.09334563,
2472-
4502.60333569,
2473-
4532.82984364,
2352+
2284.30991972,
2353+
2383.54778909,
2354+
4234.40738673,
24742355
4549.46314886,
24752356
],
24762357
]
24772358
)
2478-
ucs_results = rotor9.run_ucs(synchronous=True)
2359+
ucs_results = rotor9.run_ucs(synchronous=True, num=5)
24792360
assert_allclose(ucs_results.wn, exp_rotor_wn, rtol=1e-6)
24802361

24812362

@@ -2718,12 +2599,15 @@ def test_harmonic_response(rotor9):
27182599

27192600
def test_amb_controller():
27202601
# Test for the magnetic_bearing_controller method.
2602+
# Simplified: reduced simulation time from 10s to 2s (5x fewer time steps, ~80% faster)
27212603
from ross.rotor_assembly import rotor_amb_example
27222604

27232605
rotor = rotor_amb_example()
27242606

27252607
speed = 1200
2726-
t = np.linspace(0, 10, 40001)
2608+
t = np.arange(
2609+
0, 2, 0.00025
2610+
) # 2 seconds with dt=0.00025s (8000 steps vs original 40001)
27272611
node = [27, 29]
27282612
mass = [10, 10]
27292613
probes = [12, 43]

0 commit comments

Comments
 (0)