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 2 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
21 changes: 13 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 Down Expand Up @@ -488,9 +489,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)
logging.info(
jnettels marked this conversation as resolved.
Show resolved Hide resolved
"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 +578,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!')
logging.info("Bi-section method: p_epsilon criterion reached.")
jnettels marked this conversation as resolved.
Show resolved Hide resolved
break

if abs(v_1 - v_0) < v_epsilon: # wieso v_1 und v_0?
print('v_epsilon criterion achieved!')
logging.info("Bi-section method: v_epsilon criterion reached.")
jnettels marked this conversation as resolved.
Show resolved Hide resolved
break

else:
Expand All @@ -590,9 +593,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)
logging.info(
jnettels marked this conversation as resolved.
Show resolved Hide resolved
"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