diff --git a/linerate/equations/cigre207/__init__.py b/linerate/equations/cigre207/__init__.py index af02088..d2c20ed 100644 --- a/linerate/equations/cigre207/__init__.py +++ b/linerate/equations/cigre207/__init__.py @@ -2,4 +2,4 @@ This submodule contains implementations of equations listed in :cite:p:`cigre207`. """ -from . import convective_cooling, solar_heating # noqa \ No newline at end of file +from . import convective_cooling, solar_heating # noqa diff --git a/linerate/equations/cigre207/ac_resistance.py b/linerate/equations/cigre207/ac_resistance.py index 748baef..550128f 100644 --- a/linerate/equations/cigre207/ac_resistance.py +++ b/linerate/equations/cigre207/ac_resistance.py @@ -1,5 +1,3 @@ -from typing import Union - from linerate.units import OhmPerMeter @@ -24,4 +22,4 @@ def correct_resistance_for_skin_effect( return 1.0123 * dc_resistance -# TODO: Implement section 2.1.2? \ No newline at end of file +# TODO: Implement section 2.1.2? diff --git a/linerate/equations/cigre207/convective_cooling.py b/linerate/equations/cigre207/convective_cooling.py index 8a0be0a..3a727d4 100644 --- a/linerate/equations/cigre207/convective_cooling.py +++ b/linerate/equations/cigre207/convective_cooling.py @@ -9,11 +9,11 @@ Meter, MeterPerSecond, Radian, + SquareMeterPerSecond, Unitless, - WattPerMeterPerKelvin, SquareMeterPerSecond, + WattPerMeterPerKelvin, ) - # Physical quantities ##################### @@ -40,10 +40,9 @@ def compute_thermal_conductivity_of_air(film_temperature: Celsius) -> WattPerMet return 2.42e-2 + 7.2e-5 * T_f -def compute_relative_air_density( - height_above_sea_level: Meter -) -> Unitless: - r"""Approximation of the relative density of air at a given altitude, relative to density at sea level. +def compute_relative_air_density(height_above_sea_level: Meter) -> Unitless: + r"""Approximation of the relative density of air at a given altitude, + relative to density at sea level. Equation on page 6 of :cite:p:`cigre207`. @@ -58,7 +57,7 @@ def compute_relative_air_density( :math:`\rho_r`. The relative mass density of air. """ y = height_above_sea_level - return np.exp(-1.16e-4*y) + return np.exp(-1.16e-4 * y) def compute_kinematic_viscosity_of_air(film_temperature: Celsius) -> KilogramPerCubeMeter: @@ -79,8 +78,7 @@ def compute_kinematic_viscosity_of_air(film_temperature: Celsius) -> KilogramPer :math:`\nu_f~\left[\text{m}^2~\text{s}^{-1}\right]`. The kinematic viscosity of air. """ T_f = film_temperature - return 1.32e-5 + 9.5e-8*T_f - + return 1.32e-5 + 9.5e-8 * T_f def compute_prandtl_number( @@ -104,14 +102,14 @@ def compute_prandtl_number( Union[float, float64, ndarray[Any, dtype[float64]]] :math:`\text{Pr}`. The Prandtl number. """ - return 0.715 - 2.5e-4*film_temperature + return 0.715 - 2.5e-4 * film_temperature def compute_reynolds_number( wind_speed: MeterPerSecond, conductor_diameter: Meter, kinematic_viscosity_of_air: SquareMeterPerSecond, - relative_air_density: Unitless + relative_air_density: Unitless, ) -> Unitless: r"""Compute the Reynolds number using the conductor diameter as characteristic length scale. @@ -142,7 +140,6 @@ def compute_reynolds_number( return rho_r * v * D / nu_f - ## Nusselt number calculation ############################# @@ -219,8 +216,7 @@ def compute_low_wind_speed_nusseltnumber( Union[float, float64, ndarray[Any, dtype[float64]]] :math:`\text{Nu}_{90}`. The corrected Nusselt number for low wind speed. """ - return 0.55*perpendicular_flow_nusselt_number - + return 0.55 * perpendicular_flow_nusselt_number @vectorize(nopython=True) @@ -265,8 +261,7 @@ def correct_wind_direction_effect_on_nusselt_number( :math:`\text{Nu}_\delta`. The Nusselt number for the given wind angle-of-attack. """ return _correct_wind_direction_effect_on_nusselt_number( - perpendicular_flow_nusselt_number, - angle_of_attack + perpendicular_flow_nusselt_number, angle_of_attack ) @@ -337,7 +332,7 @@ def compute_nusselt_number( forced_convection_nusselt_number: Unitless, natural_nusselt_number: Unitless, low_wind_nusselt_number: Unitless, - wind_speed: MeterPerSecond + wind_speed: MeterPerSecond, ) -> Unitless: r"""Compute the nusselt number. diff --git a/linerate/equations/cigre207/solar_heating.py b/linerate/equations/cigre207/solar_heating.py index df756fa..ef6b4d0 100644 --- a/linerate/equations/cigre207/solar_heating.py +++ b/linerate/equations/cigre207/solar_heating.py @@ -1,8 +1,8 @@ import numpy as np from numpy import pi -from .. import cigre601 from ...units import Meter, Unitless, WattPerSquareMeter +from .. import cigre601 def compute_direct_solar_radiation( @@ -19,8 +19,8 @@ def compute_direct_solar_radiation( N_s \frac{1280 \sin(H_s)}{\sin(H_s) + 0.314}, where :math:`H_s` is the solar altitude. - To correct for height above sea level, we use the Eq. 19 from Cigre 601, since no equation is provided - in Cigre 207. + To correct for height above sea level, we use the Eq. 19 from Cigre 601, + since no equation is provided in Cigre 207. Parameters ---------- @@ -35,7 +35,9 @@ def compute_direct_solar_radiation( :math:`I_B~\left[\text{W}~\text{m}^{-2}\right]`. The direct solar radiation. """ clearness_ratio = 1.0 - return cigre601.solar_heating.compute_direct_solar_radiation(sin_solar_altitude, clearness_ratio, height_above_sea_level) + return cigre601.solar_heating.compute_direct_solar_radiation( + sin_solar_altitude, clearness_ratio, height_above_sea_level + ) def compute_diffuse_sky_radiation( @@ -64,7 +66,7 @@ def compute_diffuse_sky_radiation( """ sin_H_s = sin_solar_altitude I_B = direct_solar_radiation - return np.maximum(0, (570 - 0.47 * I_B)) * np.maximum(0, sin_H_s)**1.2 + return np.maximum(0, (570 - 0.47 * I_B)) * np.maximum(0, sin_H_s) ** 1.2 def compute_global_radiation_intensity( @@ -142,4 +144,4 @@ def compute_global_radiation_intensity( sin_eta = sin_angle_of_sun_on_line F_pi_half = 0.5 * pi * F - return I_B * (sin_eta + F_pi_half * sin_H_s) + I_d * pi/2 * (1 + F) # type: ignore + return I_B * (sin_eta + F_pi_half * sin_H_s) + I_d * pi / 2 * (1 + F) # type: ignore diff --git a/linerate/equations/cigre601/convective_cooling.py b/linerate/equations/cigre601/convective_cooling.py index c02ff29..2069062 100644 --- a/linerate/equations/cigre601/convective_cooling.py +++ b/linerate/equations/cigre601/convective_cooling.py @@ -15,16 +15,15 @@ WattPerMeterPerKelvin, ) - # Physical quantities ##################### def compute_temperature_gradient( - total_heat_gain: WattPerMeter, - conductor_thermal_conductivity: WattPerMeterPerKelvin, - core_diameter: Meter, - conductor_diameter: Meter, + total_heat_gain: WattPerMeter, + conductor_thermal_conductivity: WattPerMeterPerKelvin, + core_diameter: Meter, + conductor_diameter: Meter, ) -> Celsius: r"""Compute the difference between the core and surface temperature. @@ -64,8 +63,8 @@ def compute_temperature_gradient( if D_1 == 0: # TODO: Maybe lower tolerance? return 0.5 * tmp else: - D_1_sq = D_1 ** 2 - delta_D_sq = D ** 2 - D_1_sq + D_1_sq = D_1**2 + delta_D_sq = D**2 - D_1_sq return tmp * (0.5 - (D_1_sq / delta_D_sq) * np.log(D / D_1)) @@ -90,11 +89,11 @@ def compute_thermal_conductivity_of_air(film_temperature: Celsius) -> WattPerMet conductivity of air at the given temperature. """ T_f = film_temperature - return 2.368e-2 + 7.23e-5 * T_f - 2.763e-8 * (T_f ** 2) + return 2.368e-2 + 7.23e-5 * T_f - 2.763e-8 * (T_f**2) def compute_air_density( - film_temperature: Celsius, height_above_sea_level: Meter + film_temperature: Celsius, height_above_sea_level: Meter ) -> KilogramPerCubeMeter: r"""Approximation of the density of air at a given temperature and altitude. @@ -116,7 +115,7 @@ def compute_air_density( """ T_f = film_temperature y = height_above_sea_level - return (1.293 - 1.525e-4 * y + 6.379e-9 * (y ** 2)) / (1 + 0.00367 * T_f) + return (1.293 - 1.525e-4 * y + 6.379e-9 * (y**2)) / (1 + 0.00367 * T_f) def compute_dynamic_viscosity_of_air(film_temperature: Celsius) -> KilogramPerMeterPerSecond: @@ -138,11 +137,11 @@ def compute_dynamic_viscosity_of_air(film_temperature: Celsius) -> KilogramPerMe of air. """ T_f = film_temperature - return 17.239e-6 + 4.635e-8 * T_f - 2.03e-11 * (T_f ** 2) + return 17.239e-6 + 4.635e-8 * T_f - 2.03e-11 * (T_f**2) def compute_kinematic_viscosity_of_air( - dynamic_viscosity_of_air: KilogramPerMeterPerSecond, air_density: KilogramPerCubeMeter + dynamic_viscosity_of_air: KilogramPerMeterPerSecond, air_density: KilogramPerCubeMeter ) -> SquareMeterPerSecond: r"""Compute the kinematic viscosity of air. @@ -185,8 +184,8 @@ def _check_perpendicular_flow_nusseltnumber_out_of_bounds(reynolds_number, condu @vectorize(nopython=True) def _compute_perpendicular_flow_nusseltnumber( - reynolds_number: Unitless, - conductor_roughness: Meter, + reynolds_number: Unitless, + conductor_roughness: Meter, ) -> Unitless: # TODO: Look at references for this table Re = reynolds_number @@ -216,12 +215,12 @@ def _compute_perpendicular_flow_nusseltnumber( else: B, n = 0.048, 0.800 - return B * Re ** n # type: ignore + return B * Re**n # type: ignore def compute_perpendicular_flow_nusseltnumber( - reynolds_number: Unitless, - conductor_roughness: Meter, + reynolds_number: Unitless, + conductor_roughness: Meter, ) -> Unitless: r"""Compute the Nusselt number for perpendicular flow. @@ -253,9 +252,9 @@ def compute_perpendicular_flow_nusseltnumber( @vectorize(nopython=True) def _correct_wind_direction_effect_on_nusselt_number( - perpendicular_flow_nusselt_number: Unitless, - angle_of_attack: Radian, - conductor_roughness: Unitless, + perpendicular_flow_nusselt_number: Unitless, + angle_of_attack: Radian, + conductor_roughness: Unitless, ) -> Unitless: delta = angle_of_attack Nu_90 = perpendicular_flow_nusselt_number @@ -264,23 +263,23 @@ def _correct_wind_direction_effect_on_nusselt_number( sin_delta = np.sin(delta) if Rs == 0 or np.isnan(Rs): - sin_delta_sq = sin_delta ** 2 + sin_delta_sq = sin_delta**2 cos_delta_sq = 1 - sin_delta_sq correction_factor = (sin_delta_sq + cos_delta_sq * 0.0169) ** 0.225 else: if delta <= np.radians(24): - correction_factor = 0.42 + 0.68 * (sin_delta ** 1.08) + correction_factor = 0.42 + 0.68 * (sin_delta**1.08) else: - correction_factor = 0.42 + 0.58 * (sin_delta ** 0.90) + correction_factor = 0.42 + 0.58 * (sin_delta**0.90) return correction_factor * Nu_90 def correct_wind_direction_effect_on_nusselt_number( - perpendicular_flow_nusselt_number: Unitless, - angle_of_attack: Radian, - conductor_roughness: Unitless, + perpendicular_flow_nusselt_number: Unitless, + angle_of_attack: Radian, + conductor_roughness: Unitless, ) -> Unitless: r"""Correct the Nusselt number for the wind's angle-of-attack. @@ -315,7 +314,7 @@ def correct_wind_direction_effect_on_nusselt_number( def _check_horizontal_natural_nusselt_number( - grashof_number: Unitless, prandtl_number: Unitless + grashof_number: Unitless, prandtl_number: Unitless ) -> None: GrPr = grashof_number * prandtl_number if np.any(GrPr < 0): @@ -326,26 +325,26 @@ def _check_horizontal_natural_nusselt_number( @vectorize(nopython=True) def _compute_horizontal_natural_nusselt_number( - grashof_number: Unitless, - prandtl_number: Unitless, + grashof_number: Unitless, + prandtl_number: Unitless, ) -> Unitless: GrPr = grashof_number * prandtl_number if GrPr < 1e-1: return 0 elif GrPr < 1e2: - return 1.020 * GrPr ** 0.148 + return 1.020 * GrPr**0.148 elif GrPr < 1e4: - return 0.850 * GrPr ** 0.188 + return 0.850 * GrPr**0.188 elif GrPr < 1e7: - return 0.480 * GrPr ** 0.250 + return 0.480 * GrPr**0.250 else: - return 0.125 * GrPr ** 0.333 + return 0.125 * GrPr**0.333 def compute_horizontal_natural_nusselt_number( - grashof_number: Unitless, - prandtl_number: Unitless, + grashof_number: Unitless, + prandtl_number: Unitless, ) -> Unitless: r"""The Nusselt number for natural (passive) convection on a horizontal conductor. @@ -378,8 +377,8 @@ def compute_horizontal_natural_nusselt_number( def _check_conductor_inclination( - conductor_inclination: Radian, - conductor_roughness: Unitless, + conductor_inclination: Radian, + conductor_roughness: Unitless, ) -> None: beta = np.degrees(conductor_inclination) Rs = conductor_roughness @@ -396,24 +395,24 @@ def _check_conductor_inclination( @vectorize(nopython=True) def _correct_natural_nusselt_number_inclination( - horizontal_natural_nusselt_number: Unitless, - conductor_inclination: Radian, - conductor_roughness: Unitless, + horizontal_natural_nusselt_number: Unitless, + conductor_inclination: Radian, + conductor_roughness: Unitless, ) -> Unitless: beta = np.degrees(conductor_inclination) Nu_nat = horizontal_natural_nusselt_number Rs = conductor_roughness if Rs == 0 or np.isnan(Rs): - return Nu_nat * (1 - 1.58e-4 * beta ** 1.5) + return Nu_nat * (1 - 1.58e-4 * beta**1.5) else: - return Nu_nat * (1 - 1.76e-6 * beta ** 2.5) + return Nu_nat * (1 - 1.76e-6 * beta**2.5) def correct_natural_nusselt_number_inclination( - horizontal_natural_nusselt_number: Unitless, - conductor_inclination: Radian, - conductor_roughness: Unitless, + horizontal_natural_nusselt_number: Unitless, + conductor_inclination: Radian, + conductor_roughness: Unitless, ) -> Unitless: r"""Correct the natural Nusselt number for the effect of the span inclination. @@ -447,8 +446,8 @@ def correct_natural_nusselt_number_inclination( def compute_nusselt_number( - forced_convection_nusselt_number: Unitless, - natural_nusselt_number: Unitless, + forced_convection_nusselt_number: Unitless, + natural_nusselt_number: Unitless, ) -> Unitless: r"""Compute the nusselt number. diff --git a/linerate/equations/cigre601/solar_heating.py b/linerate/equations/cigre601/solar_heating.py index 575920f..aef33c8 100644 --- a/linerate/equations/cigre601/solar_heating.py +++ b/linerate/equations/cigre601/solar_heating.py @@ -1,7 +1,7 @@ import numpy as np from numpy import pi -from ...units import Meter, Unitless, WattPerMeter, WattPerSquareMeter +from ...units import Meter, Unitless, WattPerSquareMeter def compute_direct_solar_radiation( diff --git a/linerate/equations/convective_cooling.py b/linerate/equations/convective_cooling.py index cec9a54..2c7b427 100644 --- a/linerate/equations/convective_cooling.py +++ b/linerate/equations/convective_cooling.py @@ -1,17 +1,18 @@ import numpy as np -from linerate.units import Celsius, Unitless, WattPerMeterPerKelvin, WattPerMeter +from linerate.units import Celsius, Unitless, WattPerMeter, WattPerMeterPerKelvin def compute_convective_cooling( - surface_temperature: Celsius, - air_temperature: Celsius, - nusselt_number: Unitless, - thermal_conductivity_of_air: WattPerMeterPerKelvin, + surface_temperature: Celsius, + air_temperature: Celsius, + nusselt_number: Unitless, + thermal_conductivity_of_air: WattPerMeterPerKelvin, ) -> WattPerMeter: r"""Compute the convective cooling of the conductor. - Equation (17) on page 24 of :cite:p:`cigre601` and Equation (12) on page 6 of :cite:p:`cigre207`. + Equation (17) on page 24 of :cite:p:`cigre601` + and Equation (12) on page 6 of :cite:p:`cigre207`. Parameters ---------- @@ -37,4 +38,4 @@ def compute_convective_cooling( T_a = air_temperature Nu = nusselt_number - return pi * lambda_f * (T_s - T_a) * Nu \ No newline at end of file + return pi * lambda_f * (T_s - T_a) * Nu diff --git a/linerate/equations/dimensionless.py b/linerate/equations/dimensionless.py index 10430ad..a1e7c3e 100644 --- a/linerate/equations/dimensionless.py +++ b/linerate/equations/dimensionless.py @@ -2,8 +2,17 @@ import numpy as np -from linerate.units import Unitless, WattPerMeterPerKelvin, KilogramPerMeterPerSecond, JoulePerKilogramPerKelvin, \ - MeterPerSecond, Meter, SquareMeterPerSecond, Celsius, MeterPerSquareSecond +from linerate.units import ( + Celsius, + JoulePerKilogramPerKelvin, + KilogramPerMeterPerSecond, + Meter, + MeterPerSecond, + MeterPerSquareSecond, + SquareMeterPerSecond, + Unitless, + WattPerMeterPerKelvin, +) def compute_reynolds_number( @@ -13,7 +22,8 @@ def compute_reynolds_number( ) -> Unitless: r"""Compute the Reynolds number using the conductor diameter as characteristic length scale. - Defined in the text on page 25 of :cite:p:`cigre601` and equation (2c) on page 10 in :cite:p:`ieee738`. + Defined in the text on page 25 of :cite:p:`cigre601` and equation (2c) + on page 10 in :cite:p:`ieee738`. The Reynolds number is a dimensionless quantity that can be used to assess if a stream is likely to be turbulent or not. It is given by @@ -125,8 +135,8 @@ def compute_prandtl_number( def compute_conductor_roughness( - conductor_diameter: Meter, - outer_layer_strand_diameter: Meter, + conductor_diameter: Meter, + outer_layer_strand_diameter: Meter, ) -> Unitless: r"""Compute the surface roughness of the conductor. diff --git a/linerate/equations/solar_heating.py b/linerate/equations/solar_heating.py index 0cfe465..a177116 100644 --- a/linerate/equations/solar_heating.py +++ b/linerate/equations/solar_heating.py @@ -1,4 +1,4 @@ -from linerate.units import WattPerSquareMeter, Unitless, Meter, WattPerMeter +from linerate.units import Meter, Unitless, WattPerMeter, WattPerSquareMeter def compute_solar_heating( diff --git a/linerate/model.py b/linerate/model.py index 2a4ad26..cad6982 100644 --- a/linerate/model.py +++ b/linerate/model.py @@ -11,15 +11,19 @@ from typing import Dict import numpy as np +from models.cigre207 import Cigre207 from linerate import solver from linerate.equations import ( cigre601, + convective_cooling, + dimensionless, ieee738, joule_heating, math, radiative_cooling, - solar_angles, convective_cooling, dimensionless, solar_heating, + solar_angles, + solar_heating, ) from linerate.equations.math import switch_cos_sin from linerate.types import Span, Weather @@ -32,7 +36,7 @@ WattPerMeter, ) -__all__ = ["ThermalModel", "Cigre601", "IEEE738"] +__all__ = ["ThermalModel", "Cigre601", "IEEE738", "Cigre207"] def _copy_method_docstring(parent_class): diff --git a/linerate/models/Cigre207.md b/linerate/models/Cigre207.md index 62c190a..ad23e73 100644 --- a/linerate/models/Cigre207.md +++ b/linerate/models/Cigre207.md @@ -33,4 +33,4 @@ viscosity $\nu_f$ has to be corrected for the air relative density. Cigre 207 has a non-smooth transition to low wind speeds (<0.5m/s) at angles of attack less than 45 degrees. This leads to an increase in cooling as the wind speed drops below 0.5m/s, which seems non-physical. -This discontinuity is removed in Cigre 601. \ No newline at end of file +This discontinuity is removed in Cigre 601. diff --git a/linerate/models/cigre207.py b/linerate/models/cigre207.py index 5343364..96277f2 100644 --- a/linerate/models/cigre207.py +++ b/linerate/models/cigre207.py @@ -1,11 +1,19 @@ from abc import abstractmethod -from linerate import ThermalModel, Span, Weather -from linerate.equations import solar_angles, cigre601, math, cigre207, dimensionless, convective_cooling, joule_heating, \ - solar_heating +from linerate import Span, ThermalModel, Weather +from linerate.equations import ( + cigre207, + cigre601, + convective_cooling, + dimensionless, + joule_heating, + math, + solar_angles, + solar_heating, +) from linerate.equations.math import switch_cos_sin from linerate.model import _copy_method_docstring -from linerate.units import Date, Celsius, Ampere, WattPerMeter, OhmPerMeter +from linerate.units import Ampere, Celsius, Date, OhmPerMeter, WattPerMeter class Cigre207(ThermalModel): @@ -80,9 +88,6 @@ def compute_convective_cooling( ) # Compute unitless quantities - # Reynolds number is defined in the text on page 5 of :cite:p:`cigre207`. - # The definition includes a relative air density, which does not make sense, so we omit it here and use the - # standard definition of Reynolds number instead. rho_r = cigre207.convective_cooling.compute_relative_air_density(y) Re = cigre207.convective_cooling.compute_reynolds_number(V, D, nu_f, rho_r) Gr = dimensionless.compute_grashof_number(D, T_c, T_a, nu_f) @@ -101,8 +106,10 @@ def compute_convective_cooling( Nu_0 = cigre207.convective_cooling.compute_horizontal_natural_nusselt_number(Gr, Pr) Nu = cigre207.convective_cooling.compute_nusselt_number( - forced_convection_nusselt_number=Nu_delta, natural_nusselt_number=Nu_0, - low_wind_nusselt_number=Nu_cor, wind_speed=V + forced_convection_nusselt_number=Nu_delta, + natural_nusselt_number=Nu_0, + low_wind_nusselt_number=Nu_cor, + wind_speed=V, ) return convective_cooling.compute_convective_cooling( diff --git a/tests/equations/cigre207/test_convective_cooling.py b/tests/equations/cigre207/test_convective_cooling.py index e6b0a7f..44695fb 100644 --- a/tests/equations/cigre207/test_convective_cooling.py +++ b/tests/equations/cigre207/test_convective_cooling.py @@ -1,6 +1,7 @@ import numpy as np from pytest import approx -from linerate.equations import cigre207, dimensionless, convective_cooling + +from linerate.equations import cigre207, dimensionless def test_matches_example1(): @@ -10,7 +11,7 @@ def test_matches_example1(): assert rho_r == approx(0.8306, rel=1e-4) T_s = 57 T_amb = 40 - T_f = (T_s + T_amb)/2 + T_f = (T_s + T_amb) / 2 nu_f = cigre207.convective_cooling.compute_kinematic_viscosity_of_air(T_f) assert nu_f == approx(1.78e-5, rel=1e-3) v = 2 @@ -29,7 +30,9 @@ def test_matches_example1_nusselt_number(): Re = 2670 Nu_90 = cigre207.convective_cooling.compute_perpendicular_flow_nusseltnumber(Re, Rs) assert Nu_90 == approx(26.45, 1e-4) - Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number(Nu_90, np.radians(45)) + Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number( + Nu_90, np.radians(45) + ) assert Nu_45 == approx(22.34, rel=1e-4) @@ -41,7 +44,7 @@ def test_matches_example2(): T_amb = 40 v = 0.2 D = 0.0286 - T_f = (T_s + T_amb)/2 + T_f = (T_s + T_amb) / 2 nu_f = cigre207.convective_cooling.compute_kinematic_viscosity_of_air(T_f) nu_f_exp = 1.95e-5 assert nu_f == approx(nu_f_exp, rel=1e-3) @@ -53,7 +56,9 @@ def test_matches_example2(): Rs = dimensionless.compute_conductor_roughness(D, d) Nu_90 = cigre207.convective_cooling.compute_perpendicular_flow_nusseltnumber(Re, Rs) assert Nu_90 == approx(8.53, 1e-3) - Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number(Nu_90, np.radians(45)) + Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number( + Nu_90, np.radians(45) + ) assert Nu_45 == approx(7.20, rel=2e-3) Nu_cor = cigre207.convective_cooling.compute_low_wind_speed_nusseltnumber(Nu_90) assert Nu_cor == approx(4.69, rel=1e-3) @@ -76,7 +81,7 @@ def test_matches_example3(): v = 2 D = 0.0286 d = 0.00318 - T_f = (T_s + T_amb)/2 + T_f = (T_s + T_amb) / 2 nu_f = cigre207.convective_cooling.compute_kinematic_viscosity_of_air(T_f) nu_f_exp = 1.866e-5 assert nu_f == approx(nu_f_exp, rel=1e-3) @@ -87,7 +92,9 @@ def test_matches_example3(): Rs = dimensionless.compute_conductor_roughness(D, d) Nu_90 = cigre207.convective_cooling.compute_perpendicular_flow_nusseltnumber(Re, Rs) assert Nu_90 == approx(25.77, 1e-3) - Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number(Nu_90, np.radians(45)) + Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number( + Nu_90, np.radians(45) + ) assert Nu_45 == approx(21.8, rel=2e-3) @@ -99,7 +106,7 @@ def test_matches_example4(): T_amb = 40 v = 0.4 D = 0.0286 - T_f = (T_s + T_amb)/2 + T_f = (T_s + T_amb) / 2 nu_f = cigre207.convective_cooling.compute_kinematic_viscosity_of_air(T_f) nu_f_exp = 1.866e-5 assert nu_f == approx(nu_f_exp, rel=1e-3) @@ -111,7 +118,9 @@ def test_matches_example4(): Rs = dimensionless.compute_conductor_roughness(D, d) Nu_90 = cigre207.convective_cooling.compute_perpendicular_flow_nusseltnumber(Re, Rs) assert Nu_90 == approx(12.08, 1e-3) - Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number(Nu_90, np.radians(45)) + Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number( + Nu_90, np.radians(45) + ) assert Nu_45 == approx(10.2, rel=2e-3) Nu_cor = cigre207.convective_cooling.compute_low_wind_speed_nusseltnumber(Nu_90) assert Nu_cor == approx(6.64, rel=1e-3) @@ -134,7 +143,7 @@ def test_matches_example5(): T_amb = 40 v = 2 D = 0.0286 - T_f = (T_s + T_amb)/2 + T_f = (T_s + T_amb) / 2 nu_f = cigre207.convective_cooling.compute_kinematic_viscosity_of_air(T_f) nu_f_exp = 1.78e-5 assert nu_f == approx(nu_f_exp, rel=1e-3) @@ -146,5 +155,7 @@ def test_matches_example5(): Rs = dimensionless.compute_conductor_roughness(D, d) Nu_90 = cigre207.convective_cooling.compute_perpendicular_flow_nusseltnumber(Re, Rs) assert Nu_90 == approx(29.85, 1e-3) - Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number(Nu_90, np.radians(45)) + Nu_45 = cigre207.convective_cooling.correct_wind_direction_effect_on_nusselt_number( + Nu_90, np.radians(45) + ) assert Nu_45 == approx(25.21, rel=2e-3) diff --git a/tests/equations/cigre601/test_convective_cooling.py b/tests/equations/cigre601/test_convective_cooling.py index 6e690c4..841f0f8 100644 --- a/tests/equations/cigre601/test_convective_cooling.py +++ b/tests/equations/cigre601/test_convective_cooling.py @@ -7,7 +7,6 @@ import linerate.equations.cigre601.convective_cooling as convective_cooling - # Tests for physical quantities ############################### @@ -260,8 +259,6 @@ def test_kinematic_viscosity_of_air_with_example(): assert convective_cooling.compute_kinematic_viscosity_of_air(mu_f, gamma) == approx(1) - - ## Nusselt number calculation ############################# diff --git a/tests/equations/test_convective_cooling.py b/tests/equations/test_convective_cooling.py index f16f208..b0fc0dc 100644 --- a/tests/equations/test_convective_cooling.py +++ b/tests/equations/test_convective_cooling.py @@ -1,8 +1,8 @@ import hypothesis import hypothesis.strategies as st import numpy as np - from pytest import approx + from linerate.equations import convective_cooling @@ -130,4 +130,4 @@ def test_cooling_matches_cigre207_example4(): T_amb = 40 Nu_45 = 10.2 cooling = convective_cooling.compute_convective_cooling(T_s, T_amb, Nu_45, 0.0283) - assert cooling == approx(31.78, rel=2e-3) \ No newline at end of file + assert cooling == approx(31.78, rel=2e-3) diff --git a/tests/equations/test_radiative_cooling.py b/tests/equations/test_radiative_cooling.py index 6170138..27586bf 100644 --- a/tests/equations/test_radiative_cooling.py +++ b/tests/equations/test_radiative_cooling.py @@ -87,11 +87,7 @@ def test_radiative_cooling_with_example( @pytest.mark.parametrize( "surface_temperature, expected_cooling", - [ - (57, 5.76), - (93, 21.27), - (75, 12.92) - ], + [(57, 5.76), (93, 21.27), (75, 12.92)], ) def test_cooling_matches_cigre207_examples(surface_temperature, expected_cooling): # See Appendix 1, Example 1 in Cigre 207 @@ -99,4 +95,4 @@ def test_cooling_matches_cigre207_examples(surface_temperature, expected_cooling D = 0.0286 epsilon = 0.5 cooling = radiative_cooling.compute_radiative_cooling(surface_temperature, T_a, D, epsilon) - assert cooling == approx(expected_cooling, rel=2e-3) \ No newline at end of file + assert cooling == approx(expected_cooling, rel=2e-3)