From 6fd166369344ee6225afb1a29722c184d05ff033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20V=C3=B6lzel?= Date: Thu, 13 Nov 2025 16:36:18 +0100 Subject: [PATCH 1/4] Started implementation of churchill friction factor --- src/pandapipes/pf/derivative_calculation.py | 10 ++++++++++ src/pandapipes/pf/scratch.py | 6 ++++++ 2 files changed, 16 insertions(+) create mode 100644 src/pandapipes/pf/scratch.py diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index b2034b275..796f62df0 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -199,6 +199,13 @@ def calc_lambda(m, eta, d, k, gas_mode, friction_model, lengths, options, area): # 1.325 instead of 0.25??? lambda_swamee_jain = 0.25 / ((np.log10(k / (3.7 * d) + 5.74 / (re ** 0.9))) ** 2) return lambda_swamee_jain, re + + elif friction_model == "churchill": + paramA = (-2.457*np.log((7/re)**0.9 + 0.27*k/d))**16 + paramB = (37530/re)**16 + lambda_churchill = 8*((8/re)**12 + 1/(paramA+paramB)**1.5)**(1/12) + return lambda_churchill + else: # lambda_tot = np.where(re > 2300, lambda_laminar + lambda_nikuradse, lambda_laminar) lambda_tot = lambda_laminar + lambda_nikuradse @@ -256,6 +263,9 @@ def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area, re, lengths lambda_der[pos] = 0.5 * np.log(10) ** 2 / (np.log(param) ** 3) / param * 5.166 * ( (eta[pos] * area[pos]) / (d[pos])) ** 0.9 * np.abs(m[pos]) ** -1.9 return lambda_der + + # elif friction_model == "churchill": + else: lambda_der[pos] = -(64 * eta[pos] * area[pos]) / (m[pos] ** 2 * d[pos]) return lambda_der diff --git a/src/pandapipes/pf/scratch.py b/src/pandapipes/pf/scratch.py new file mode 100644 index 000000000..9935d329d --- /dev/null +++ b/src/pandapipes/pf/scratch.py @@ -0,0 +1,6 @@ +# %% + + +import numpy as np + + From bc27ce2431627b277a6a6a3d1c684ec9fb780547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20V=C3=B6lzel?= Date: Fri, 14 Nov 2025 10:48:07 +0100 Subject: [PATCH 2/4] Implemented friction factor calculation by Churchill (1977) --- .../converter/stanet/preparing_steps.py | 2 +- src/pandapipes/pf/derivative_calculation.py | 21 ++++++++++++++++++- src/pandapipes/pf/scratch.py | 6 ------ 3 files changed, 21 insertions(+), 8 deletions(-) delete mode 100644 src/pandapipes/pf/scratch.py diff --git a/src/pandapipes/converter/stanet/preparing_steps.py b/src/pandapipes/converter/stanet/preparing_steps.py index 77a00f29f..d22868db8 100644 --- a/src/pandapipes/converter/stanet/preparing_steps.py +++ b/src/pandapipes/converter/stanet/preparing_steps.py @@ -171,7 +171,7 @@ def get_net_params(net, stored_data): :return: net parameters :rtype: """ - known_friction_models = {1: "swamee-jain", 3: "nikuradse", 5: "colebrook"} + known_friction_models = {1: "swamee-jain", 3: "nikuradse", 5: "colebrook", 7:"churchill"} compressibility_models = {0: "linear", 1: "AGA", 2: "GERG-88"} net_params = dict() net_data = stored_data["net_parameters"] diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 796f62df0..5e7e3e35d 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -264,7 +264,21 @@ def calc_der_lambda(m, eta, d, k, friction_model, lambda_pipe, area, re, lengths (eta[pos] * area[pos]) / (d[pos])) ** 0.9 * np.abs(m[pos]) ** -1.9 return lambda_der - # elif friction_model == "churchill": + elif friction_model == "churchill": + param = (7*eta[pos]*area[pos]/(m[pos]*d[pos]))**0.9 + 0.27*k[pos]/d[pos] + partial_dparamdm = -0.9*7**0.9 * (d[pos]/(eta[pos] * area[pos]))**(-0.9) * m[pos]**(-1.9) + + paramsAB = ((-2.457*np.log((7*eta[pos]*area[pos]/(m[pos] * d[pos]))**0.9 + 0.27*k[pos]/d[pos]))**16 + (37530*eta[pos]*area[pos]/(m[pos] * d[pos]))**16) + paramC = (8*eta[pos]*area[pos]/(m[pos]*d[pos]))**12 + paramsAB**(-1.5) + + partial_dAdm = 16*(2.457*np.log(param))**15 * 2.457*param**(-1) * partial_dparamdm + partial_dBdm = -16*37530**16*(eta[pos]*area[pos]/(m[pos]*d[pos]))**17 + + partial_dCdm = -12*(8*eta[pos]*area[pos]/(m[pos]*d[pos]))**11 * (8*eta[pos]*area[pos]/(m[pos]**2*d[pos])) - paramsAB**(-3)*1.5*paramsAB**0.5 * (partial_dAdm + partial_dBdm) + + lambda_der[pos] = 2/3* paramC**(-11/12) * partial_dCdm + + return lambda_der else: lambda_der[pos] = -(64 * eta[pos] * area[pos]) / (m[pos] ** 2 * d[pos]) @@ -319,3 +333,8 @@ def cw_derivative(lambda_cb, re_nz, k_nz, d_nz): converged = np.all(res.converged) return converged, lambda_res + + + + + diff --git a/src/pandapipes/pf/scratch.py b/src/pandapipes/pf/scratch.py deleted file mode 100644 index 9935d329d..000000000 --- a/src/pandapipes/pf/scratch.py +++ /dev/null @@ -1,6 +0,0 @@ -# %% - - -import numpy as np - - From 2762c36af48be30379940c0fe2c771d4183d54f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20V=C3=B6lzel?= Date: Fri, 14 Nov 2025 10:54:56 +0100 Subject: [PATCH 3/4] correction in return statement of function calc_lambda --- src/pandapipes/pf/derivative_calculation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pandapipes/pf/derivative_calculation.py b/src/pandapipes/pf/derivative_calculation.py index 5e7e3e35d..81bb3523a 100644 --- a/src/pandapipes/pf/derivative_calculation.py +++ b/src/pandapipes/pf/derivative_calculation.py @@ -204,7 +204,7 @@ def calc_lambda(m, eta, d, k, gas_mode, friction_model, lengths, options, area): paramA = (-2.457*np.log((7/re)**0.9 + 0.27*k/d))**16 paramB = (37530/re)**16 lambda_churchill = 8*((8/re)**12 + 1/(paramA+paramB)**1.5)**(1/12) - return lambda_churchill + return lambda_churchill, re else: # lambda_tot = np.where(re > 2300, lambda_laminar + lambda_nikuradse, lambda_laminar) From e996ad31063789c4d74f77c57a80d2c3629da8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Constantin=20V=C3=B6lzel?= Date: Wed, 22 Apr 2026 13:50:17 +0200 Subject: [PATCH 4/4] Added changelog entry for impllementation of Churchill friction factor --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 19c9b45f7..1f739bc5b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,6 +10,7 @@ Change Log - [CHANGED] Colebrook-White friction model now uses scipy.optimize.newton for solving the equation - [CHANGED] Fluid properties compressibility and viscosity can now process pressure and temperature as inputs, if given the "allow_2d" attribute - [CHANGED] Temperature change along pipes now based on exponential function and does not use qext_w anymore +- [ADDED] Churchill friction factor for application in entire flow regime [0.12.0] - 2025-06-27 -------------------------------