Skip to content

Commit

Permalink
Merge pull request #125 from oemof/Fix/Replace_print_in_precalc
Browse files Browse the repository at this point in the history
Replace print in precalc by logging
  • Loading branch information
jnettels authored Oct 23, 2023
2 parents c6aeaef + ac19941 commit a66d25c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions dhnx/optimization/precalc_hydraulic.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
SPDX-License-Identifier: MIT
"""

import logging
import math

import numpy as np
Expand All @@ -31,6 +32,8 @@
print("Need to install CoolProp to use the hydraulic "
"pre-calculation module.")

logger = logging.getLogger(__name__) # Create a logger for this module


def eq_smooth(x, R_e):
r"""
Expand Down Expand Up @@ -488,9 +491,11 @@ def v_max_secant(d_i, T_average, k=0.1, p_max=100, p_epsilon=1,
v_0 = v_1
v_1 = v_new

print('Number of Iterations: ', n)
print('Resulting pressure drop ', p_new)
print('Resulting velocity: ', v_new)
logger.info(
"Maximum flow velocity calculated. Iterations: %d, "
"Flow velocity: %.4f [m/s], Pressure drop: %.4f [Pa/m]"
% (n, v_new, p_new)
)

return v_new

Expand Down Expand Up @@ -575,11 +580,11 @@ def v_max_bisection(d_i, T_average, k=0.1, p_max=100,
pressure=pressure, fluid=fluid)

if abs(p_new - p_max) < p_epsilon:
print('p_epsilon criterion achieved!')
logger.info("Bi-section method: p_epsilon criterion reached.")
break

if abs(v_1 - v_0) < v_epsilon: # wieso v_1 und v_0?
print('v_epsilon criterion achieved!')
logger.info("Bi-section method: v_epsilon criterion reached.")
break

else:
Expand All @@ -590,9 +595,11 @@ def v_max_bisection(d_i, T_average, k=0.1, p_max=100,
else:
v_0 = v_new

print('Number of Iterations: ', n)
print('Resulting pressure drop: ', p_new)
print('Resulting velocity: ', v_new)
logger.info(
"Maximum flow velocity calculated. Iterations: %d, "
"Flow velocity: %.4f [m/s], Pressure drop: %.4f [Pa/m]"
% (n, v_new, p_new)
)

return v_new

Expand Down

0 comments on commit a66d25c

Please sign in to comment.