pycphy 0.1.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.
- pycphy-0.1.0/LICENSE +21 -0
- pycphy-0.1.0/MANIFEST.in +7 -0
- pycphy-0.1.0/PKG-INFO +335 -0
- pycphy-0.1.0/README.md +290 -0
- pycphy-0.1.0/pycphy/__init__.py +24 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/__init__.py +41 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/config/__init__.py +26 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/config/block_mesh_config.py +90 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/config/control_config.py +168 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/config/global_config.py +83 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/config/turbulence_config.py +187 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/core/__init__.py +18 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/core/block_mesh_developer.py +101 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/core/control_dict_writer.py +55 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/core/foam_case_manager.py +195 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/core/turbulence_properties_writer.py +68 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/main.py +260 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/writers/__init__.py +18 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/writers/block_mesh_writer.py +113 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/writers/control_dict_writer.py +54 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/writers/foam_writer.py +73 -0
- pycphy-0.1.0/pycphy/foamCaseDeveloper/writers/turbulence_properties_writer.py +78 -0
- pycphy-0.1.0/pycphy.egg-info/PKG-INFO +335 -0
- pycphy-0.1.0/pycphy.egg-info/SOURCES.txt +30 -0
- pycphy-0.1.0/pycphy.egg-info/dependency_links.txt +1 -0
- pycphy-0.1.0/pycphy.egg-info/entry_points.txt +2 -0
- pycphy-0.1.0/pycphy.egg-info/requires.txt +14 -0
- pycphy-0.1.0/pycphy.egg-info/top_level.txt +1 -0
- pycphy-0.1.0/pyproject.toml +87 -0
- pycphy-0.1.0/requirements.txt +4 -0
- pycphy-0.1.0/setup.cfg +4 -0
- pycphy-0.1.0/setup.py +78 -0
pycphy-0.1.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Sanjeev Bashyal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
pycphy-0.1.0/MANIFEST.in
ADDED
pycphy-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,335 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pycphy
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Python: Computational Physics - Tools for physics dynamics simulation
|
5
|
+
Home-page: https://github.com/SanjeevBashyal/pycphy
|
6
|
+
Author: Sanjeev Bashyal
|
7
|
+
Author-email: Sanjeev Bashyal <sanjeev.bashyal@example.com>
|
8
|
+
Maintainer-email: Sanjeev Bashyal <sanjeev.bashyal@example.com>
|
9
|
+
License: MIT
|
10
|
+
Project-URL: Homepage, https://github.com/SanjeevBashyal/pycphy
|
11
|
+
Project-URL: Repository, https://github.com/SanjeevBashyal/pycphy
|
12
|
+
Project-URL: Documentation, https://github.com/SanjeevBashyal/pycphy#readme
|
13
|
+
Project-URL: Bug Tracker, https://github.com/SanjeevBashyal/pycphy/issues
|
14
|
+
Keywords: computational physics,simulation,openfoam,cfd,physics
|
15
|
+
Classifier: Development Status :: 3 - Alpha
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
17
|
+
Classifier: Operating System :: OS Independent
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
19
|
+
Classifier: Programming Language :: Python :: 3.7
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
26
|
+
Requires-Python: >=3.7
|
27
|
+
Description-Content-Type: text/markdown
|
28
|
+
License-File: LICENSE
|
29
|
+
Requires-Dist: numpy>=1.19.0
|
30
|
+
Requires-Dist: scipy>=1.6.0
|
31
|
+
Requires-Dist: matplotlib>=3.3.0
|
32
|
+
Provides-Extra: dev
|
33
|
+
Requires-Dist: pytest>=6.0; extra == "dev"
|
34
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
35
|
+
Requires-Dist: black; extra == "dev"
|
36
|
+
Requires-Dist: flake8; extra == "dev"
|
37
|
+
Requires-Dist: mypy; extra == "dev"
|
38
|
+
Provides-Extra: docs
|
39
|
+
Requires-Dist: sphinx; extra == "docs"
|
40
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
41
|
+
Dynamic: author
|
42
|
+
Dynamic: home-page
|
43
|
+
Dynamic: license-file
|
44
|
+
Dynamic: requires-python
|
45
|
+
|
46
|
+
# pycphy
|
47
|
+
|
48
|
+
**Python: Computational Physics**
|
49
|
+
|
50
|
+
A comprehensive Python package for computational physics simulations and tools, with a focus on OpenFOAM case development and management.
|
51
|
+
|
52
|
+
**Author:** Sanjeev Bashyal
|
53
|
+
**Repository:** [https://github.com/SanjeevBashyal/pycphy](https://github.com/SanjeevBashyal/pycphy)
|
54
|
+
|
55
|
+
## Overview
|
56
|
+
|
57
|
+
`pycphy` is a Python package designed to provide tools and utilities for computational physics simulations. The package currently includes the `foamCaseDeveloper` module, which offers comprehensive tools for creating and managing OpenFOAM CFD simulation cases.
|
58
|
+
|
59
|
+
## Features
|
60
|
+
|
61
|
+
### foamCaseDeveloper Module
|
62
|
+
|
63
|
+
The `foamCaseDeveloper` module provides:
|
64
|
+
|
65
|
+
- **BlockMesh Generation**: Create OpenFOAM blockMeshDict files with custom geometries
|
66
|
+
- **Control Dictionary Setup**: Configure solver settings, time control, and output parameters
|
67
|
+
- **Turbulence Model Configuration**: Set up RAS, LES, and laminar turbulence models
|
68
|
+
- **Complete Case Management**: Automatically create complete OpenFOAM case directories
|
69
|
+
- **Validation and Error Checking**: Built-in validation for all configuration parameters
|
70
|
+
|
71
|
+
## Installation
|
72
|
+
|
73
|
+
### From Source
|
74
|
+
|
75
|
+
```bash
|
76
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
77
|
+
cd pycphy
|
78
|
+
pip install -e .
|
79
|
+
```
|
80
|
+
|
81
|
+
### Development Installation
|
82
|
+
|
83
|
+
```bash
|
84
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
85
|
+
cd pycphy
|
86
|
+
pip install -e ".[dev]"
|
87
|
+
```
|
88
|
+
|
89
|
+
## Quick Start
|
90
|
+
|
91
|
+
### Using the Command Line Interface
|
92
|
+
|
93
|
+
```bash
|
94
|
+
# Create an example case
|
95
|
+
pycphy-foam --example
|
96
|
+
|
97
|
+
# Create a custom case from configuration files
|
98
|
+
pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
|
99
|
+
```
|
100
|
+
|
101
|
+
### Using Python API
|
102
|
+
|
103
|
+
```python
|
104
|
+
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig
|
105
|
+
|
106
|
+
# Create a case manager
|
107
|
+
case_manager = FoamCaseManager("myCase")
|
108
|
+
|
109
|
+
# Set up geometry
|
110
|
+
geometry_config = BlockMeshConfig(
|
111
|
+
p0=(0.0, 0.0, 0.0),
|
112
|
+
p1=(1.0, 1.0, 1.0),
|
113
|
+
cells=(50, 50, 50),
|
114
|
+
patch_names={
|
115
|
+
'minX': 'inlet',
|
116
|
+
'maxX': 'outlet',
|
117
|
+
'minY': 'frontWall',
|
118
|
+
'maxY': 'backWall',
|
119
|
+
'minZ': 'floor',
|
120
|
+
'maxZ': 'ceiling'
|
121
|
+
}
|
122
|
+
)
|
123
|
+
|
124
|
+
case_manager.setup_geometry(
|
125
|
+
p0=geometry_config.p0,
|
126
|
+
p1=geometry_config.p1,
|
127
|
+
cells=geometry_config.cells,
|
128
|
+
patch_names=geometry_config.patch_names
|
129
|
+
)
|
130
|
+
|
131
|
+
# Set up control
|
132
|
+
control_config = ControlConfig()
|
133
|
+
control_config.set_solver("interFoam")
|
134
|
+
control_config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
135
|
+
|
136
|
+
case_manager.setup_control(control_config.get_parameters())
|
137
|
+
|
138
|
+
# Set up turbulence
|
139
|
+
turbulence_config = TurbulenceConfig("RAS")
|
140
|
+
turbulence_config.set_ras_model("kOmegaSST")
|
141
|
+
|
142
|
+
case_manager.setup_turbulence(
|
143
|
+
simulation_type=turbulence_config.get_simulation_type(),
|
144
|
+
model_properties=turbulence_config.get_model_properties()
|
145
|
+
)
|
146
|
+
|
147
|
+
# Create the complete case
|
148
|
+
case_manager.create_full_case()
|
149
|
+
```
|
150
|
+
|
151
|
+
## Package Structure
|
152
|
+
|
153
|
+
```
|
154
|
+
pycphy/
|
155
|
+
├── __init__.py
|
156
|
+
└── foamCaseDeveloper/
|
157
|
+
├── __init__.py
|
158
|
+
├── main.py # Command-line interface
|
159
|
+
├── core/ # Core functionality
|
160
|
+
│ ├── __init__.py
|
161
|
+
│ ├── foam_case_manager.py # Main case management class
|
162
|
+
│ ├── block_mesh_developer.py # BlockMesh generation
|
163
|
+
│ ├── control_dict_writer.py # Control dictionary writer
|
164
|
+
│ └── turbulence_properties_writer.py # Turbulence properties writer
|
165
|
+
├── writers/ # OpenFOAM dictionary writers
|
166
|
+
│ ├── __init__.py
|
167
|
+
│ ├── foam_writer.py # Base writer class
|
168
|
+
│ ├── block_mesh_writer.py # BlockMesh dictionary writer
|
169
|
+
│ ├── control_dict_writer.py # Control dictionary writer
|
170
|
+
│ └── turbulence_properties_writer.py # Turbulence properties writer
|
171
|
+
└── config/ # Configuration classes
|
172
|
+
├── __init__.py
|
173
|
+
├── block_mesh_config.py # Geometry configuration
|
174
|
+
├── control_config.py # Control configuration
|
175
|
+
└── turbulence_config.py # Turbulence configuration
|
176
|
+
```
|
177
|
+
|
178
|
+
## Configuration
|
179
|
+
|
180
|
+
### Geometry Configuration (BlockMesh)
|
181
|
+
|
182
|
+
```python
|
183
|
+
from pycphy.foamCaseDeveloper import BlockMeshConfig
|
184
|
+
|
185
|
+
config = BlockMeshConfig(
|
186
|
+
p0=(0.0, 0.0, 0.0), # Minimum corner
|
187
|
+
p1=(1.0, 1.0, 1.0), # Maximum corner
|
188
|
+
cells=(50, 50, 50), # Number of cells
|
189
|
+
patch_names={ # Boundary patch names
|
190
|
+
'minX': 'inlet',
|
191
|
+
'maxX': 'outlet',
|
192
|
+
'minY': 'frontWall',
|
193
|
+
'maxY': 'backWall',
|
194
|
+
'minZ': 'floor',
|
195
|
+
'maxZ': 'ceiling'
|
196
|
+
}
|
197
|
+
)
|
198
|
+
```
|
199
|
+
|
200
|
+
### Control Configuration
|
201
|
+
|
202
|
+
```python
|
203
|
+
from pycphy.foamCaseDeveloper import ControlConfig
|
204
|
+
|
205
|
+
config = ControlConfig()
|
206
|
+
config.set_solver("interFoam")
|
207
|
+
config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
208
|
+
config.set_write_control(write_interval=0.05)
|
209
|
+
config.set_courant_control(max_co=1)
|
210
|
+
```
|
211
|
+
|
212
|
+
### Turbulence Configuration
|
213
|
+
|
214
|
+
```python
|
215
|
+
from pycphy.foamCaseDeveloper import TurbulenceConfig
|
216
|
+
|
217
|
+
# RAS configuration
|
218
|
+
ras_config = TurbulenceConfig("RAS")
|
219
|
+
ras_config.set_ras_model("kOmegaSST")
|
220
|
+
|
221
|
+
# LES configuration
|
222
|
+
les_config = TurbulenceConfig("LES")
|
223
|
+
les_config.set_les_model("kEqn")
|
224
|
+
les_config.set_delta_model("smooth")
|
225
|
+
|
226
|
+
# Laminar configuration
|
227
|
+
laminar_config = TurbulenceConfig("laminar")
|
228
|
+
```
|
229
|
+
|
230
|
+
## Examples
|
231
|
+
|
232
|
+
### Channel Flow Case
|
233
|
+
|
234
|
+
```python
|
235
|
+
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig
|
236
|
+
|
237
|
+
# Create channel flow case
|
238
|
+
case_manager = FoamCaseManager("channelFlow")
|
239
|
+
|
240
|
+
# Channel geometry: 0.5m x 0.2m x 0.1m
|
241
|
+
geometry = BlockMeshConfig(
|
242
|
+
p0=(0.0, 0.0, 0.0),
|
243
|
+
p1=(0.5, 0.2, 0.1),
|
244
|
+
cells=(50, 20, 50),
|
245
|
+
patch_names={
|
246
|
+
'minX': 'inlet',
|
247
|
+
'maxX': 'outlet',
|
248
|
+
'minY': 'frontWall',
|
249
|
+
'maxY': 'backWall',
|
250
|
+
'minZ': 'floor',
|
251
|
+
'maxZ': 'ceiling'
|
252
|
+
}
|
253
|
+
)
|
254
|
+
|
255
|
+
case_manager.setup_geometry(
|
256
|
+
p0=geometry.p0, p1=geometry.p1, cells=geometry.cells,
|
257
|
+
patch_names=geometry.patch_names
|
258
|
+
)
|
259
|
+
|
260
|
+
# Set up solver
|
261
|
+
control = ControlConfig()
|
262
|
+
control.set_solver("interFoam")
|
263
|
+
control.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
264
|
+
|
265
|
+
case_manager.setup_control(control.get_parameters())
|
266
|
+
|
267
|
+
# Set up turbulence
|
268
|
+
turbulence = TurbulenceConfig("RAS")
|
269
|
+
turbulence.set_ras_model("kOmegaSST")
|
270
|
+
|
271
|
+
case_manager.setup_turbulence(
|
272
|
+
simulation_type=turbulence.get_simulation_type(),
|
273
|
+
model_properties=turbulence.get_model_properties()
|
274
|
+
)
|
275
|
+
|
276
|
+
# Create the case
|
277
|
+
case_manager.create_full_case()
|
278
|
+
```
|
279
|
+
|
280
|
+
## Requirements
|
281
|
+
|
282
|
+
- Python >= 3.7
|
283
|
+
- NumPy >= 1.19.0
|
284
|
+
- SciPy >= 1.6.0
|
285
|
+
- Matplotlib >= 3.3.0
|
286
|
+
|
287
|
+
## Development
|
288
|
+
|
289
|
+
### Running Tests
|
290
|
+
|
291
|
+
```bash
|
292
|
+
pytest
|
293
|
+
```
|
294
|
+
|
295
|
+
### Code Formatting
|
296
|
+
|
297
|
+
```bash
|
298
|
+
black pycphy/
|
299
|
+
flake8 pycphy/
|
300
|
+
```
|
301
|
+
|
302
|
+
### Building Documentation
|
303
|
+
|
304
|
+
```bash
|
305
|
+
sphinx-build docs/ docs/_build/
|
306
|
+
```
|
307
|
+
|
308
|
+
## Contributing
|
309
|
+
|
310
|
+
1. Fork the repository
|
311
|
+
2. Create a feature branch (`git checkout -b feature/new-feature`)
|
312
|
+
3. Commit your changes (`git commit -am 'Add new feature'`)
|
313
|
+
4. Push to the branch (`git push origin feature/new-feature`)
|
314
|
+
5. Create a Pull Request
|
315
|
+
|
316
|
+
## License
|
317
|
+
|
318
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
319
|
+
|
320
|
+
## Citation
|
321
|
+
|
322
|
+
If you use pycphy in your research, please cite:
|
323
|
+
|
324
|
+
```bibtex
|
325
|
+
@software{bashyal2025pycphy,
|
326
|
+
title={pycphy: Python Computational Physics},
|
327
|
+
author={Bashyal, Sanjeev},
|
328
|
+
year={2025},
|
329
|
+
url={https://github.com/SanjeevBashyal/pycphy}
|
330
|
+
}
|
331
|
+
```
|
332
|
+
|
333
|
+
## Support
|
334
|
+
|
335
|
+
For questions, issues, or contributions, please visit the [GitHub repository](https://github.com/SanjeevBashyal/pycphy).
|
pycphy-0.1.0/README.md
ADDED
@@ -0,0 +1,290 @@
|
|
1
|
+
# pycphy
|
2
|
+
|
3
|
+
**Python: Computational Physics**
|
4
|
+
|
5
|
+
A comprehensive Python package for computational physics simulations and tools, with a focus on OpenFOAM case development and management.
|
6
|
+
|
7
|
+
**Author:** Sanjeev Bashyal
|
8
|
+
**Repository:** [https://github.com/SanjeevBashyal/pycphy](https://github.com/SanjeevBashyal/pycphy)
|
9
|
+
|
10
|
+
## Overview
|
11
|
+
|
12
|
+
`pycphy` is a Python package designed to provide tools and utilities for computational physics simulations. The package currently includes the `foamCaseDeveloper` module, which offers comprehensive tools for creating and managing OpenFOAM CFD simulation cases.
|
13
|
+
|
14
|
+
## Features
|
15
|
+
|
16
|
+
### foamCaseDeveloper Module
|
17
|
+
|
18
|
+
The `foamCaseDeveloper` module provides:
|
19
|
+
|
20
|
+
- **BlockMesh Generation**: Create OpenFOAM blockMeshDict files with custom geometries
|
21
|
+
- **Control Dictionary Setup**: Configure solver settings, time control, and output parameters
|
22
|
+
- **Turbulence Model Configuration**: Set up RAS, LES, and laminar turbulence models
|
23
|
+
- **Complete Case Management**: Automatically create complete OpenFOAM case directories
|
24
|
+
- **Validation and Error Checking**: Built-in validation for all configuration parameters
|
25
|
+
|
26
|
+
## Installation
|
27
|
+
|
28
|
+
### From Source
|
29
|
+
|
30
|
+
```bash
|
31
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
32
|
+
cd pycphy
|
33
|
+
pip install -e .
|
34
|
+
```
|
35
|
+
|
36
|
+
### Development Installation
|
37
|
+
|
38
|
+
```bash
|
39
|
+
git clone https://github.com/SanjeevBashyal/pycphy.git
|
40
|
+
cd pycphy
|
41
|
+
pip install -e ".[dev]"
|
42
|
+
```
|
43
|
+
|
44
|
+
## Quick Start
|
45
|
+
|
46
|
+
### Using the Command Line Interface
|
47
|
+
|
48
|
+
```bash
|
49
|
+
# Create an example case
|
50
|
+
pycphy-foam --example
|
51
|
+
|
52
|
+
# Create a custom case from configuration files
|
53
|
+
pycphy-foam --case myCase --geometry configBlockMesh.py --control configControl.py --turbulence configTurbulence.py
|
54
|
+
```
|
55
|
+
|
56
|
+
### Using Python API
|
57
|
+
|
58
|
+
```python
|
59
|
+
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig
|
60
|
+
|
61
|
+
# Create a case manager
|
62
|
+
case_manager = FoamCaseManager("myCase")
|
63
|
+
|
64
|
+
# Set up geometry
|
65
|
+
geometry_config = BlockMeshConfig(
|
66
|
+
p0=(0.0, 0.0, 0.0),
|
67
|
+
p1=(1.0, 1.0, 1.0),
|
68
|
+
cells=(50, 50, 50),
|
69
|
+
patch_names={
|
70
|
+
'minX': 'inlet',
|
71
|
+
'maxX': 'outlet',
|
72
|
+
'minY': 'frontWall',
|
73
|
+
'maxY': 'backWall',
|
74
|
+
'minZ': 'floor',
|
75
|
+
'maxZ': 'ceiling'
|
76
|
+
}
|
77
|
+
)
|
78
|
+
|
79
|
+
case_manager.setup_geometry(
|
80
|
+
p0=geometry_config.p0,
|
81
|
+
p1=geometry_config.p1,
|
82
|
+
cells=geometry_config.cells,
|
83
|
+
patch_names=geometry_config.patch_names
|
84
|
+
)
|
85
|
+
|
86
|
+
# Set up control
|
87
|
+
control_config = ControlConfig()
|
88
|
+
control_config.set_solver("interFoam")
|
89
|
+
control_config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
90
|
+
|
91
|
+
case_manager.setup_control(control_config.get_parameters())
|
92
|
+
|
93
|
+
# Set up turbulence
|
94
|
+
turbulence_config = TurbulenceConfig("RAS")
|
95
|
+
turbulence_config.set_ras_model("kOmegaSST")
|
96
|
+
|
97
|
+
case_manager.setup_turbulence(
|
98
|
+
simulation_type=turbulence_config.get_simulation_type(),
|
99
|
+
model_properties=turbulence_config.get_model_properties()
|
100
|
+
)
|
101
|
+
|
102
|
+
# Create the complete case
|
103
|
+
case_manager.create_full_case()
|
104
|
+
```
|
105
|
+
|
106
|
+
## Package Structure
|
107
|
+
|
108
|
+
```
|
109
|
+
pycphy/
|
110
|
+
├── __init__.py
|
111
|
+
└── foamCaseDeveloper/
|
112
|
+
├── __init__.py
|
113
|
+
├── main.py # Command-line interface
|
114
|
+
├── core/ # Core functionality
|
115
|
+
│ ├── __init__.py
|
116
|
+
│ ├── foam_case_manager.py # Main case management class
|
117
|
+
│ ├── block_mesh_developer.py # BlockMesh generation
|
118
|
+
│ ├── control_dict_writer.py # Control dictionary writer
|
119
|
+
│ └── turbulence_properties_writer.py # Turbulence properties writer
|
120
|
+
├── writers/ # OpenFOAM dictionary writers
|
121
|
+
│ ├── __init__.py
|
122
|
+
│ ├── foam_writer.py # Base writer class
|
123
|
+
│ ├── block_mesh_writer.py # BlockMesh dictionary writer
|
124
|
+
│ ├── control_dict_writer.py # Control dictionary writer
|
125
|
+
│ └── turbulence_properties_writer.py # Turbulence properties writer
|
126
|
+
└── config/ # Configuration classes
|
127
|
+
├── __init__.py
|
128
|
+
├── block_mesh_config.py # Geometry configuration
|
129
|
+
├── control_config.py # Control configuration
|
130
|
+
└── turbulence_config.py # Turbulence configuration
|
131
|
+
```
|
132
|
+
|
133
|
+
## Configuration
|
134
|
+
|
135
|
+
### Geometry Configuration (BlockMesh)
|
136
|
+
|
137
|
+
```python
|
138
|
+
from pycphy.foamCaseDeveloper import BlockMeshConfig
|
139
|
+
|
140
|
+
config = BlockMeshConfig(
|
141
|
+
p0=(0.0, 0.0, 0.0), # Minimum corner
|
142
|
+
p1=(1.0, 1.0, 1.0), # Maximum corner
|
143
|
+
cells=(50, 50, 50), # Number of cells
|
144
|
+
patch_names={ # Boundary patch names
|
145
|
+
'minX': 'inlet',
|
146
|
+
'maxX': 'outlet',
|
147
|
+
'minY': 'frontWall',
|
148
|
+
'maxY': 'backWall',
|
149
|
+
'minZ': 'floor',
|
150
|
+
'maxZ': 'ceiling'
|
151
|
+
}
|
152
|
+
)
|
153
|
+
```
|
154
|
+
|
155
|
+
### Control Configuration
|
156
|
+
|
157
|
+
```python
|
158
|
+
from pycphy.foamCaseDeveloper import ControlConfig
|
159
|
+
|
160
|
+
config = ControlConfig()
|
161
|
+
config.set_solver("interFoam")
|
162
|
+
config.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
163
|
+
config.set_write_control(write_interval=0.05)
|
164
|
+
config.set_courant_control(max_co=1)
|
165
|
+
```
|
166
|
+
|
167
|
+
### Turbulence Configuration
|
168
|
+
|
169
|
+
```python
|
170
|
+
from pycphy.foamCaseDeveloper import TurbulenceConfig
|
171
|
+
|
172
|
+
# RAS configuration
|
173
|
+
ras_config = TurbulenceConfig("RAS")
|
174
|
+
ras_config.set_ras_model("kOmegaSST")
|
175
|
+
|
176
|
+
# LES configuration
|
177
|
+
les_config = TurbulenceConfig("LES")
|
178
|
+
les_config.set_les_model("kEqn")
|
179
|
+
les_config.set_delta_model("smooth")
|
180
|
+
|
181
|
+
# Laminar configuration
|
182
|
+
laminar_config = TurbulenceConfig("laminar")
|
183
|
+
```
|
184
|
+
|
185
|
+
## Examples
|
186
|
+
|
187
|
+
### Channel Flow Case
|
188
|
+
|
189
|
+
```python
|
190
|
+
from pycphy.foamCaseDeveloper import FoamCaseManager, BlockMeshConfig, ControlConfig, TurbulenceConfig
|
191
|
+
|
192
|
+
# Create channel flow case
|
193
|
+
case_manager = FoamCaseManager("channelFlow")
|
194
|
+
|
195
|
+
# Channel geometry: 0.5m x 0.2m x 0.1m
|
196
|
+
geometry = BlockMeshConfig(
|
197
|
+
p0=(0.0, 0.0, 0.0),
|
198
|
+
p1=(0.5, 0.2, 0.1),
|
199
|
+
cells=(50, 20, 50),
|
200
|
+
patch_names={
|
201
|
+
'minX': 'inlet',
|
202
|
+
'maxX': 'outlet',
|
203
|
+
'minY': 'frontWall',
|
204
|
+
'maxY': 'backWall',
|
205
|
+
'minZ': 'floor',
|
206
|
+
'maxZ': 'ceiling'
|
207
|
+
}
|
208
|
+
)
|
209
|
+
|
210
|
+
case_manager.setup_geometry(
|
211
|
+
p0=geometry.p0, p1=geometry.p1, cells=geometry.cells,
|
212
|
+
patch_names=geometry.patch_names
|
213
|
+
)
|
214
|
+
|
215
|
+
# Set up solver
|
216
|
+
control = ControlConfig()
|
217
|
+
control.set_solver("interFoam")
|
218
|
+
control.set_time_control(start_time=0, end_time=1.0, delta_t=0.001)
|
219
|
+
|
220
|
+
case_manager.setup_control(control.get_parameters())
|
221
|
+
|
222
|
+
# Set up turbulence
|
223
|
+
turbulence = TurbulenceConfig("RAS")
|
224
|
+
turbulence.set_ras_model("kOmegaSST")
|
225
|
+
|
226
|
+
case_manager.setup_turbulence(
|
227
|
+
simulation_type=turbulence.get_simulation_type(),
|
228
|
+
model_properties=turbulence.get_model_properties()
|
229
|
+
)
|
230
|
+
|
231
|
+
# Create the case
|
232
|
+
case_manager.create_full_case()
|
233
|
+
```
|
234
|
+
|
235
|
+
## Requirements
|
236
|
+
|
237
|
+
- Python >= 3.7
|
238
|
+
- NumPy >= 1.19.0
|
239
|
+
- SciPy >= 1.6.0
|
240
|
+
- Matplotlib >= 3.3.0
|
241
|
+
|
242
|
+
## Development
|
243
|
+
|
244
|
+
### Running Tests
|
245
|
+
|
246
|
+
```bash
|
247
|
+
pytest
|
248
|
+
```
|
249
|
+
|
250
|
+
### Code Formatting
|
251
|
+
|
252
|
+
```bash
|
253
|
+
black pycphy/
|
254
|
+
flake8 pycphy/
|
255
|
+
```
|
256
|
+
|
257
|
+
### Building Documentation
|
258
|
+
|
259
|
+
```bash
|
260
|
+
sphinx-build docs/ docs/_build/
|
261
|
+
```
|
262
|
+
|
263
|
+
## Contributing
|
264
|
+
|
265
|
+
1. Fork the repository
|
266
|
+
2. Create a feature branch (`git checkout -b feature/new-feature`)
|
267
|
+
3. Commit your changes (`git commit -am 'Add new feature'`)
|
268
|
+
4. Push to the branch (`git push origin feature/new-feature`)
|
269
|
+
5. Create a Pull Request
|
270
|
+
|
271
|
+
## License
|
272
|
+
|
273
|
+
This project is licensed under the MIT License - see the LICENSE file for details.
|
274
|
+
|
275
|
+
## Citation
|
276
|
+
|
277
|
+
If you use pycphy in your research, please cite:
|
278
|
+
|
279
|
+
```bibtex
|
280
|
+
@software{bashyal2025pycphy,
|
281
|
+
title={pycphy: Python Computational Physics},
|
282
|
+
author={Bashyal, Sanjeev},
|
283
|
+
year={2025},
|
284
|
+
url={https://github.com/SanjeevBashyal/pycphy}
|
285
|
+
}
|
286
|
+
```
|
287
|
+
|
288
|
+
## Support
|
289
|
+
|
290
|
+
For questions, issues, or contributions, please visit the [GitHub repository](https://github.com/SanjeevBashyal/pycphy).
|
@@ -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
|
+
]
|