Skip to content

Commit

Permalink
Fix formatting, import Cigre207 in model.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Halvor Lund committed May 30, 2024
1 parent c2ef481 commit 18fb95c
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 122 deletions.
2 changes: 1 addition & 1 deletion linerate/equations/cigre207/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
This submodule contains implementations of equations listed in :cite:p:`cigre207`.
"""

from . import convective_cooling, solar_heating # noqa
from . import convective_cooling, solar_heating # noqa
4 changes: 1 addition & 3 deletions linerate/equations/cigre207/ac_resistance.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from typing import Union

from linerate.units import OhmPerMeter


Expand All @@ -24,4 +22,4 @@ def correct_resistance_for_skin_effect(
return 1.0123 * dc_resistance


# TODO: Implement section 2.1.2?
# TODO: Implement section 2.1.2?
29 changes: 12 additions & 17 deletions linerate/equations/cigre207/convective_cooling.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
Meter,
MeterPerSecond,
Radian,
SquareMeterPerSecond,
Unitless,
WattPerMeterPerKelvin, SquareMeterPerSecond,
WattPerMeterPerKelvin,
)


# Physical quantities
#####################

Expand All @@ -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`.
Expand All @@ -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:
Expand All @@ -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(
Expand All @@ -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.
Expand Down Expand Up @@ -142,7 +140,6 @@ def compute_reynolds_number(
return rho_r * v * D / nu_f



## Nusselt number calculation
#############################

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
)


Expand Down Expand Up @@ -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.
Expand Down
14 changes: 8 additions & 6 deletions linerate/equations/cigre207/solar_heating.py
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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
----------
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Loading

0 comments on commit 18fb95c

Please sign in to comment.