Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace print in precalc by logging #125

Merged
merged 5 commits into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading