pycphy 0.1.0__py3-none-any.whl
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.
- pycphy/__init__.py +24 -0
- pycphy/foamCaseDeveloper/__init__.py +41 -0
- pycphy/foamCaseDeveloper/config/__init__.py +26 -0
- pycphy/foamCaseDeveloper/config/block_mesh_config.py +90 -0
- pycphy/foamCaseDeveloper/config/control_config.py +168 -0
- pycphy/foamCaseDeveloper/config/global_config.py +83 -0
- pycphy/foamCaseDeveloper/config/turbulence_config.py +187 -0
- pycphy/foamCaseDeveloper/core/__init__.py +18 -0
- pycphy/foamCaseDeveloper/core/block_mesh_developer.py +101 -0
- pycphy/foamCaseDeveloper/core/control_dict_writer.py +55 -0
- pycphy/foamCaseDeveloper/core/foam_case_manager.py +195 -0
- pycphy/foamCaseDeveloper/core/turbulence_properties_writer.py +68 -0
- pycphy/foamCaseDeveloper/main.py +260 -0
- pycphy/foamCaseDeveloper/writers/__init__.py +18 -0
- pycphy/foamCaseDeveloper/writers/block_mesh_writer.py +113 -0
- pycphy/foamCaseDeveloper/writers/control_dict_writer.py +54 -0
- pycphy/foamCaseDeveloper/writers/foam_writer.py +73 -0
- pycphy/foamCaseDeveloper/writers/turbulence_properties_writer.py +78 -0
- pycphy-0.1.0.dist-info/METADATA +335 -0
- pycphy-0.1.0.dist-info/RECORD +24 -0
- pycphy-0.1.0.dist-info/WHEEL +5 -0
- pycphy-0.1.0.dist-info/entry_points.txt +2 -0
- pycphy-0.1.0.dist-info/licenses/LICENSE +21 -0
- pycphy-0.1.0.dist-info/top_level.txt +1 -0
pycphy/__init__.py
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
"""
|
2
|
+
pycphy - Python: Computational Physics
|
3
|
+
|
4
|
+
A Python package for computational physics simulations and tools.
|
5
|
+
|
6
|
+
Author: Sanjeev Bashyal
|
7
|
+
Location: https://github.com/SanjeevBashyal/pycphy
|
8
|
+
"""
|
9
|
+
|
10
|
+
__version__ = "0.1.0"
|
11
|
+
__author__ = "Sanjeev Bashyal"
|
12
|
+
__email__ = "sanjeev.bashyal@example.com"
|
13
|
+
__url__ = "https://github.com/SanjeevBashyal/pycphy"
|
14
|
+
|
15
|
+
# Import main modules for easy access
|
16
|
+
from . import foamCaseDeveloper
|
17
|
+
|
18
|
+
__all__ = [
|
19
|
+
"__version__",
|
20
|
+
"__author__",
|
21
|
+
"__email__",
|
22
|
+
"__url__",
|
23
|
+
"foamCaseDeveloper",
|
24
|
+
]
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"""
|
2
|
+
foamCaseDeveloper - OpenFOAM Case Development Tools
|
3
|
+
|
4
|
+
This module provides tools for creating and managing OpenFOAM simulation cases,
|
5
|
+
including mesh generation, control dictionary setup, and turbulence properties
|
6
|
+
configuration.
|
7
|
+
|
8
|
+
Author: Sanjeev Bashyal
|
9
|
+
"""
|
10
|
+
|
11
|
+
from .core import (
|
12
|
+
BlockMeshDeveloper,
|
13
|
+
ControlDictWriter,
|
14
|
+
TurbulencePropertiesWriter,
|
15
|
+
FoamCaseManager
|
16
|
+
)
|
17
|
+
from .writers import (
|
18
|
+
BlockMeshWriter,
|
19
|
+
FoamWriter
|
20
|
+
)
|
21
|
+
from .config import (
|
22
|
+
global_config,
|
23
|
+
block_mesh_config,
|
24
|
+
control_config,
|
25
|
+
turbulence_config
|
26
|
+
)
|
27
|
+
|
28
|
+
__version__ = "0.1.0"
|
29
|
+
|
30
|
+
__all__ = [
|
31
|
+
"BlockMeshDeveloper",
|
32
|
+
"ControlDictWriter",
|
33
|
+
"TurbulencePropertiesWriter",
|
34
|
+
"FoamCaseManager",
|
35
|
+
"BlockMeshWriter",
|
36
|
+
"FoamWriter",
|
37
|
+
"global_config",
|
38
|
+
"block_mesh_config",
|
39
|
+
"control_config",
|
40
|
+
"turbulence_config",
|
41
|
+
]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"""
|
2
|
+
Configuration files for OpenFOAM case setup.
|
3
|
+
|
4
|
+
This module provides configuration files for different aspects of
|
5
|
+
OpenFOAM case setup, including geometry, control, and turbulence settings.
|
6
|
+
Each config file contains detailed comments explaining all parameters.
|
7
|
+
|
8
|
+
Usage:
|
9
|
+
from pycphy.foamCaseDeveloper.config import global_config
|
10
|
+
from pycphy.foamCaseDeveloper.config import block_mesh_config
|
11
|
+
from pycphy.foamCaseDeveloper.config import control_config
|
12
|
+
from pycphy.foamCaseDeveloper.config import turbulence_config
|
13
|
+
"""
|
14
|
+
|
15
|
+
# Import all config modules
|
16
|
+
from . import global_config
|
17
|
+
from . import block_mesh_config
|
18
|
+
from . import control_config
|
19
|
+
from . import turbulence_config
|
20
|
+
|
21
|
+
__all__ = [
|
22
|
+
"global_config",
|
23
|
+
"block_mesh_config",
|
24
|
+
"control_config",
|
25
|
+
"turbulence_config",
|
26
|
+
]
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# block_mesh_config.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** User Input Configuration for blockMeshDict Generation ***
|
5
|
+
# =============================================================================
|
6
|
+
#
|
7
|
+
# Modify the values in this file to define the desired geometry,
|
8
|
+
# mesh resolution, and boundary patch names.
|
9
|
+
#
|
10
|
+
|
11
|
+
# --- 1. Geometry Definition ---
|
12
|
+
|
13
|
+
# `p0`: The minimum corner of the computational domain (x_min, y_min, z_min).
|
14
|
+
# This defines the bottom-left-front corner of the geometry.
|
15
|
+
# Example: (0.0, 0.0, 0.0) for a domain starting at the origin
|
16
|
+
p0 = (0.0, 0.0, 0.0)
|
17
|
+
|
18
|
+
# `p1`: The maximum corner of the computational domain (x_max, y_max, z_max).
|
19
|
+
# This defines the top-right-back corner of the geometry.
|
20
|
+
# Example: (0.5, 0.2, 0.1) for a channel 0.5m long, 0.2m wide, 0.1m high
|
21
|
+
p1 = (0.5, 0.2, 0.1)
|
22
|
+
|
23
|
+
# --- 2. Meshing Parameters ---
|
24
|
+
|
25
|
+
# `cells`: Number of cells in each direction (nx, ny, nz).
|
26
|
+
# This determines the mesh resolution. Higher numbers = finer mesh = longer computation time.
|
27
|
+
# Example: (50, 20, 50) means 50 cells in x-direction, 20 in y-direction, 50 in z-direction
|
28
|
+
# Total cells = nx * ny * nz = 50 * 20 * 50 = 50,000 cells
|
29
|
+
cells = (50, 20, 50)
|
30
|
+
|
31
|
+
# `scale`: Scaling factor for the mesh coordinates.
|
32
|
+
# Usually set to 1.0 for actual dimensions. Use other values to scale the entire geometry.
|
33
|
+
# Example: 1.0 for meters, 0.001 for millimeters, 1000 for kilometers
|
34
|
+
scale = 1.0
|
35
|
+
|
36
|
+
# --- 3. Boundary Patch Names ---
|
37
|
+
|
38
|
+
# `patch_names`: Dictionary mapping geometric faces to boundary patch names.
|
39
|
+
# These names will be used in boundary condition files and OpenFOAM dictionaries.
|
40
|
+
#
|
41
|
+
# Face identifiers:
|
42
|
+
# 'minX': Face at minimum X (x = p0[0])
|
43
|
+
# 'maxX': Face at maximum X (x = p1[0])
|
44
|
+
# 'minY': Face at minimum Y (y = p0[1])
|
45
|
+
# 'maxY': Face at maximum Y (y = p1[1])
|
46
|
+
# 'minZ': Face at minimum Z (z = p0[2])
|
47
|
+
# 'maxZ': Face at maximum Z (z = p1[2])
|
48
|
+
#
|
49
|
+
# Common patch types in OpenFOAM:
|
50
|
+
# - 'patch': General boundary patch
|
51
|
+
# - 'wall': Solid wall boundary
|
52
|
+
# - 'symmetryPlane': Symmetry boundary
|
53
|
+
# - 'empty': 2D simulation (front/back faces)
|
54
|
+
#
|
55
|
+
# Example for channel flow:
|
56
|
+
patch_names = {
|
57
|
+
'minX': 'inlet', # Inlet face (flow enters here)
|
58
|
+
'maxX': 'outlet', # Outlet face (flow exits here)
|
59
|
+
'minY': 'frontWall', # Front wall (solid boundary)
|
60
|
+
'maxY': 'backWall', # Back wall (solid boundary)
|
61
|
+
'minZ': 'floor', # Floor (solid boundary)
|
62
|
+
'maxZ': 'ceiling' # Ceiling (solid boundary)
|
63
|
+
}
|
64
|
+
|
65
|
+
# --- 4. Advanced Meshing Options ---
|
66
|
+
|
67
|
+
# `grading`: Cell size grading for each direction.
|
68
|
+
# Controls how cell sizes change across the domain.
|
69
|
+
# Example: (1, 1, 1) for uniform cells, (2, 1, 0.5) for graded cells
|
70
|
+
# Note: These are used in the blockMeshDict but not currently exposed in the simple interface
|
71
|
+
grading = (1, 1, 1)
|
72
|
+
|
73
|
+
# `merge_patch_pairs`: List of patch pairs to merge (for periodic boundaries).
|
74
|
+
# Example: [('leftWall', 'rightWall')] to create a periodic boundary
|
75
|
+
# Currently not implemented in the simple interface
|
76
|
+
merge_patch_pairs = []
|
77
|
+
|
78
|
+
# --- 5. Validation Settings ---
|
79
|
+
|
80
|
+
# `min_cell_size`: Minimum allowed cell size (for validation).
|
81
|
+
# Used to prevent extremely small cells that could cause numerical issues.
|
82
|
+
min_cell_size = 1e-6
|
83
|
+
|
84
|
+
# `max_cell_size`: Maximum allowed cell size (for validation).
|
85
|
+
# Used to prevent extremely large cells that could cause accuracy issues.
|
86
|
+
max_cell_size = 1.0
|
87
|
+
|
88
|
+
# `max_total_cells`: Maximum allowed total number of cells (for validation).
|
89
|
+
# Used to prevent creating meshes that are too large for available computational resources.
|
90
|
+
max_total_cells = 1000000
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# control_config.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** User Input for controlDict Parameters ***
|
5
|
+
# =============================================================================
|
6
|
+
#
|
7
|
+
# This file defines the simulation control settings that will be written
|
8
|
+
# to the controlDict file. Modify the values in the `control_params`
|
9
|
+
# dictionary below.
|
10
|
+
#
|
11
|
+
|
12
|
+
control_params = {
|
13
|
+
# --- Solver and Time Control ---
|
14
|
+
|
15
|
+
# `application`: The name of the OpenFOAM solver to be used.
|
16
|
+
# This determines which physics equations will be solved.
|
17
|
+
# Common Options:
|
18
|
+
# 'icoFoam': Incompressible, laminar flow solver
|
19
|
+
# 'simpleFoam': Steady-state, incompressible, turbulent flow solver
|
20
|
+
# 'pimpleFoam': Transient, incompressible, turbulent flow solver
|
21
|
+
# 'interFoam': Two-phase flow solver (VOF method)
|
22
|
+
# 'rhoSimpleFoam': Steady-state, compressible flow solver
|
23
|
+
# 'rhoPimpleFoam': Transient, compressible flow solver
|
24
|
+
# 'buoyantFoam': Natural convection solver
|
25
|
+
"application": "interFoam",
|
26
|
+
|
27
|
+
# `startFrom`: Controls how the simulation starts.
|
28
|
+
# This determines the initial time and data source for the simulation.
|
29
|
+
# Options:
|
30
|
+
# 'startTime': Starts from the time specified in 'startTime'. (Most common)
|
31
|
+
# 'firstTime': Starts from the earliest time-step directory found in the case.
|
32
|
+
# 'latestTime': Starts from the latest time-step directory. (For restarting)
|
33
|
+
"startFrom": "startTime",
|
34
|
+
|
35
|
+
# `startTime`: The simulation time to start from. Usually 0 for a new run.
|
36
|
+
# This is the initial time value for the simulation.
|
37
|
+
# Example: 0.0 for starting from t=0, 1.5 for restarting from t=1.5
|
38
|
+
"startTime": 0,
|
39
|
+
|
40
|
+
# `stopAt`: The condition that will end the simulation.
|
41
|
+
# This determines when the solver will stop running.
|
42
|
+
# Options:
|
43
|
+
# 'endTime': Stops when the simulation time reaches 'endTime'. (Most common)
|
44
|
+
# 'writeNow': Writes the current time step and then stops.
|
45
|
+
# 'noWriteNow': Stops immediately without writing.
|
46
|
+
# 'runTime': Stops after a specified wall-clock time (in seconds).
|
47
|
+
"stopAt": "endTime",
|
48
|
+
|
49
|
+
# `endTime`: The simulation time to stop at.
|
50
|
+
# This is the final time value for the simulation.
|
51
|
+
# Example: 1.0 for running until t=1.0 seconds
|
52
|
+
"endTime": 1.0,
|
53
|
+
|
54
|
+
# `deltaT`: The time step (Δt) for the simulation. This is a critical
|
55
|
+
# parameter for numerical stability and accuracy.
|
56
|
+
# Smaller values = more stable but slower computation.
|
57
|
+
# Larger values = faster but potentially unstable.
|
58
|
+
# Typical range: 1e-6 to 1e-2 depending on the problem
|
59
|
+
"deltaT": 0.001,
|
60
|
+
|
61
|
+
# --- Data Output (Write) Control ---
|
62
|
+
|
63
|
+
# `writeControl`: Determines how often results are written to disk.
|
64
|
+
# This controls the frequency of data output during the simulation.
|
65
|
+
# Options:
|
66
|
+
# 'adjustableRunTime': Writes at intervals of simulation time specified by
|
67
|
+
# 'writeInterval', adjusting to match a multiple of deltaT. (Recommended)
|
68
|
+
# 'runTime': Writes at intervals of simulation time, may not align with deltaT.
|
69
|
+
# 'timeStep': Writes every N time steps, where N is 'writeInterval'.
|
70
|
+
# 'cpuTime': Writes at intervals of CPU time (wall-clock seconds).
|
71
|
+
"writeControl": "adjustableRunTime",
|
72
|
+
|
73
|
+
# `writeInterval`: The frequency of writing data. Its meaning depends on 'writeControl'.
|
74
|
+
# For 'adjustableRunTime' or 'runTime': seconds of simulation time
|
75
|
+
# For 'timeStep': integer number of steps
|
76
|
+
# For 'cpuTime': wall-clock seconds
|
77
|
+
# Example: 0.05 means write every 0.05 seconds of simulation time
|
78
|
+
"writeInterval": 0.05,
|
79
|
+
|
80
|
+
# `purgeWrite`: Cleans up old time-step directories to save disk space.
|
81
|
+
# This prevents the case directory from becoming too large.
|
82
|
+
# Options:
|
83
|
+
# 0: Keep all saved time steps (default, uses more disk space)
|
84
|
+
# N > 0: Keep only the latest N time-step directories
|
85
|
+
# Example: 5 means keep only the latest 5 time directories
|
86
|
+
"purgeWrite": 0,
|
87
|
+
|
88
|
+
# `writeFormat`: The format for the output data files.
|
89
|
+
# This affects file size and read/write speed.
|
90
|
+
# Options:
|
91
|
+
# 'ascii': Human-readable text format. Good for debugging, larger file sizes.
|
92
|
+
# 'binary': Machine-readable binary format. Smaller files, faster I/O.
|
93
|
+
"writeFormat": "ascii",
|
94
|
+
|
95
|
+
# `writePrecision`: Number of significant figures for data in 'ascii' format.
|
96
|
+
# Higher precision = larger files but more accurate output.
|
97
|
+
# Typical range: 6-12 digits
|
98
|
+
"writePrecision": 6,
|
99
|
+
|
100
|
+
# `writeCompression`: Compresses the output files to save space.
|
101
|
+
# This reduces disk usage but may slow down I/O slightly.
|
102
|
+
# Options: 'on' (or 'compressed'), 'off' (or 'uncompressed')
|
103
|
+
"writeCompression": "off",
|
104
|
+
|
105
|
+
# `timeFormat`: The format used for the names of the time-step directories.
|
106
|
+
# This affects how time directories are named and sorted.
|
107
|
+
# Options: 'general', 'fixed', 'scientific'. 'general' is usually best.
|
108
|
+
"timeFormat": "general",
|
109
|
+
|
110
|
+
# `timePrecision`: Number of significant figures for the time-step directory names.
|
111
|
+
# This affects the precision of time directory names.
|
112
|
+
# Typical range: 6-12 digits
|
113
|
+
"timePrecision": 6,
|
114
|
+
|
115
|
+
# --- Run-Time Modification and Time-Step Adjustment ---
|
116
|
+
|
117
|
+
# `runTimeModifiable`: Allows dictionaries (like this one) to be re-read
|
118
|
+
# and updated while the simulation is running.
|
119
|
+
# This is very useful for adjusting parameters during long simulations.
|
120
|
+
# Options: 'yes' (or 'true'), 'no' (or 'false')
|
121
|
+
"runTimeModifiable": "yes",
|
122
|
+
|
123
|
+
# `adjustTimeStep`: Enables automatic time-step adjustment to meet criteria
|
124
|
+
# like the Courant number (`maxCo`).
|
125
|
+
# This is essential for many simulations to maintain stability.
|
126
|
+
# Options: 'on' (or 'yes'), 'off' (or 'no')
|
127
|
+
"adjustTimeStep": "on",
|
128
|
+
|
129
|
+
# `maxCo`: The maximum allowable Courant number. If 'adjustTimeStep' is on,
|
130
|
+
# the solver will reduce 'deltaT' to ensure the Courant number does not
|
131
|
+
# exceed this value. A value of < 1 is required for many solvers.
|
132
|
+
# Typical range: 0.1 to 1.0 (lower = more stable but slower)
|
133
|
+
"maxCo": 1,
|
134
|
+
|
135
|
+
# `maxAlphaCo`: Similar to `maxCo`, but specifically for the interface-capturing
|
136
|
+
# part of multiphase solvers like 'interFoam'.
|
137
|
+
# This controls the stability of the volume fraction equation.
|
138
|
+
# Typical range: 0.1 to 1.0
|
139
|
+
"maxAlphaCo": 1,
|
140
|
+
|
141
|
+
# `maxDeltaT`: An absolute maximum limit for the time step, regardless of
|
142
|
+
# the Courant number. Prevents the time step from becoming excessively large.
|
143
|
+
# This is a safety measure to prevent numerical instability.
|
144
|
+
# Example: 1.0 means time step will never exceed 1.0 seconds
|
145
|
+
"maxDeltaT": 1,
|
146
|
+
|
147
|
+
# --- Additional Solver-Specific Parameters ---
|
148
|
+
|
149
|
+
# `nCorrectors`: Number of pressure correction iterations (for PIMPLE algorithm).
|
150
|
+
# Used by pimpleFoam and similar solvers.
|
151
|
+
# Typical range: 1-5 (higher = more accurate but slower)
|
152
|
+
"nCorrectors": 2,
|
153
|
+
|
154
|
+
# `nNonOrthogonalCorrectors`: Number of non-orthogonal correction iterations.
|
155
|
+
# Used to improve accuracy on non-orthogonal meshes.
|
156
|
+
# Typical range: 0-3 (higher = more accurate but slower)
|
157
|
+
"nNonOrthogonalCorrectors": 0,
|
158
|
+
|
159
|
+
# `pRefCell`: Reference pressure cell (for pressure field).
|
160
|
+
# Used to set the reference pressure in the pressure field.
|
161
|
+
# Example: 0 (uses cell 0 as reference)
|
162
|
+
"pRefCell": 0,
|
163
|
+
|
164
|
+
# `pRefValue`: Reference pressure value (for pressure field).
|
165
|
+
# The pressure value at the reference cell.
|
166
|
+
# Example: 0.0 (atmospheric pressure reference)
|
167
|
+
"pRefValue": 0.0
|
168
|
+
}
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# global_config.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** Global Configuration for pycphy foamCaseDeveloper ***
|
5
|
+
# =============================================================================
|
6
|
+
#
|
7
|
+
# This file contains global settings and case information that applies
|
8
|
+
# to the entire OpenFOAM case setup process.
|
9
|
+
#
|
10
|
+
|
11
|
+
# --- Case Information ---
|
12
|
+
|
13
|
+
# `case_name`: The name of the OpenFOAM case directory to be created.
|
14
|
+
# This will be the main directory containing all case files.
|
15
|
+
case_name = "channelFlow"
|
16
|
+
|
17
|
+
# `case_description`: A brief description of the simulation case.
|
18
|
+
# This is used for documentation and logging purposes.
|
19
|
+
case_description = "Channel flow simulation with RAS turbulence model"
|
20
|
+
|
21
|
+
# `author_name`: Name of the person creating this case.
|
22
|
+
author_name = "Sanjeev Bashyal"
|
23
|
+
|
24
|
+
# `author_email`: Email contact for the case author.
|
25
|
+
author_email = "sanjeev.bashyal@example.com"
|
26
|
+
|
27
|
+
# `creation_date`: Date when the case was created (automatically set).
|
28
|
+
# Format: YYYY-MM-DD
|
29
|
+
creation_date = "2025-01-09"
|
30
|
+
|
31
|
+
# --- Output Configuration ---
|
32
|
+
|
33
|
+
# `output_directory`: The base directory where the case will be created.
|
34
|
+
# Use "." for current directory, or specify a full path.
|
35
|
+
output_directory = "."
|
36
|
+
|
37
|
+
# `overwrite_existing`: Whether to overwrite an existing case directory.
|
38
|
+
# Options: True (overwrite), False (create with suffix if exists)
|
39
|
+
overwrite_existing = True
|
40
|
+
|
41
|
+
# `create_backup`: Whether to create a backup of existing case before overwriting.
|
42
|
+
# Only applies when overwrite_existing = True
|
43
|
+
create_backup = False
|
44
|
+
|
45
|
+
# --- Logging and Verbosity ---
|
46
|
+
|
47
|
+
# `verbose_output`: Enable detailed output during case creation.
|
48
|
+
# Options: True (detailed), False (minimal)
|
49
|
+
verbose_output = True
|
50
|
+
|
51
|
+
# `log_to_file`: Whether to save case creation log to a file.
|
52
|
+
log_to_file = True
|
53
|
+
|
54
|
+
# `log_filename`: Name of the log file (if log_to_file = True).
|
55
|
+
log_filename = "case_creation.log"
|
56
|
+
|
57
|
+
# --- Validation Settings ---
|
58
|
+
|
59
|
+
# `validate_geometry`: Enable geometry validation before mesh generation.
|
60
|
+
# Checks for valid dimensions, positive cell counts, etc.
|
61
|
+
validate_geometry = True
|
62
|
+
|
63
|
+
# `validate_control`: Enable control parameter validation.
|
64
|
+
# Checks for valid solver names, time parameters, etc.
|
65
|
+
validate_control = True
|
66
|
+
|
67
|
+
# `validate_turbulence`: Enable turbulence model validation.
|
68
|
+
# Checks for valid model names and parameters.
|
69
|
+
validate_turbulence = True
|
70
|
+
|
71
|
+
# --- Advanced Options ---
|
72
|
+
|
73
|
+
# `auto_create_directories`: Automatically create necessary directories.
|
74
|
+
# Options: True (auto-create), False (fail if directories don't exist)
|
75
|
+
auto_create_directories = True
|
76
|
+
|
77
|
+
# `cleanup_on_failure`: Remove partially created case files if setup fails.
|
78
|
+
# Options: True (cleanup), False (keep partial files for debugging)
|
79
|
+
cleanup_on_failure = True
|
80
|
+
|
81
|
+
# `parallel_processing`: Enable parallel processing for large cases.
|
82
|
+
# Currently not implemented, reserved for future use.
|
83
|
+
parallel_processing = False
|
@@ -0,0 +1,187 @@
|
|
1
|
+
# turbulence_config.py
|
2
|
+
|
3
|
+
# =============================================================================
|
4
|
+
# *** User Input for turbulenceProperties ***
|
5
|
+
# =============================================================================
|
6
|
+
#
|
7
|
+
# This file defines the turbulence model settings.
|
8
|
+
# 1. Set the SIMULATION_TYPE variable to 'RAS', 'LES', or 'laminar'.
|
9
|
+
# 2. Edit the corresponding properties dictionary below if needed.
|
10
|
+
#
|
11
|
+
|
12
|
+
# `SIMULATION_TYPE`: The type of turbulence simulation to perform.
|
13
|
+
# This determines which turbulence model will be used.
|
14
|
+
# Options:
|
15
|
+
# 'RAS': Reynolds-Averaged Simulation (steady or unsteady, computationally efficient)
|
16
|
+
# 'LES': Large Eddy Simulation (unsteady, more detailed but computationally expensive)
|
17
|
+
# 'laminar': Laminar flow (no turbulence model, for low Reynolds number flows)
|
18
|
+
SIMULATION_TYPE = "RAS"
|
19
|
+
|
20
|
+
# --- Reynolds-Averaged Simulation (RAS) Properties ---
|
21
|
+
# RAS models solve the Reynolds-averaged Navier-Stokes equations and model
|
22
|
+
# the effects of turbulence using statistical models. They are computationally
|
23
|
+
# less expensive and are suitable for many steady-state industrial flows.
|
24
|
+
|
25
|
+
RAS_PROPERTIES = {
|
26
|
+
# `RASModel`: Specifies the turbulence model to use.
|
27
|
+
# This determines how the Reynolds stresses are modeled.
|
28
|
+
# Common Options:
|
29
|
+
# 'kEpsilon': Standard k-epsilon model. Robust but less accurate for separated flows.
|
30
|
+
# Good for free shear flows, mixing layers, and jets.
|
31
|
+
# 'realizableKE': A variation of k-epsilon with better performance for rotating flows.
|
32
|
+
# Improved handling of adverse pressure gradients.
|
33
|
+
# 'kOmegaSST': Menter's Shear Stress Transport model. Very popular, blends k-w
|
34
|
+
# near walls and k-e in the far-field. Excellent for aerodynamics
|
35
|
+
# and complex flows with separation.
|
36
|
+
# 'SpalartAllmaras': One-equation model. Good for aerospace applications.
|
37
|
+
# Particularly effective for attached flows.
|
38
|
+
"RASModel": "kOmegaSST",
|
39
|
+
|
40
|
+
# `turbulence`: A switch to turn the turbulence calculations on or off.
|
41
|
+
# This allows you to run laminar simulations with RAS setup.
|
42
|
+
# Options: 'on' (turbulence active), 'off' (laminar simulation)
|
43
|
+
"turbulence": "on",
|
44
|
+
|
45
|
+
# `printCoeffs`: Prints the model coefficients to the log file at the start.
|
46
|
+
# This is useful for debugging and verifying model settings.
|
47
|
+
# Options: 'on' (print coefficients), 'off' (don't print)
|
48
|
+
"printCoeffs": "on",
|
49
|
+
|
50
|
+
# Additional RAS model coefficients (advanced users only)
|
51
|
+
# These can be used to modify the default model coefficients if needed.
|
52
|
+
# Most users should not modify these unless they understand the model physics.
|
53
|
+
|
54
|
+
# `kEpsilonCoeffs`: Coefficients for k-epsilon models (if using kEpsilon or realizableKE)
|
55
|
+
# "kEpsilonCoeffs": {
|
56
|
+
# "Cmu": 0.09, # Turbulent viscosity coefficient
|
57
|
+
# "C1": 1.44, # Production coefficient
|
58
|
+
# "C2": 1.92, # Destruction coefficient
|
59
|
+
# "C3": -0.33, # Buoyancy coefficient
|
60
|
+
# "sigmap": 1.0, # Prandtl number for pressure
|
61
|
+
# "sigmak": 1.0, # Prandtl number for k
|
62
|
+
# "sigmaEps": 1.3 # Prandtl number for epsilon
|
63
|
+
# },
|
64
|
+
|
65
|
+
# `kOmegaSSTCoeffs`: Coefficients for k-omega SST model (if using kOmegaSST)
|
66
|
+
# "kOmegaSSTCoeffs": {
|
67
|
+
# "beta1": 0.075, # Beta coefficient for k equation
|
68
|
+
# "beta2": 0.0828, # Beta coefficient for omega equation
|
69
|
+
# "betaStar": 0.09, # Beta star coefficient
|
70
|
+
# "gamma1": 0.5532, # Gamma coefficient for k equation
|
71
|
+
# "gamma2": 0.4403, # Gamma coefficient for omega equation
|
72
|
+
# "alphaK1": 0.85, # Alpha coefficient for k equation
|
73
|
+
# "alphaK2": 1.0, # Alpha coefficient for k equation
|
74
|
+
# "alphaOmega1": 0.5, # Alpha coefficient for omega equation
|
75
|
+
# "alphaOmega2": 0.856, # Alpha coefficient for omega equation
|
76
|
+
# "Prt": 0.9 # Turbulent Prandtl number
|
77
|
+
# }
|
78
|
+
}
|
79
|
+
|
80
|
+
# --- Large Eddy Simulation (LES) Properties ---
|
81
|
+
# LES resolves the large, energy-containing eddies directly and models the
|
82
|
+
# smaller ones using sub-grid scale (SGS) models. It is more computationally
|
83
|
+
# expensive than RAS but provides more detail on transient turbulent structures.
|
84
|
+
|
85
|
+
LES_PROPERTIES = {
|
86
|
+
# `LESModel`: Specifies the sub-grid scale (SGS) model for LES.
|
87
|
+
# This determines how the unresolved small-scale turbulence is modeled.
|
88
|
+
# Common Options:
|
89
|
+
# 'Smagorinsky': The classic SGS model. Simple and robust but can be
|
90
|
+
# overly dissipative near walls.
|
91
|
+
# 'kEqn': One-equation eddy-viscosity model. Solves an equation for
|
92
|
+
# sub-grid scale kinetic energy. More accurate than Smagorinsky.
|
93
|
+
# 'WALE': Wall-Adapting Local Eddy-viscosity model. Better near-wall
|
94
|
+
# behavior than Smagorinsky.
|
95
|
+
# 'dynamicKEqn': Dynamic version of kEqn model. Coefficients are
|
96
|
+
# computed dynamically, more accurate but computationally expensive.
|
97
|
+
"LESModel": "kEqn",
|
98
|
+
|
99
|
+
# `turbulence`: A switch to turn the turbulence calculations on or off.
|
100
|
+
# Options: 'on' (LES active), 'off' (laminar simulation)
|
101
|
+
"turbulence": "on",
|
102
|
+
|
103
|
+
# `printCoeffs`: Prints the model coefficients to the log file at the start.
|
104
|
+
# Options: 'on' (print coefficients), 'off' (don't print)
|
105
|
+
"printCoeffs": "on",
|
106
|
+
|
107
|
+
# `delta`: The model for the LES filter width.
|
108
|
+
# This determines how the characteristic length scale is calculated.
|
109
|
+
# Common Options:
|
110
|
+
# 'cubeRootVol': Based on the cell volume. (Most common and recommended)
|
111
|
+
# 'vanDriest': Wall-damping model. Reduces filter width near walls.
|
112
|
+
# 'smooth': Smoothing for the delta field. Helps with mesh sensitivity.
|
113
|
+
"delta": "smooth",
|
114
|
+
|
115
|
+
# Each delta model and some LES models have their own coefficient sub-dictionaries.
|
116
|
+
# The structure below is an example for the kEqn model with smooth delta.
|
117
|
+
|
118
|
+
# `cubeRootVolCoeffs`: Coefficients for cubeRootVol delta model
|
119
|
+
"cubeRootVolCoeffs": {
|
120
|
+
# `deltaCoeff`: Coefficient for the filter width calculation.
|
121
|
+
# Typical range: 0.5 to 2.0. Higher values = larger filter width.
|
122
|
+
"deltaCoeff": 1
|
123
|
+
},
|
124
|
+
|
125
|
+
# `smoothCoeffs`: Coefficients for smooth delta model
|
126
|
+
"smoothCoeffs": {
|
127
|
+
# `delta`: The base delta model to use for smoothing.
|
128
|
+
"delta": "cubeRootVol",
|
129
|
+
|
130
|
+
# `cubeRootVolCoeffs`: Coefficients for the base delta model
|
131
|
+
"cubeRootVolCoeffs": {
|
132
|
+
"deltaCoeff": 1
|
133
|
+
},
|
134
|
+
|
135
|
+
# `maxDeltaRatio`: Maximum ratio between adjacent delta values.
|
136
|
+
# This prevents large jumps in filter width between cells.
|
137
|
+
# Typical range: 1.1 to 1.5
|
138
|
+
"maxDeltaRatio": 1.1
|
139
|
+
},
|
140
|
+
|
141
|
+
# Additional LES model coefficients (advanced users only)
|
142
|
+
# `kEqnCoeffs`: Coefficients for kEqn LES model (if using kEqn)
|
143
|
+
# "kEqnCoeffs": {
|
144
|
+
# "Ck": 0.094, # Model coefficient
|
145
|
+
# "Ce": 1.048 # Dissipation coefficient
|
146
|
+
# },
|
147
|
+
|
148
|
+
# `SmagorinskyCoeffs`: Coefficients for Smagorinsky model (if using Smagorinsky)
|
149
|
+
# "SmagorinskyCoeffs": {
|
150
|
+
# "Ck": 0.094 # Smagorinsky constant
|
151
|
+
# },
|
152
|
+
|
153
|
+
# `WALECoeffs`: Coefficients for WALE model (if using WALE)
|
154
|
+
# "WALECoeffs": {
|
155
|
+
# "Cw": 0.325 # WALE constant
|
156
|
+
# }
|
157
|
+
|
158
|
+
# Add other coefficient dictionaries like 'vanDriestCoeffs' if your model needs them.
|
159
|
+
}
|
160
|
+
|
161
|
+
# --- Laminar Simulation Properties ---
|
162
|
+
# For flows at low Reynolds numbers where turbulence is not present.
|
163
|
+
# The dictionary is typically empty as no turbulence modeling is required.
|
164
|
+
|
165
|
+
LAMINAR_PROPERTIES = {
|
166
|
+
# For laminar flows, no turbulence model coefficients are needed.
|
167
|
+
# This dictionary is kept for consistency but should remain empty.
|
168
|
+
# If you need to add any laminar-specific parameters in the future,
|
169
|
+
# they would go here.
|
170
|
+
}
|
171
|
+
|
172
|
+
# --- Additional Turbulence Settings ---
|
173
|
+
|
174
|
+
# `turbulenceOn`: Global switch for turbulence calculations.
|
175
|
+
# This can be used to quickly disable turbulence for testing.
|
176
|
+
# Options: True (turbulence active), False (laminar simulation)
|
177
|
+
turbulenceOn = True
|
178
|
+
|
179
|
+
# `turbulenceCorrected`: Enable turbulence corrections for better accuracy.
|
180
|
+
# This is useful for complex geometries and flow conditions.
|
181
|
+
# Options: True (enable corrections), False (disable corrections)
|
182
|
+
turbulenceCorrected = True
|
183
|
+
|
184
|
+
# `turbulenceDebug`: Enable debug output for turbulence calculations.
|
185
|
+
# This provides detailed information about turbulence model behavior.
|
186
|
+
# Options: True (debug on), False (debug off)
|
187
|
+
turbulenceDebug = False
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"""
|
2
|
+
Core functionality for OpenFOAM case development.
|
3
|
+
|
4
|
+
This module contains the main classes for managing OpenFOAM cases,
|
5
|
+
including mesh generation, control setup, and case management.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from .block_mesh_developer import BlockMeshDeveloper
|
9
|
+
from .control_dict_writer import ControlDictWriter
|
10
|
+
from .turbulence_properties_writer import TurbulencePropertiesWriter
|
11
|
+
from .foam_case_manager import FoamCaseManager
|
12
|
+
|
13
|
+
__all__ = [
|
14
|
+
"BlockMeshDeveloper",
|
15
|
+
"ControlDictWriter",
|
16
|
+
"TurbulencePropertiesWriter",
|
17
|
+
"FoamCaseManager",
|
18
|
+
]
|