Skip to content

Commit

Permalink
Style: Update Black to 22.1.0 and fix formatting
Browse files Browse the repository at this point in the history
This marks the first non-beta version of Black. The most notable change
for us is the hugging of power operators in "simple" expressions. For
more information, see psf/black#2726 .
  • Loading branch information
Tjerk Vreeken committed Feb 7, 2022
1 parent 0ade5e5 commit d04faaf
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/rtctools_heat_network/_darcy_weisbach.py
Expand Up @@ -99,13 +99,13 @@ def head_loss(velocity, diameter, length, wall_roughness, temperature):

f = friction_factor(velocity, diameter, wall_roughness, temperature)

return length * f / (2 * GRAVITATIONAL_CONSTANT) * velocity ** 2 / diameter
return length * f / (2 * GRAVITATIONAL_CONSTANT) * velocity**2 / diameter


def get_linear_pipe_dh_vs_q_fit(
diameter, length, wall_roughness, temperature, n_lines=10, v_max=2.0
):
area = math.pi * diameter ** 2 / 4
area = math.pi * diameter**2 / 4

v_points = np.linspace(0.0, v_max, n_lines + 1)
q_points = v_points * area
Expand Down
4 changes: 2 additions & 2 deletions src/rtctools_heat_network/_heat_loss_u_values_pipe.py
Expand Up @@ -81,7 +81,7 @@ def heat_loss_u_values_pipe(
* math.log(1 + (2 * depth_corrected / pipe_distance) ** 2)
)

u_1 = (r_subsoil + r_ins) / ((r_subsoil + r_ins) ** 2 - r_m ** 2)
u_2 = r_m / ((r_subsoil + r_ins) ** 2 - r_m ** 2)
u_1 = (r_subsoil + r_ins) / ((r_subsoil + r_ins) ** 2 - r_m**2)
u_2 = r_m / ((r_subsoil + r_ins) ** 2 - r_m**2)

return u_1, u_2
6 changes: 3 additions & 3 deletions src/rtctools_heat_network/head_loss_mixin.py
Expand Up @@ -37,7 +37,7 @@ class HeadLossOption(IntEnum):
class _MinimizeHeadLosses(Goal):
order = 1

priority = 2 ** 31 - 1
priority = 2**31 - 1

def __init__(self, optimization_problem: "_HeadLossMixin", *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -396,7 +396,7 @@ def _hn_pipe_head_loss(
c_v = length * ff / (2 * GRAVITATIONAL_CONSTANT) / diameter

linearization_velocity = estimated_velocity
linearization_head_loss = c_v * linearization_velocity ** 2
linearization_head_loss = c_v * linearization_velocity**2
linearization_discharge = linearization_velocity * area

expr = linearization_head_loss * discharge / linearization_discharge
Expand Down Expand Up @@ -445,7 +445,7 @@ def _hn_pipe_head_loss(
c_v = length * ff / (2 * GRAVITATIONAL_CONSTANT) / diameter

v = discharge / area
expr = c_v * v ** 2
expr = c_v * v**2

if symbolic:
q_nominal = self.variable_nominal(f"{pipe}.Q")
Expand Down
2 changes: 1 addition & 1 deletion src/rtctools_heat_network/pipe_class.py
Expand Up @@ -16,4 +16,4 @@ def maximum_discharge(self):

@property
def area(self):
return 0.25 * math.pi * self.inner_diameter ** 2
return 0.25 * math.pi * self.inner_diameter**2
Expand Up @@ -24,7 +24,7 @@ def __init__(self, name, **modifiers):
self.heat_transfer_coeff = 1.0
self.height = 5.0
self.radius = 10.0
self.volume = math.pi * self.radius ** 2 * self.height
self.volume = math.pi * self.radius**2 * self.height
self.heat_loss_coeff = 2 * self.heat_transfer_coeff / (self.radius * self.rho * self.cp)
# The hot/cold tank can have a lower bound on its volume.
# Meaning that they might always be, for e.g., 5% full.
Expand Down
Expand Up @@ -16,7 +16,7 @@ def __init__(self, name, **modifiers):
self.length = 1.0
self.diameter = 1.0
assert "area" not in modifiers, "modifying area directly is not allowed"
self.area = 0.25 * pi * self.diameter ** 2
self.area = 0.25 * pi * self.diameter**2
self.temperature = nan

# Parameters determining the heat loss
Expand Down
Expand Up @@ -21,13 +21,13 @@ def __init__(self, name, **modifiers):
self.heat_transfer_coeff = 1.0
self.height = 5.0
self.radius = 10.0
self.volume = math.pi * self.radius ** 2 * self.height
self.volume = math.pi * self.radius**2 * self.height
# The hot/cold tank can have a lower bound on its volume.
# Meaning that they might always be, for e.g., 5% full.
self.min_fraction_tank_volume = 0.05

# if the tank is plced on ground, ignore surface of bottom of tank
self.surface = 2 * math.pi * self.radius ** 2 + 2 * math.pi * self.radius * self.height
self.surface = 2 * math.pi * self.radius**2 + 2 * math.pi * self.radius * self.height
self.T_outside = 10.0

# Nominals
Expand Down
Expand Up @@ -30,7 +30,7 @@ def __init__(self, name, **modifiers):
self.length = 1.0
self.diameter = 1.0
assert "area" not in modifiers, "modifying area directly is not allowed"
self.area = 0.25 * pi * self.diameter ** 2
self.area = 0.25 * pi * self.diameter**2
self.temperature = nan

# Parameters determining the heat loss
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Expand Up @@ -26,6 +26,6 @@ commands = flake8 examples src tests setup.py
[testenv:black]
skip_install = True
deps =
black
black >= 22.1.0
commands =
black --line-length 100 --target-version py37 --check --diff examples src tests setup.py

0 comments on commit d04faaf

Please sign in to comment.