cfdpre 0.2.4__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cfdpre-0.3.0/PKG-INFO +157 -0
- cfdpre-0.3.0/README.md +147 -0
- cfdpre-0.3.0/cfdpre/__init__.py +3 -0
- cfdpre-0.3.0/cfdpre/main.py +234 -0
- cfdpre-0.3.0/cfdpre.egg-info/PKG-INFO +157 -0
- {cfdpre-0.2.4 → cfdpre-0.3.0}/setup.py +24 -24
- cfdpre-0.2.4/PKG-INFO +0 -107
- cfdpre-0.2.4/README.md +0 -97
- cfdpre-0.2.4/cfdpre/__init__.py +0 -3
- cfdpre-0.2.4/cfdpre/main.py +0 -111
- cfdpre-0.2.4/cfdpre.egg-info/PKG-INFO +0 -107
- {cfdpre-0.2.4 → cfdpre-0.3.0}/cfdpre.egg-info/SOURCES.txt +0 -0
- {cfdpre-0.2.4 → cfdpre-0.3.0}/cfdpre.egg-info/dependency_links.txt +0 -0
- {cfdpre-0.2.4 → cfdpre-0.3.0}/cfdpre.egg-info/requires.txt +0 -0
- {cfdpre-0.2.4 → cfdpre-0.3.0}/cfdpre.egg-info/top_level.txt +0 -0
- {cfdpre-0.2.4 → cfdpre-0.3.0}/setup.cfg +0 -0
cfdpre-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cfdpre
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CFD PreProcessing Library
|
|
5
|
+
Author: Pushkar Sheth
|
|
6
|
+
Author-email: siglyserdev@gmail.com
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: CoolProp
|
|
10
|
+
|
|
11
|
+
<h1 align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
13
|
+
</h1><br>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
What is CFDPre?
|
|
17
|
+
----------------------
|
|
18
|
+
|
|
19
|
+
CFDPre is an open-source collection of object-oriented software tools for
|
|
20
|
+
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
21
|
+
Among other things, it can be used to:
|
|
22
|
+
|
|
23
|
+
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Installation
|
|
27
|
+
----------------------
|
|
28
|
+
|
|
29
|
+
[](
|
|
30
|
+
https://pypi.org/project/cfdpre/) [](
|
|
31
|
+
https://pypistats.org/packages/cfdpre)
|
|
32
|
+
|
|
33
|
+
In your command line, within Python environment:
|
|
34
|
+
```pythom
|
|
35
|
+
pip install cfdpre
|
|
36
|
+
```
|
|
37
|
+
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Usage
|
|
41
|
+
----------------------
|
|
42
|
+
|
|
43
|
+
`yhgrcalc` supports two flow types:
|
|
44
|
+
|
|
45
|
+
- **`flow_type='internal'`** (default) — fully-developed pipe/duct flow. `massflow_kgpersec`
|
|
46
|
+
and `hydraulicdia_mm` are used to derive velocity and Reynolds number. Skin friction uses
|
|
47
|
+
the laminar (`Re < 2300`, `16/Re`) or the **Haaland (1983)** explicit turbulent correlation,
|
|
48
|
+
valid across the full turbulent range for smooth and rough pipes (`roughness_mm`) — unlike
|
|
49
|
+
Blasius, which is only accurate below `Re ≈ 1e5`. The prism-stack thickness defaults to the
|
|
50
|
+
pipe radius, but you can set it explicitly with `bl_thickness_mm` or as a fraction of the
|
|
51
|
+
radius with `bl_thickness_fraction` (filling the entire radius with prisms is rarely what
|
|
52
|
+
you actually mesh).
|
|
53
|
+
- **`flow_type='external'`** — flow over a flat plate / aerodynamic surface.
|
|
54
|
+
`hydraulicdia_mm` is interpreted as a characteristic length (e.g. chord length), and
|
|
55
|
+
`flow_velocity_mpersec` is **required** (the mass-flow/area velocity is meaningless for
|
|
56
|
+
external flow). Skin friction and boundary layer thickness use the laminar (Blasius) or
|
|
57
|
+
turbulent (Schlichting) flat-plate correlations; `bl_thickness_mm` can override the
|
|
58
|
+
correlation-based thickness.
|
|
59
|
+
|
|
60
|
+
If the computed growth ratio exceeds ~1.3 (or the boundary layer is too thin to resolve
|
|
61
|
+
with the requested `target_yplus`/`num_layers`), a `UserWarning` is raised so you can
|
|
62
|
+
adjust your inputs.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from cfdpre import yhgrcalc
|
|
66
|
+
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Output:
|
|
70
|
+
```python
|
|
71
|
+
{'fluid': 'Air',
|
|
72
|
+
'temperature [C]': 50,
|
|
73
|
+
'pressure [bar]': 10,
|
|
74
|
+
'massflow [kg/sec]': 2.5,
|
|
75
|
+
'hydraulicdia [mm]': 125,
|
|
76
|
+
'target yplus': 1,
|
|
77
|
+
'number of layers': 8,
|
|
78
|
+
'flow type': 'internal',
|
|
79
|
+
'roughness [mm]': 0.0,
|
|
80
|
+
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
81
|
+
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
82
|
+
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
83
|
+
'density [kg/m^3]': 10.792698589669245,
|
|
84
|
+
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
85
|
+
'flow velocity [m/sec]': 18.875569021507275,
|
|
86
|
+
'reynolds number': 1288541.1444310248,
|
|
87
|
+
'prandtl number': 0.7103701741111368,
|
|
88
|
+
'skin friction coefficient [cf]': 0.002776948990231969,
|
|
89
|
+
'wall shear stress [tau_wall]': 5.339100066909961,
|
|
90
|
+
'boundary layer thickness [delta99] [m]': 0.0625,
|
|
91
|
+
'height of cell centroid from wall [yp] [m]': 2.6034112015544278e-06,
|
|
92
|
+
'first layer height [yh] [m]': 5.2068224031088555e-06,
|
|
93
|
+
'Growth Ratio': 3.6553638704281375,
|
|
94
|
+
'Final Layer Thickness [m]': 0.04540326342524223}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> Note: with `target_yplus=1` and only 8 layers at this high Reynolds number (~1.29e6),
|
|
98
|
+
> the growth ratio comes out to ~3.66, well above the recommended ~1.3 maximum — this
|
|
99
|
+
> example raises a `UserWarning` accordingly. In practice you'd either use far more layers
|
|
100
|
+
> (20-40+) or restrict the prism stack to part of the radius. For example, spanning only
|
|
101
|
+
> 30% of the radius:
|
|
102
|
+
>
|
|
103
|
+
> ```python
|
|
104
|
+
> yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8, bl_thickness_fraction=0.3) # GR ~3.04
|
|
105
|
+
> ```
|
|
106
|
+
|
|
107
|
+
External flow example (`flow_velocity_mpersec` is required):
|
|
108
|
+
```python
|
|
109
|
+
yhgrcalc('Air', 25, 1.01325, 2.5, 1000, 1, 15, flow_type='external', flow_velocity_mpersec=30)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Documentation
|
|
113
|
+
----------------------
|
|
114
|
+
|
|
115
|
+
In progress - not yet made!
|
|
116
|
+
|
|
117
|
+
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
118
|
+
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
119
|
+
- **Source code:** https://github.com/phsheth/cfdpre
|
|
120
|
+
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Call for Contributors
|
|
125
|
+
----------------------
|
|
126
|
+
|
|
127
|
+
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Project Log
|
|
131
|
+
----------------------
|
|
132
|
+
January 2025:
|
|
133
|
+
1. Created Library
|
|
134
|
+
|
|
135
|
+
June 2026:
|
|
136
|
+
1. Added `flow_type` ('internal'/'external') support. Internal flow uses laminar `16/Re`
|
|
137
|
+
and the Haaland (1983) turbulent correlation (valid to high Re, smooth/rough via
|
|
138
|
+
`roughness_mm`); external flow uses Blasius/Schlichting flat-plate correlations and now
|
|
139
|
+
requires `flow_velocity_mpersec`. Prism-stack thickness is selectable via `bl_thickness_mm`
|
|
140
|
+
or `bl_thickness_fraction`. Added growth-ratio (>1.3) and boundary-layer sanity warnings.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
Project RoadMap:
|
|
144
|
+
----------------------
|
|
145
|
+
|
|
146
|
+
1. Documentation for existing functionality.
|
|
147
|
+
2. Include example data within library.
|
|
148
|
+
3. Object-oriented API refactor + input validation.
|
|
149
|
+
4. Generate `snappyHexMeshDict`-ready `addLayersControls` snippets.
|
|
150
|
+
5. Bundled examples, unit tests, CI, and docs site.
|
|
151
|
+
6. Parametric/batch sweeps.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
cfdpre-0.3.0/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
3
|
+
</h1><br>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
What is CFDPre?
|
|
7
|
+
----------------------
|
|
8
|
+
|
|
9
|
+
CFDPre is an open-source collection of object-oriented software tools for
|
|
10
|
+
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
11
|
+
Among other things, it can be used to:
|
|
12
|
+
|
|
13
|
+
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
Installation
|
|
17
|
+
----------------------
|
|
18
|
+
|
|
19
|
+
[](
|
|
20
|
+
https://pypi.org/project/cfdpre/) [](
|
|
21
|
+
https://pypistats.org/packages/cfdpre)
|
|
22
|
+
|
|
23
|
+
In your command line, within Python environment:
|
|
24
|
+
```pythom
|
|
25
|
+
pip install cfdpre
|
|
26
|
+
```
|
|
27
|
+
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Usage
|
|
31
|
+
----------------------
|
|
32
|
+
|
|
33
|
+
`yhgrcalc` supports two flow types:
|
|
34
|
+
|
|
35
|
+
- **`flow_type='internal'`** (default) — fully-developed pipe/duct flow. `massflow_kgpersec`
|
|
36
|
+
and `hydraulicdia_mm` are used to derive velocity and Reynolds number. Skin friction uses
|
|
37
|
+
the laminar (`Re < 2300`, `16/Re`) or the **Haaland (1983)** explicit turbulent correlation,
|
|
38
|
+
valid across the full turbulent range for smooth and rough pipes (`roughness_mm`) — unlike
|
|
39
|
+
Blasius, which is only accurate below `Re ≈ 1e5`. The prism-stack thickness defaults to the
|
|
40
|
+
pipe radius, but you can set it explicitly with `bl_thickness_mm` or as a fraction of the
|
|
41
|
+
radius with `bl_thickness_fraction` (filling the entire radius with prisms is rarely what
|
|
42
|
+
you actually mesh).
|
|
43
|
+
- **`flow_type='external'`** — flow over a flat plate / aerodynamic surface.
|
|
44
|
+
`hydraulicdia_mm` is interpreted as a characteristic length (e.g. chord length), and
|
|
45
|
+
`flow_velocity_mpersec` is **required** (the mass-flow/area velocity is meaningless for
|
|
46
|
+
external flow). Skin friction and boundary layer thickness use the laminar (Blasius) or
|
|
47
|
+
turbulent (Schlichting) flat-plate correlations; `bl_thickness_mm` can override the
|
|
48
|
+
correlation-based thickness.
|
|
49
|
+
|
|
50
|
+
If the computed growth ratio exceeds ~1.3 (or the boundary layer is too thin to resolve
|
|
51
|
+
with the requested `target_yplus`/`num_layers`), a `UserWarning` is raised so you can
|
|
52
|
+
adjust your inputs.
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from cfdpre import yhgrcalc
|
|
56
|
+
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Output:
|
|
60
|
+
```python
|
|
61
|
+
{'fluid': 'Air',
|
|
62
|
+
'temperature [C]': 50,
|
|
63
|
+
'pressure [bar]': 10,
|
|
64
|
+
'massflow [kg/sec]': 2.5,
|
|
65
|
+
'hydraulicdia [mm]': 125,
|
|
66
|
+
'target yplus': 1,
|
|
67
|
+
'number of layers': 8,
|
|
68
|
+
'flow type': 'internal',
|
|
69
|
+
'roughness [mm]': 0.0,
|
|
70
|
+
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
71
|
+
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
72
|
+
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
73
|
+
'density [kg/m^3]': 10.792698589669245,
|
|
74
|
+
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
75
|
+
'flow velocity [m/sec]': 18.875569021507275,
|
|
76
|
+
'reynolds number': 1288541.1444310248,
|
|
77
|
+
'prandtl number': 0.7103701741111368,
|
|
78
|
+
'skin friction coefficient [cf]': 0.002776948990231969,
|
|
79
|
+
'wall shear stress [tau_wall]': 5.339100066909961,
|
|
80
|
+
'boundary layer thickness [delta99] [m]': 0.0625,
|
|
81
|
+
'height of cell centroid from wall [yp] [m]': 2.6034112015544278e-06,
|
|
82
|
+
'first layer height [yh] [m]': 5.2068224031088555e-06,
|
|
83
|
+
'Growth Ratio': 3.6553638704281375,
|
|
84
|
+
'Final Layer Thickness [m]': 0.04540326342524223}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> Note: with `target_yplus=1` and only 8 layers at this high Reynolds number (~1.29e6),
|
|
88
|
+
> the growth ratio comes out to ~3.66, well above the recommended ~1.3 maximum — this
|
|
89
|
+
> example raises a `UserWarning` accordingly. In practice you'd either use far more layers
|
|
90
|
+
> (20-40+) or restrict the prism stack to part of the radius. For example, spanning only
|
|
91
|
+
> 30% of the radius:
|
|
92
|
+
>
|
|
93
|
+
> ```python
|
|
94
|
+
> yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8, bl_thickness_fraction=0.3) # GR ~3.04
|
|
95
|
+
> ```
|
|
96
|
+
|
|
97
|
+
External flow example (`flow_velocity_mpersec` is required):
|
|
98
|
+
```python
|
|
99
|
+
yhgrcalc('Air', 25, 1.01325, 2.5, 1000, 1, 15, flow_type='external', flow_velocity_mpersec=30)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Documentation
|
|
103
|
+
----------------------
|
|
104
|
+
|
|
105
|
+
In progress - not yet made!
|
|
106
|
+
|
|
107
|
+
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
108
|
+
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
109
|
+
- **Source code:** https://github.com/phsheth/cfdpre
|
|
110
|
+
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
Call for Contributors
|
|
115
|
+
----------------------
|
|
116
|
+
|
|
117
|
+
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
Project Log
|
|
121
|
+
----------------------
|
|
122
|
+
January 2025:
|
|
123
|
+
1. Created Library
|
|
124
|
+
|
|
125
|
+
June 2026:
|
|
126
|
+
1. Added `flow_type` ('internal'/'external') support. Internal flow uses laminar `16/Re`
|
|
127
|
+
and the Haaland (1983) turbulent correlation (valid to high Re, smooth/rough via
|
|
128
|
+
`roughness_mm`); external flow uses Blasius/Schlichting flat-plate correlations and now
|
|
129
|
+
requires `flow_velocity_mpersec`. Prism-stack thickness is selectable via `bl_thickness_mm`
|
|
130
|
+
or `bl_thickness_fraction`. Added growth-ratio (>1.3) and boundary-layer sanity warnings.
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
Project RoadMap:
|
|
134
|
+
----------------------
|
|
135
|
+
|
|
136
|
+
1. Documentation for existing functionality.
|
|
137
|
+
2. Include example data within library.
|
|
138
|
+
3. Object-oriented API refactor + input validation.
|
|
139
|
+
4. Generate `snappyHexMeshDict`-ready `addLayersControls` snippets.
|
|
140
|
+
5. Bundled examples, unit tests, CI, and docs site.
|
|
141
|
+
6. Parametric/batch sweeps.
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# main.py
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import warnings
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import CoolProp.CoolProp as CP
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def calculate_f(r, N, delta99, yH):
|
|
12
|
+
|
|
13
|
+
"""Calculates the function f(r) for root finding."""
|
|
14
|
+
|
|
15
|
+
return r**N - r * (delta99 / yH) + (delta99 / yH - 1)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def calculate_df_dr(r, N, delta99, yH):
|
|
20
|
+
|
|
21
|
+
"""Calculates the derivative of f(r) with respect to r."""
|
|
22
|
+
|
|
23
|
+
return N * r**(N-1) - (delta99 / yH)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def newton_raphson(N, delta99, yH, initial_guess=5, tolerance=1e-12, max_iterations=1000):
|
|
28
|
+
|
|
29
|
+
"""Finds the growth ratio using the Newton-Raphson method."""
|
|
30
|
+
|
|
31
|
+
r = initial_guess
|
|
32
|
+
|
|
33
|
+
for _ in range(max_iterations):
|
|
34
|
+
|
|
35
|
+
f_r = calculate_f(r, N, delta99, yH)
|
|
36
|
+
|
|
37
|
+
df_dr = calculate_df_dr(r, N, delta99, yH)
|
|
38
|
+
|
|
39
|
+
r_new = r - f_r / df_dr
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if np.abs(r_new - r) < tolerance:
|
|
43
|
+
|
|
44
|
+
return r_new
|
|
45
|
+
|
|
46
|
+
r = r_new
|
|
47
|
+
|
|
48
|
+
return r
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def yhgrcalc(fluid, temperature_c, pressure_bar, massflow_kgpersec, hydraulicdia_mm,
|
|
54
|
+
target_yplus, num_layers, flow_type='internal', flow_velocity_mpersec=None,
|
|
55
|
+
bl_thickness_mm=None, bl_thickness_fraction=None, roughness_mm=0.0):
|
|
56
|
+
|
|
57
|
+
"""Calculate boundary layer mesh sizing (first layer height, growth ratio, final layer thickness).
|
|
58
|
+
|
|
59
|
+
Two flow types are supported:
|
|
60
|
+
|
|
61
|
+
- ``'internal'`` (default): fully-developed pipe/duct flow. ``massflow_kgpersec`` and
|
|
62
|
+
``hydraulicdia_mm`` are used to derive the flow velocity and Reynolds number. The skin
|
|
63
|
+
friction coefficient uses the laminar (``Re < 2300``, ``16/Re``) or the Haaland (1983)
|
|
64
|
+
explicit turbulent correlation, which is valid across the full turbulent range for both
|
|
65
|
+
smooth and rough pipes (unlike the Blasius ``0.079*Re^-0.25`` form, which is only valid
|
|
66
|
+
for ``Re < ~1e5``). The prism-stack thickness to be spanned defaults to the pipe radius,
|
|
67
|
+
but can be set explicitly with ``bl_thickness_mm`` or as a fraction of the radius with
|
|
68
|
+
``bl_thickness_fraction`` (filling the whole radius is rarely what you mesh in practice).
|
|
69
|
+
- ``'external'``: flow over a flat plate / aerodynamic surface. ``hydraulicdia_mm`` is
|
|
70
|
+
interpreted as the characteristic length (e.g. chord or plate length) along the flow
|
|
71
|
+
direction. ``flow_velocity_mpersec`` is **required** (the mass-flow/area velocity is
|
|
72
|
+
meaningless for external flow). The skin friction coefficient and boundary layer
|
|
73
|
+
thickness use the laminar (``Re < 5e5``, Blasius flat plate) or turbulent (Schlichting)
|
|
74
|
+
flat-plate correlations; ``bl_thickness_mm`` can override the correlation-based thickness.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
fluid (str): CoolProp fluid name (e.g. ``'Air'``, ``'Water'``).
|
|
78
|
+
temperature_c (float): Static temperature in degrees Celsius.
|
|
79
|
+
pressure_bar (float): Static pressure in bar (absolute).
|
|
80
|
+
massflow_kgpersec (float): Mass flow rate in kg/s (used for internal flow).
|
|
81
|
+
hydraulicdia_mm (float): Hydraulic diameter (internal flow) or characteristic
|
|
82
|
+
length (external flow) in mm.
|
|
83
|
+
target_yplus (float): Target y+ value at the first cell centroid.
|
|
84
|
+
num_layers (int): Number of inflation/prism layers.
|
|
85
|
+
flow_type (str): ``'internal'`` (default) or ``'external'``.
|
|
86
|
+
flow_velocity_mpersec (float, optional): Free-stream velocity in m/s. Required for
|
|
87
|
+
``flow_type='external'``; ignored for internal flow (derived from mass flow).
|
|
88
|
+
bl_thickness_mm (float, optional): Explicit total prism-stack thickness in mm to be
|
|
89
|
+
spanned by the layers. Overrides the default (pipe radius for internal,
|
|
90
|
+
correlation BL thickness for external).
|
|
91
|
+
bl_thickness_fraction (float, optional): Internal flow only. Prism-stack thickness as
|
|
92
|
+
a fraction of the pipe radius (0 < f <= 1), e.g. 0.3 for 30% of the radius.
|
|
93
|
+
Ignored if ``bl_thickness_mm`` is given.
|
|
94
|
+
roughness_mm (float): Absolute wall roughness in mm for the Haaland turbulent
|
|
95
|
+
internal correlation. Default 0.0 (hydraulically smooth).
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
dict: Fluid properties, flow conditions, and boundary layer mesh sizing results,
|
|
99
|
+
including ``'Growth Ratio'`` and ``'Final Layer Thickness [m]'``.
|
|
100
|
+
|
|
101
|
+
Warns:
|
|
102
|
+
UserWarning: If the boundary layer thickness is not larger than the first layer
|
|
103
|
+
height (mesh sizing inputs are inconsistent), or if the resulting growth ratio
|
|
104
|
+
exceeds the commonly recommended maximum of ~1.3.
|
|
105
|
+
|
|
106
|
+
Raises:
|
|
107
|
+
ValueError: If ``flow_type`` is invalid, if ``flow_type='external'`` is requested
|
|
108
|
+
without ``flow_velocity_mpersec``, or if ``bl_thickness_fraction`` is outside (0, 1].
|
|
109
|
+
|
|
110
|
+
Example:
|
|
111
|
+
>>> from cfdpre import yhgrcalc
|
|
112
|
+
>>> yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
if flow_type not in ('internal', 'external'):
|
|
116
|
+
raise ValueError("flow_type must be 'internal' or 'external', got %r" % (flow_type,))
|
|
117
|
+
|
|
118
|
+
if flow_type == 'external' and flow_velocity_mpersec is None:
|
|
119
|
+
raise ValueError(
|
|
120
|
+
"flow_type='external' requires flow_velocity_mpersec (free-stream velocity in "
|
|
121
|
+
"m/s); deriving velocity from mass flow and a pipe-area assumption is meaningless "
|
|
122
|
+
"for external flow."
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
if bl_thickness_fraction is not None and not (0 < bl_thickness_fraction <= 1):
|
|
126
|
+
raise ValueError(
|
|
127
|
+
"bl_thickness_fraction must be in the interval (0, 1], got %r" % (bl_thickness_fraction,)
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
pressure_pa = pressure_bar * 1e5
|
|
131
|
+
hydraulicdia_m = hydraulicdia_mm/1000
|
|
132
|
+
temperature_k = temperature_c + 273.15
|
|
133
|
+
|
|
134
|
+
dynvisc_pas = CP.PropsSI('V', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
135
|
+
dynvisc_nsm2 = dynvisc_pas
|
|
136
|
+
|
|
137
|
+
thermal_conductivity_wpermk = CP.PropsSI('L', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
138
|
+
specific_heat_cp_jperkgk = CP.PropsSI('C', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
139
|
+
density_kgperm3 = CP.PropsSI('D', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
140
|
+
kinevisc_m2s = dynvisc_nsm2 / density_kgperm3
|
|
141
|
+
volflowrate_m3persec = massflow_kgpersec / density_kgperm3
|
|
142
|
+
|
|
143
|
+
if flow_type == 'external':
|
|
144
|
+
flowvelocity_mpersec = flow_velocity_mpersec
|
|
145
|
+
else:
|
|
146
|
+
flowvelocity_mpersec = volflowrate_m3persec / ((np.pi/4) * np.power(hydraulicdia_m, 2))
|
|
147
|
+
|
|
148
|
+
reynolds = flowvelocity_mpersec * hydraulicdia_m / kinevisc_m2s
|
|
149
|
+
prandtl = specific_heat_cp_jperkgk * dynvisc_nsm2 / thermal_conductivity_wpermk
|
|
150
|
+
|
|
151
|
+
if flow_type == 'internal':
|
|
152
|
+
radius_m = hydraulicdia_m / 2
|
|
153
|
+
if reynolds < 2300:
|
|
154
|
+
cf = 16 / reynolds # laminar pipe flow, Fanning friction factor (= Hagen-Poiseuille)
|
|
155
|
+
else:
|
|
156
|
+
# Haaland (1983) explicit approximation to Colebrook. Valid across the full
|
|
157
|
+
# turbulent range for smooth and rough pipes, avoiding Blasius's ~Re<1e5 ceiling.
|
|
158
|
+
rough_ratio = (roughness_mm / 1000) / hydraulicdia_m
|
|
159
|
+
f_darcy = (1.0 / (-1.8 * np.log10((6.9 / reynolds) + (rough_ratio / 3.7) ** 1.11))) ** 2
|
|
160
|
+
cf = f_darcy / 4.0 # convert Darcy -> Fanning (skin friction coefficient)
|
|
161
|
+
# prism-stack thickness to span: explicit > fraction-of-radius > full radius
|
|
162
|
+
if bl_thickness_mm is not None:
|
|
163
|
+
delta99 = bl_thickness_mm / 1000
|
|
164
|
+
elif bl_thickness_fraction is not None:
|
|
165
|
+
delta99 = bl_thickness_fraction * radius_m
|
|
166
|
+
else:
|
|
167
|
+
delta99 = radius_m
|
|
168
|
+
else:
|
|
169
|
+
if reynolds < 5e5:
|
|
170
|
+
cf = 0.664 / np.sqrt(reynolds) # Blasius laminar flat plate
|
|
171
|
+
delta99 = 4.91 * hydraulicdia_m / np.sqrt(reynolds)
|
|
172
|
+
else:
|
|
173
|
+
cf = np.power(((2 * np.log10(reynolds) - 0.65)), (-2.3)) # Schlichting turbulent flat plate
|
|
174
|
+
delta99 = 0.38 * hydraulicdia_m * reynolds**(-1/5)
|
|
175
|
+
if bl_thickness_mm is not None:
|
|
176
|
+
delta99 = bl_thickness_mm / 1000
|
|
177
|
+
|
|
178
|
+
tau_wall = 0.5 * density_kgperm3 * np.square(flowvelocity_mpersec) * cf # wall shear stress
|
|
179
|
+
u_tau = np.sqrt(tau_wall/density_kgperm3) #friction velocity
|
|
180
|
+
yp_m = (target_yplus * dynvisc_nsm2) /(u_tau * density_kgperm3)
|
|
181
|
+
yh_m = yp_m * 2
|
|
182
|
+
|
|
183
|
+
if delta99 <= yh_m:
|
|
184
|
+
warnings.warn(
|
|
185
|
+
"Boundary layer thickness (%.3e m) is not larger than the first layer height "
|
|
186
|
+
"(%.3e m). Reduce target_yplus/num_layers or check the input flow conditions "
|
|
187
|
+
"and geometry." % (delta99, yh_m),
|
|
188
|
+
UserWarning,
|
|
189
|
+
)
|
|
190
|
+
growth_ratio = float('nan')
|
|
191
|
+
final_layer_thickness_m = float('nan')
|
|
192
|
+
else:
|
|
193
|
+
growth_ratio = newton_raphson(num_layers, delta99, yh_m)
|
|
194
|
+
final_layer_thickness_m = yh_m * growth_ratio**(num_layers - 1)
|
|
195
|
+
if growth_ratio > 1.3:
|
|
196
|
+
warnings.warn(
|
|
197
|
+
"Computed growth ratio (%.3f) exceeds the commonly recommended maximum of "
|
|
198
|
+
"~1.3 for boundary layer mesh quality. Consider increasing num_layers or "
|
|
199
|
+
"revisiting target_yplus." % growth_ratio,
|
|
200
|
+
UserWarning,
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
result = {
|
|
204
|
+
'fluid' : fluid,
|
|
205
|
+
'temperature [C]' : temperature_c,
|
|
206
|
+
'pressure [bar]' : pressure_bar,
|
|
207
|
+
'massflow [kg/sec]' : massflow_kgpersec,
|
|
208
|
+
'hydraulicdia [mm]' : hydraulicdia_mm,
|
|
209
|
+
'target yplus' : target_yplus,
|
|
210
|
+
'number of layers' : num_layers,
|
|
211
|
+
'flow type' : flow_type,
|
|
212
|
+
'roughness [mm]' : roughness_mm,
|
|
213
|
+
'dynvisc [N-sec/m^2]' : dynvisc_nsm2,
|
|
214
|
+
'thermal conductivity [W/m-k]' : thermal_conductivity_wpermk,
|
|
215
|
+
'specific heat [cp] [J/kg-k]' : specific_heat_cp_jperkgk,
|
|
216
|
+
'density [kg/m^3]' : density_kgperm3,
|
|
217
|
+
'kinematic viscosity [m^2/s]' : kinevisc_m2s,
|
|
218
|
+
'flow velocity [m/sec]' : flowvelocity_mpersec,
|
|
219
|
+
'reynolds number' : reynolds,
|
|
220
|
+
'prandtl number' : prandtl,
|
|
221
|
+
'skin friction coefficient [cf]' : cf,
|
|
222
|
+
'wall shear stress [tau_wall]' : tau_wall,
|
|
223
|
+
'boundary layer thickness [delta99] [m]' : delta99,
|
|
224
|
+
'height of cell centroid from wall [yp] [m]' : yp_m,
|
|
225
|
+
'first layer height [yh] [m]' : yh_m,
|
|
226
|
+
'Growth Ratio' : growth_ratio,
|
|
227
|
+
'Final Layer Thickness [m]' : final_layer_thickness_m
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return result
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: cfdpre
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CFD PreProcessing Library
|
|
5
|
+
Author: Pushkar Sheth
|
|
6
|
+
Author-email: siglyserdev@gmail.com
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: CoolProp
|
|
10
|
+
|
|
11
|
+
<h1 align="center">
|
|
12
|
+
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
13
|
+
</h1><br>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
What is CFDPre?
|
|
17
|
+
----------------------
|
|
18
|
+
|
|
19
|
+
CFDPre is an open-source collection of object-oriented software tools for
|
|
20
|
+
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
21
|
+
Among other things, it can be used to:
|
|
22
|
+
|
|
23
|
+
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Installation
|
|
27
|
+
----------------------
|
|
28
|
+
|
|
29
|
+
[](
|
|
30
|
+
https://pypi.org/project/cfdpre/) [](
|
|
31
|
+
https://pypistats.org/packages/cfdpre)
|
|
32
|
+
|
|
33
|
+
In your command line, within Python environment:
|
|
34
|
+
```pythom
|
|
35
|
+
pip install cfdpre
|
|
36
|
+
```
|
|
37
|
+
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
Usage
|
|
41
|
+
----------------------
|
|
42
|
+
|
|
43
|
+
`yhgrcalc` supports two flow types:
|
|
44
|
+
|
|
45
|
+
- **`flow_type='internal'`** (default) — fully-developed pipe/duct flow. `massflow_kgpersec`
|
|
46
|
+
and `hydraulicdia_mm` are used to derive velocity and Reynolds number. Skin friction uses
|
|
47
|
+
the laminar (`Re < 2300`, `16/Re`) or the **Haaland (1983)** explicit turbulent correlation,
|
|
48
|
+
valid across the full turbulent range for smooth and rough pipes (`roughness_mm`) — unlike
|
|
49
|
+
Blasius, which is only accurate below `Re ≈ 1e5`. The prism-stack thickness defaults to the
|
|
50
|
+
pipe radius, but you can set it explicitly with `bl_thickness_mm` or as a fraction of the
|
|
51
|
+
radius with `bl_thickness_fraction` (filling the entire radius with prisms is rarely what
|
|
52
|
+
you actually mesh).
|
|
53
|
+
- **`flow_type='external'`** — flow over a flat plate / aerodynamic surface.
|
|
54
|
+
`hydraulicdia_mm` is interpreted as a characteristic length (e.g. chord length), and
|
|
55
|
+
`flow_velocity_mpersec` is **required** (the mass-flow/area velocity is meaningless for
|
|
56
|
+
external flow). Skin friction and boundary layer thickness use the laminar (Blasius) or
|
|
57
|
+
turbulent (Schlichting) flat-plate correlations; `bl_thickness_mm` can override the
|
|
58
|
+
correlation-based thickness.
|
|
59
|
+
|
|
60
|
+
If the computed growth ratio exceeds ~1.3 (or the boundary layer is too thin to resolve
|
|
61
|
+
with the requested `target_yplus`/`num_layers`), a `UserWarning` is raised so you can
|
|
62
|
+
adjust your inputs.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from cfdpre import yhgrcalc
|
|
66
|
+
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Output:
|
|
70
|
+
```python
|
|
71
|
+
{'fluid': 'Air',
|
|
72
|
+
'temperature [C]': 50,
|
|
73
|
+
'pressure [bar]': 10,
|
|
74
|
+
'massflow [kg/sec]': 2.5,
|
|
75
|
+
'hydraulicdia [mm]': 125,
|
|
76
|
+
'target yplus': 1,
|
|
77
|
+
'number of layers': 8,
|
|
78
|
+
'flow type': 'internal',
|
|
79
|
+
'roughness [mm]': 0.0,
|
|
80
|
+
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
81
|
+
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
82
|
+
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
83
|
+
'density [kg/m^3]': 10.792698589669245,
|
|
84
|
+
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
85
|
+
'flow velocity [m/sec]': 18.875569021507275,
|
|
86
|
+
'reynolds number': 1288541.1444310248,
|
|
87
|
+
'prandtl number': 0.7103701741111368,
|
|
88
|
+
'skin friction coefficient [cf]': 0.002776948990231969,
|
|
89
|
+
'wall shear stress [tau_wall]': 5.339100066909961,
|
|
90
|
+
'boundary layer thickness [delta99] [m]': 0.0625,
|
|
91
|
+
'height of cell centroid from wall [yp] [m]': 2.6034112015544278e-06,
|
|
92
|
+
'first layer height [yh] [m]': 5.2068224031088555e-06,
|
|
93
|
+
'Growth Ratio': 3.6553638704281375,
|
|
94
|
+
'Final Layer Thickness [m]': 0.04540326342524223}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> Note: with `target_yplus=1` and only 8 layers at this high Reynolds number (~1.29e6),
|
|
98
|
+
> the growth ratio comes out to ~3.66, well above the recommended ~1.3 maximum — this
|
|
99
|
+
> example raises a `UserWarning` accordingly. In practice you'd either use far more layers
|
|
100
|
+
> (20-40+) or restrict the prism stack to part of the radius. For example, spanning only
|
|
101
|
+
> 30% of the radius:
|
|
102
|
+
>
|
|
103
|
+
> ```python
|
|
104
|
+
> yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8, bl_thickness_fraction=0.3) # GR ~3.04
|
|
105
|
+
> ```
|
|
106
|
+
|
|
107
|
+
External flow example (`flow_velocity_mpersec` is required):
|
|
108
|
+
```python
|
|
109
|
+
yhgrcalc('Air', 25, 1.01325, 2.5, 1000, 1, 15, flow_type='external', flow_velocity_mpersec=30)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Documentation
|
|
113
|
+
----------------------
|
|
114
|
+
|
|
115
|
+
In progress - not yet made!
|
|
116
|
+
|
|
117
|
+
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
118
|
+
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
119
|
+
- **Source code:** https://github.com/phsheth/cfdpre
|
|
120
|
+
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Call for Contributors
|
|
125
|
+
----------------------
|
|
126
|
+
|
|
127
|
+
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Project Log
|
|
131
|
+
----------------------
|
|
132
|
+
January 2025:
|
|
133
|
+
1. Created Library
|
|
134
|
+
|
|
135
|
+
June 2026:
|
|
136
|
+
1. Added `flow_type` ('internal'/'external') support. Internal flow uses laminar `16/Re`
|
|
137
|
+
and the Haaland (1983) turbulent correlation (valid to high Re, smooth/rough via
|
|
138
|
+
`roughness_mm`); external flow uses Blasius/Schlichting flat-plate correlations and now
|
|
139
|
+
requires `flow_velocity_mpersec`. Prism-stack thickness is selectable via `bl_thickness_mm`
|
|
140
|
+
or `bl_thickness_fraction`. Added growth-ratio (>1.3) and boundary-layer sanity warnings.
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
Project RoadMap:
|
|
144
|
+
----------------------
|
|
145
|
+
|
|
146
|
+
1. Documentation for existing functionality.
|
|
147
|
+
2. Include example data within library.
|
|
148
|
+
3. Object-oriented API refactor + input validation.
|
|
149
|
+
4. Generate `snappyHexMeshDict`-ready `addLayersControls` snippets.
|
|
150
|
+
5. Bundled examples, unit tests, CI, and docs site.
|
|
151
|
+
6. Parametric/batch sweeps.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
# setup.py
|
|
2
|
-
|
|
3
|
-
from setuptools import setup, find_packages
|
|
4
|
-
|
|
5
|
-
with open("README.md", "r") as f:
|
|
6
|
-
description = f.read()
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
setup(
|
|
10
|
-
name='cfdpre',
|
|
11
|
-
version='0.
|
|
12
|
-
description='CFD PreProcessing Library',
|
|
13
|
-
author='Pushkar Sheth',
|
|
14
|
-
author_email='siglyserdev@gmail.com',
|
|
15
|
-
packages=find_packages(),
|
|
16
|
-
install_requires=[
|
|
17
|
-
'numpy',
|
|
18
|
-
'CoolProp'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
],
|
|
22
|
-
|
|
23
|
-
long_description=description,
|
|
24
|
-
long_description_content_type="text/markdown",
|
|
1
|
+
# setup.py
|
|
2
|
+
|
|
3
|
+
from setuptools import setup, find_packages
|
|
4
|
+
|
|
5
|
+
with open("README.md", "r") as f:
|
|
6
|
+
description = f.read()
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
setup(
|
|
10
|
+
name='cfdpre',
|
|
11
|
+
version='0.3.0',
|
|
12
|
+
description='CFD PreProcessing Library',
|
|
13
|
+
author='Pushkar Sheth',
|
|
14
|
+
author_email='siglyserdev@gmail.com',
|
|
15
|
+
packages=find_packages(),
|
|
16
|
+
install_requires=[
|
|
17
|
+
'numpy',
|
|
18
|
+
'CoolProp'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
long_description=description,
|
|
24
|
+
long_description_content_type="text/markdown",
|
|
25
25
|
)
|
cfdpre-0.2.4/PKG-INFO
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: cfdpre
|
|
3
|
-
Version: 0.2.4
|
|
4
|
-
Summary: CFD PreProcessing Library
|
|
5
|
-
Author: Pushkar Sheth
|
|
6
|
-
Author-email: siglyserdev@gmail.com
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: numpy
|
|
9
|
-
Requires-Dist: CoolProp
|
|
10
|
-
|
|
11
|
-
<h1 align="center">
|
|
12
|
-
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
13
|
-
</h1><br>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
What is CFDPre?
|
|
17
|
-
----------------------
|
|
18
|
-
|
|
19
|
-
CFDPre is an open-source collection of object-oriented software tools for
|
|
20
|
-
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
21
|
-
Among other things, it can be used to:
|
|
22
|
-
|
|
23
|
-
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Installation
|
|
27
|
-
----------------------
|
|
28
|
-
|
|
29
|
-
[](
|
|
30
|
-
https://pypi.org/project/cfdpre/) [](
|
|
31
|
-
https://pypistats.org/packages/cfdpre)
|
|
32
|
-
|
|
33
|
-
In your command line, within Python environment:
|
|
34
|
-
```pythom
|
|
35
|
-
pip install cfdpre
|
|
36
|
-
```
|
|
37
|
-
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Usage
|
|
41
|
-
----------------------
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
from cfdpre import yhgrcalc
|
|
45
|
-
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Output:
|
|
49
|
-
```python
|
|
50
|
-
{'fluid': 'Air',
|
|
51
|
-
'temperature [C]': 50,
|
|
52
|
-
'pressure [bar]': 10,
|
|
53
|
-
'massflow [kg/sec]': 2.5,
|
|
54
|
-
'hydraulicdia [mm]': 125,
|
|
55
|
-
'target yplus': 1,
|
|
56
|
-
'number of layers': 8,
|
|
57
|
-
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
58
|
-
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
59
|
-
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
60
|
-
'density [kg/m^3]': 10.792698589669245,
|
|
61
|
-
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
62
|
-
'flow velocity [m/sec]': 18.875569021507275,
|
|
63
|
-
'reynolds number': 1288541.1444310248,
|
|
64
|
-
'prandtl number': 0.7103701741111368,
|
|
65
|
-
'skin friction coefficient [cf]': 0.003583573389858024,
|
|
66
|
-
'wall shear stress [tau_wall]': 6.889956204766108,
|
|
67
|
-
'height of cell centroid from wall [yp] [m]': 2.2917570116263883e-06,
|
|
68
|
-
'first layer height [yh] [m]': 4.583514023252777e-06,
|
|
69
|
-
'Growth Ratio': 2.3120331242085856,
|
|
70
|
-
'Final Layer Thickness [m]': 0.0016186648187374523}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Documentation
|
|
74
|
-
----------------------
|
|
75
|
-
|
|
76
|
-
In progress - not yet made!
|
|
77
|
-
|
|
78
|
-
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
79
|
-
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
80
|
-
- **Source code:** https://github.com/phsheth/cfdpre
|
|
81
|
-
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Call for Contributors
|
|
86
|
-
----------------------
|
|
87
|
-
|
|
88
|
-
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Project Log
|
|
92
|
-
----------------------
|
|
93
|
-
January 2025:
|
|
94
|
-
1. Created Library
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Project RoadMap:
|
|
98
|
-
----------------------
|
|
99
|
-
|
|
100
|
-
1. Documentation for existing functionality.
|
|
101
|
-
2. Include example data within library.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
cfdpre-0.2.4/README.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
<h1 align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
3
|
-
</h1><br>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
What is CFDPre?
|
|
7
|
-
----------------------
|
|
8
|
-
|
|
9
|
-
CFDPre is an open-source collection of object-oriented software tools for
|
|
10
|
-
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
11
|
-
Among other things, it can be used to:
|
|
12
|
-
|
|
13
|
-
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Installation
|
|
17
|
-
----------------------
|
|
18
|
-
|
|
19
|
-
[](
|
|
20
|
-
https://pypi.org/project/cfdpre/) [](
|
|
21
|
-
https://pypistats.org/packages/cfdpre)
|
|
22
|
-
|
|
23
|
-
In your command line, within Python environment:
|
|
24
|
-
```pythom
|
|
25
|
-
pip install cfdpre
|
|
26
|
-
```
|
|
27
|
-
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
Usage
|
|
31
|
-
----------------------
|
|
32
|
-
|
|
33
|
-
```python
|
|
34
|
-
from cfdpre import yhgrcalc
|
|
35
|
-
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
Output:
|
|
39
|
-
```python
|
|
40
|
-
{'fluid': 'Air',
|
|
41
|
-
'temperature [C]': 50,
|
|
42
|
-
'pressure [bar]': 10,
|
|
43
|
-
'massflow [kg/sec]': 2.5,
|
|
44
|
-
'hydraulicdia [mm]': 125,
|
|
45
|
-
'target yplus': 1,
|
|
46
|
-
'number of layers': 8,
|
|
47
|
-
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
48
|
-
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
49
|
-
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
50
|
-
'density [kg/m^3]': 10.792698589669245,
|
|
51
|
-
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
52
|
-
'flow velocity [m/sec]': 18.875569021507275,
|
|
53
|
-
'reynolds number': 1288541.1444310248,
|
|
54
|
-
'prandtl number': 0.7103701741111368,
|
|
55
|
-
'skin friction coefficient [cf]': 0.003583573389858024,
|
|
56
|
-
'wall shear stress [tau_wall]': 6.889956204766108,
|
|
57
|
-
'height of cell centroid from wall [yp] [m]': 2.2917570116263883e-06,
|
|
58
|
-
'first layer height [yh] [m]': 4.583514023252777e-06,
|
|
59
|
-
'Growth Ratio': 2.3120331242085856,
|
|
60
|
-
'Final Layer Thickness [m]': 0.0016186648187374523}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Documentation
|
|
64
|
-
----------------------
|
|
65
|
-
|
|
66
|
-
In progress - not yet made!
|
|
67
|
-
|
|
68
|
-
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
69
|
-
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
70
|
-
- **Source code:** https://github.com/phsheth/cfdpre
|
|
71
|
-
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
Call for Contributors
|
|
76
|
-
----------------------
|
|
77
|
-
|
|
78
|
-
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Project Log
|
|
82
|
-
----------------------
|
|
83
|
-
January 2025:
|
|
84
|
-
1. Created Library
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
Project RoadMap:
|
|
88
|
-
----------------------
|
|
89
|
-
|
|
90
|
-
1. Documentation for existing functionality.
|
|
91
|
-
2. Include example data within library.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
cfdpre-0.2.4/cfdpre/__init__.py
DELETED
cfdpre-0.2.4/cfdpre/main.py
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
# main.py
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import numpy as np
|
|
5
|
-
import CoolProp.CoolProp as CP
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
def calculate_f(r, N, delta99, yH):
|
|
10
|
-
|
|
11
|
-
"""Calculates the function f(r) for root finding."""
|
|
12
|
-
|
|
13
|
-
return r**N - r * (delta99 / yH) + (delta99 / yH - 1)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
def calculate_df_dr(r, N, delta99, yH):
|
|
18
|
-
|
|
19
|
-
"""Calculates the derivative of f(r) with respect to r."""
|
|
20
|
-
|
|
21
|
-
return N * r**(N-1) - (delta99 / yH)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
def newton_raphson(N, delta99, yH, initial_guess=5, tolerance=1e-12, max_iterations=1000):
|
|
26
|
-
|
|
27
|
-
"""Finds the growth ratio using the Newton-Raphson method."""
|
|
28
|
-
|
|
29
|
-
r = initial_guess
|
|
30
|
-
|
|
31
|
-
for _ in range(max_iterations):
|
|
32
|
-
|
|
33
|
-
f_r = calculate_f(r, N, delta99, yH)
|
|
34
|
-
|
|
35
|
-
df_dr = calculate_df_dr(r, N, delta99, yH)
|
|
36
|
-
|
|
37
|
-
r_new = r - f_r / df_dr
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
if np.abs(r_new - r) < tolerance:
|
|
41
|
-
|
|
42
|
-
return r_new
|
|
43
|
-
|
|
44
|
-
r = r_new
|
|
45
|
-
|
|
46
|
-
return r
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def yhgrcalc(fluid, temperature_c, pressure_bar, massflow_kgpersec, hydraulicdia_mm, target_yplus, num_layers):
|
|
52
|
-
|
|
53
|
-
pressure_pa = pressure_bar * 1e5
|
|
54
|
-
hydraulicdia_m = hydraulicdia_mm/1000
|
|
55
|
-
temperature_k = temperature_c + 273.15
|
|
56
|
-
|
|
57
|
-
dynvisc_pas = CP.PropsSI('V', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
58
|
-
dynvisc_nsm2 = dynvisc_pas
|
|
59
|
-
|
|
60
|
-
thermal_conductivity_wpermk = CP.PropsSI('L', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
61
|
-
specific_heat_cp_jperkgk = CP.PropsSI('C', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
62
|
-
density_kgperm3 = CP.PropsSI('D', 'T', temperature_k, 'P', pressure_pa, fluid)
|
|
63
|
-
kinevisc_m2s = dynvisc_nsm2 / density_kgperm3
|
|
64
|
-
volflowrate_m3persec = massflow_kgpersec / density_kgperm3
|
|
65
|
-
flowvelocity_mpersec = volflowrate_m3persec / ((np.pi/4) * np.power(hydraulicdia_m, 2))
|
|
66
|
-
reynolds = flowvelocity_mpersec * hydraulicdia_m / kinevisc_m2s
|
|
67
|
-
prandtl = specific_heat_cp_jperkgk * dynvisc_nsm2 / thermal_conductivity_wpermk
|
|
68
|
-
cf = np.power(((2 * np.log10(reynolds)- 0.65)), (-2.3)) # skin friction coefficient
|
|
69
|
-
tau_wall = 0.5 * density_kgperm3 * np.square(flowvelocity_mpersec) * cf # wall shear stress
|
|
70
|
-
u_tau = np.sqrt(tau_wall/density_kgperm3) #friction velocity
|
|
71
|
-
yp_m = (target_yplus * dynvisc_nsm2) /(u_tau * density_kgperm3)
|
|
72
|
-
yh_m = yp_m * 2
|
|
73
|
-
|
|
74
|
-
if reynolds < 5e5:
|
|
75
|
-
delta99 = 4.91 * hydraulicdia_m / np.sqrt(reynolds)
|
|
76
|
-
else:
|
|
77
|
-
delta99 = 0.38 * hydraulicdia_m * reynolds**(-1/5)
|
|
78
|
-
|
|
79
|
-
growth_ratio = newton_raphson(num_layers, delta99, yh_m)
|
|
80
|
-
final_layer_thickness_m = yh_m * growth_ratio**(num_layers - 1)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
result = {
|
|
84
|
-
'fluid' : fluid,
|
|
85
|
-
'temperature [C]' : temperature_c,
|
|
86
|
-
'pressure [bar]' : pressure_bar,
|
|
87
|
-
'massflow [kg/sec]' : massflow_kgpersec,
|
|
88
|
-
'hydraulicdia [mm]' : hydraulicdia_mm,
|
|
89
|
-
'target yplus' : target_yplus,
|
|
90
|
-
'number of layers' : num_layers,
|
|
91
|
-
'dynvisc [N-sec/m^2]' : dynvisc_nsm2,
|
|
92
|
-
'thermal conductivity [W/m-k]' : thermal_conductivity_wpermk,
|
|
93
|
-
'specific heat [cp] [J/kg-k]' : specific_heat_cp_jperkgk,
|
|
94
|
-
'density [kg/m^3]' : density_kgperm3,
|
|
95
|
-
'kinematic viscosity [m^2/s]' : kinevisc_m2s,
|
|
96
|
-
'flow velocity [m/sec]' : flowvelocity_mpersec,
|
|
97
|
-
'reynolds number' : reynolds,
|
|
98
|
-
'prandtl number' : prandtl,
|
|
99
|
-
'skin friction coefficient [cf]' : cf,
|
|
100
|
-
'wall shear stress [tau_wall]' : tau_wall,
|
|
101
|
-
'height of cell centroid from wall [yp] [m]' : yp_m,
|
|
102
|
-
'first layer height [yh] [m]' : yh_m,
|
|
103
|
-
'Growth Ratio' : growth_ratio,
|
|
104
|
-
'Final Layer Thickness [m]' : final_layer_thickness_m
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return result
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: cfdpre
|
|
3
|
-
Version: 0.2.4
|
|
4
|
-
Summary: CFD PreProcessing Library
|
|
5
|
-
Author: Pushkar Sheth
|
|
6
|
-
Author-email: siglyserdev@gmail.com
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
Requires-Dist: numpy
|
|
9
|
-
Requires-Dist: CoolProp
|
|
10
|
-
|
|
11
|
-
<h1 align="center">
|
|
12
|
-
<img src="https://raw.githubusercontent.com/phsheth/cfdpre/refs/heads/main/cfdprelogo.png" width="300">
|
|
13
|
-
</h1><br>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
What is CFDPre?
|
|
17
|
-
----------------------
|
|
18
|
-
|
|
19
|
-
CFDPre is an open-source collection of object-oriented software tools for
|
|
20
|
-
calculating boundary layer mesh dimensions for Computational Fluid Dynamics simulations.
|
|
21
|
-
Among other things, it can be used to:
|
|
22
|
-
|
|
23
|
-
* Calculate First Layer Thickness, Growth Ratio and Final Layer Thickess
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Installation
|
|
27
|
-
----------------------
|
|
28
|
-
|
|
29
|
-
[](
|
|
30
|
-
https://pypi.org/project/cfdpre/) [](
|
|
31
|
-
https://pypistats.org/packages/cfdpre)
|
|
32
|
-
|
|
33
|
-
In your command line, within Python environment:
|
|
34
|
-
```pythom
|
|
35
|
-
pip install cfdpre
|
|
36
|
-
```
|
|
37
|
-
- The Python module can also be installed using pip on Windows, macOS, and Linux.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
Usage
|
|
41
|
-
----------------------
|
|
42
|
-
|
|
43
|
-
```python
|
|
44
|
-
from cfdpre import yhgrcalc
|
|
45
|
-
yhgrcalc('Air', 50, 10, 2.5, 125, 1, 8)
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
Output:
|
|
49
|
-
```python
|
|
50
|
-
{'fluid': 'Air',
|
|
51
|
-
'temperature [C]': 50,
|
|
52
|
-
'pressure [bar]': 10,
|
|
53
|
-
'massflow [kg/sec]': 2.5,
|
|
54
|
-
'hydraulicdia [mm]': 125,
|
|
55
|
-
'target yplus': 1,
|
|
56
|
-
'number of layers': 8,
|
|
57
|
-
'dynvisc [N-sec/m^2]': 1.9762497305390764e-05,
|
|
58
|
-
'thermal conductivity [W/m-k]': 0.028357331300649127,
|
|
59
|
-
'specific heat [cp] [J/kg-k]': 1019.3146170790077,
|
|
60
|
-
'density [kg/m^3]': 10.792698589669245,
|
|
61
|
-
'kinematic viscosity [m^2/s]': 1.8310987878701066e-06,
|
|
62
|
-
'flow velocity [m/sec]': 18.875569021507275,
|
|
63
|
-
'reynolds number': 1288541.1444310248,
|
|
64
|
-
'prandtl number': 0.7103701741111368,
|
|
65
|
-
'skin friction coefficient [cf]': 0.003583573389858024,
|
|
66
|
-
'wall shear stress [tau_wall]': 6.889956204766108,
|
|
67
|
-
'height of cell centroid from wall [yp] [m]': 2.2917570116263883e-06,
|
|
68
|
-
'first layer height [yh] [m]': 4.583514023252777e-06,
|
|
69
|
-
'Growth Ratio': 2.3120331242085856,
|
|
70
|
-
'Final Layer Thickness [m]': 0.0016186648187374523}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Documentation
|
|
74
|
-
----------------------
|
|
75
|
-
|
|
76
|
-
In progress - not yet made!
|
|
77
|
-
|
|
78
|
-
- **Project Home Page:** https://cfdpre.github.io/ [under construction]
|
|
79
|
-
- **Users Group:** https://groups.google.com/g/cfdpre
|
|
80
|
-
- **Source code:** https://github.com/phsheth/cfdpre
|
|
81
|
-
- **PyPI Page:** https://pypi.org/project/cfdpre/
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Call for Contributors
|
|
86
|
-
----------------------
|
|
87
|
-
|
|
88
|
-
The CFDPre project welcomes your expertise and enthusiasm! Better to discuss on the users group before starting to contribute!
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Project Log
|
|
92
|
-
----------------------
|
|
93
|
-
January 2025:
|
|
94
|
-
1. Created Library
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Project RoadMap:
|
|
98
|
-
----------------------
|
|
99
|
-
|
|
100
|
-
1. Documentation for existing functionality.
|
|
101
|
-
2. Include example data within library.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|