44import pytest
55from pytest import approx
66
7- import linerate
7+ from linerate .models .cigre601 import Cigre601
8+ from linerate .models .thermal_model import ThermalModel
9+ from linerate .types import Conductor , Span , Tower , Weather
810
911
10- def test_example_a_convective_cooling (example_model_1_conductors ):
11- assert example_model_1_conductors .compute_convective_cooling (100 , None ) == approx (77.6 , abs = 0.5 )
12+ def test_example_a_convective_cooling (example_model_1_conductors : ThermalModel ):
13+ assert example_model_1_conductors .compute_convective_cooling (100 ) == approx (77.6 , abs = 0.5 )
1214
1315
14- def test_example_a_radiative_cooling (example_model_1_conductors ):
15- assert example_model_1_conductors .compute_radiative_cooling (100 , None ) == approx (39.1 , abs = 0.5 )
16+ def test_example_a_radiative_cooling (example_model_1_conductors : ThermalModel ):
17+ assert example_model_1_conductors .compute_radiative_cooling (100 ) == approx (39.1 , abs = 0.5 )
1618
1719
18- def test_example_a_solar_heating (example_model_1_conductors ):
19- assert example_model_1_conductors .compute_solar_heating (100 , None ) == approx (27.2 , abs = 0.5 )
20+ def test_example_a_solar_heating (example_model_1_conductors : ThermalModel ):
21+ assert example_model_1_conductors .compute_solar_heating () == approx (27.2 , abs = 0.5 )
2022
2123
22- def test_example_a_resistance (example_model_1_conductors ):
23- assert example_model_1_conductors .compute_resistance (100 , None ) == approx (
24+ def test_example_a_resistance (example_model_1_conductors : ThermalModel ):
25+ assert example_model_1_conductors .compute_resistance (100 , np . nan ) == approx (
2426 9.3905e-5 , abs = 0.0001e-5
2527 )
2628
2729
28- def test_example_a_ampacity (example_model_1_conductors ):
30+ def test_example_a_ampacity (example_model_1_conductors : ThermalModel ):
2931 # There are noticable roundoff errors in the report
3032 assert example_model_1_conductors .compute_steady_state_ampacity (100 , tolerance = 1e-8 ) == approx (
3133 976 , abs = 1.5
3234 )
3335
3436
3537@pytest .fixture
36- def drake_conductor_b ():
37- return linerate . Conductor (
38+ def drake_conductor_b () -> Conductor :
39+ return Conductor (
3840 core_diameter = 10.4e-3 ,
3941 conductor_diameter = 28.1e-3 ,
4042 outer_layer_strand_diameter = 2.2e-3 ,
@@ -52,8 +54,8 @@ def drake_conductor_b():
5254
5355
5456@pytest .fixture
55- def example_weather_b ():
56- return linerate . Weather (
57+ def example_weather_b () -> Weather :
58+ return Weather (
5759 air_temperature = 20 ,
5860 wind_direction = np .radians (80 ), # Conductor azimuth is 0, so angle of attack is 80
5961 wind_speed = 1.66 ,
@@ -63,51 +65,51 @@ def example_weather_b():
6365
6466
6567@pytest .fixture ()
66- def example_span_b (drake_conductor_b ) :
67- start_tower = linerate . Tower (latitude = 50 - 0.0045 , longitude = 0 , altitude = 500 - 88 )
68- end_tower = linerate . Tower (latitude = 50 + 0.0045 , longitude = 0 , altitude = 500 + 88 )
69- return linerate . Span (
68+ def example_span_b (drake_conductor_b : Conductor ) -> Span :
69+ start_tower = Tower (latitude = 50 - 0.0045 , longitude = 0 , altitude = 500 - 88 )
70+ end_tower = Tower (latitude = 50 + 0.0045 , longitude = 0 , altitude = 500 + 88 )
71+ return Span (
7072 conductor = drake_conductor_b ,
7173 start_tower = start_tower ,
7274 end_tower = end_tower ,
7375 num_conductors = 1 ,
7476 )
7577
7678
77- def test_example_span_b_has_correct_altitude (example_span_b ):
79+ def test_example_span_b_has_correct_altitude (example_span_b : Span ):
7880 assert example_span_b .conductor_altitude == approx (500 , abs = 0.5 )
7981
8082
81- def test_example_span_b_has_correct_inclination (example_span_b ):
83+ def test_example_span_b_has_correct_inclination (example_span_b : Span ):
8284 assert np .degrees (example_span_b .inclination ) == approx (10 , abs = 0.5 )
8385
8486
85- def test_example_span_b_has_correct_latitude (example_span_b ):
87+ def test_example_span_b_has_correct_latitude (example_span_b : Span ):
8688 assert example_span_b .latitude == approx (50 )
8789
8890
8991@pytest .fixture ()
90- def example_model_b (example_span_b , example_weather_b ) :
91- return linerate . Cigre601 (example_span_b , example_weather_b , np .datetime64 ("2016-10-03 14:00" ))
92+ def example_model_b (example_span_b : Span , example_weather_b : Weather ) -> Cigre601 :
93+ return Cigre601 (example_span_b , example_weather_b , np .datetime64 ("2016-10-03 14:00" ))
9294
9395
94- def test_example_b_convective_cooling (example_model_b ):
95- assert example_model_b .compute_convective_cooling (100 , None ) == approx (172.1 , abs = 0.5 )
96+ def test_example_b_convective_cooling (example_model_b : ThermalModel ):
97+ assert example_model_b .compute_convective_cooling (100 ) == approx (172.1 , abs = 0.5 )
9698
9799
98- def test_example_b_radiative_cooling (example_model_b ):
99- assert example_model_b .compute_radiative_cooling (100 , None ) == approx (54 , abs = 0.5 )
100+ def test_example_b_radiative_cooling (example_model_b : ThermalModel ):
101+ assert example_model_b .compute_radiative_cooling (100 ) == approx (54 , abs = 0.5 )
100102
101103
102- def test_example_b_solar_heating (example_model_b ):
103- assert example_model_b .compute_solar_heating (100 , None ) == approx (13.7 , abs = 0.5 )
104+ def test_example_b_solar_heating (example_model_b : ThermalModel ):
105+ assert example_model_b .compute_solar_heating () == approx (13.7 , abs = 0.5 )
104106
105107
106- def test_example_b_resistance (example_model_b ):
107- assert example_model_b .compute_resistance (100 , None ) == approx (9.3905e-5 , abs = 0.0001e-5 )
108+ def test_example_b_resistance (example_model_b : ThermalModel ):
109+ assert example_model_b .compute_resistance (100 , np . nan ) == approx (9.3905e-5 , abs = 0.0001e-5 )
108110
109111
110- def test_example_b_ampacity (example_model_b ):
112+ def test_example_b_ampacity (example_model_b : ThermalModel ):
111113 # There are noticable roundoff errors in the report
112114 # There is a typo in the report, where it says that the ampacity is 1054, but it is 1504.
113115 assert example_model_b .compute_steady_state_ampacity (100 , tolerance = 1e-8 ) == approx (
0 commit comments