-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/mcgoldba/pyFoamd into main
- Loading branch information
Showing
17 changed files
with
195 additions
and
853 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Metadata-Version: 2.1 | ||
Name: pyfoamd | ||
Version: 0.0.2 | ||
Version: 0.0.7 | ||
Author-email: Marc Goldbach <[email protected]> | ||
License: GNU GENERAL PUBLIC LICENSE | ||
Version 3, 29 June 2007 | ||
|
@@ -691,66 +691,147 @@ pyFoamd | |
|
||
Pythonic modification of OpenFOAM dictionaries and case files. | ||
|
||
Features | ||
-------- | ||
|
||
* Load OpenFOAM cases as Python objects | ||
* Read and edit OpenFOAM dictionary entries | ||
* Manipulated OpenFOAM cases from command line using the integrated iPython console | ||
* Manipulate OpenFOAM cases from a Python script file. | ||
* Support for most OpenFOAM naitive types including: | ||
* dictonary entries, lists, scalars, vectors, tensors, dimensioned types, tables, coded objects, and more | ||
* Run OpenFOAM case Allrun scripts | ||
* Easily setup and execute parametric OpenFOAM studies with many simulations | ||
|
||
Installation | ||
------------ | ||
|
||
.. code-block:: bash | ||
|
||
python -m pip install pyfoamd | ||
```bash | ||
#terminal | ||
python -m pip install pyfoamd | ||
``` | ||
|
||
Basic Usage | ||
----------- | ||
|
||
Copy a template case and load as a python object | ||
```bash | ||
#terminal | ||
cp $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . | ||
cd pitzDaily | ||
pf init | ||
``` | ||
|
||
.. code-block:: bash | ||
View case variables | ||
```bash | ||
#terminal | ||
pf edit | ||
``` | ||
|
||
cp $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily . | ||
cd pitzDaily | ||
pf init | ||
```python | ||
#Python console | ||
>>> case.constant.turbulenceProperties.RAS.RASModel | ||
kEpsilon | ||
``` | ||
Change case dictionary entries | ||
|
||
View case variables | ||
```python | ||
#Python console | ||
>>> case.constant.case.constant.turbulenceProperties.RAS.RASModel = kOmega | ||
``` | ||
|
||
Write the updated case to file | ||
|
||
```python | ||
#Python console | ||
>>> case.write() | ||
``` | ||
|
||
.. code-block:: bash | ||
Run the Allrun script | ||
```python | ||
#Python console | ||
>>> case.run() | ||
``` | ||
|
||
pf edit | ||
Scripting | ||
--------- | ||
|
||
.. code-block:: python | ||
PyFoamd can also be imported into a python script to allow for manipultion of OpenFOAM cases. This is useful, for example, when performing parameteric studies to run multiple simulations with varibale parameters (e.g. different turbulence models): | ||
|
||
>>> case.constant.turbulenceProperties.RAS.RASModel | ||
kEpsilon | ||
```bash | ||
#terminal | ||
#- Setup the OpenFOAM study directory | ||
cd ~ | ||
mkdir ofStudy | ||
cd ofStudy | ||
cp $FOAM_TEMPLATES/incompressible/simpleFoam/pitzDaily of.template | ||
touch runStudy.py | ||
``` | ||
|
||
Change case dictionary entries | ||
runStudy.py | ||
```python | ||
import pyfoamd.functions as pf | ||
import pyfoamd.types as pt | ||
import pamdas as pd | ||
|
||
.. code-block:: python | ||
turbulenceModels = [kEpsilon, realizableKE, kOmega, kOmegaSST] | ||
parameterNames = ['Turbulence Model'] | ||
|
||
>>> case.constant.case.constant.turbulenceProperties.RAS.RASModel = kOmega | ||
samples = pd.DataFrame( | ||
[[model] for model in turbulenceModels], | ||
columns = parameterNames | ||
) | ||
|
||
Write the updated case to file | ||
def updateCase(case, values): | ||
""" | ||
This function is called from the ofStudy. | ||
|
||
.. code-block:: python | ||
Parameters | ||
---------- | ||
case [pyfoamd.ofCase]: | ||
The OpenFOAM case which is to be updated. | ||
values [list]: | ||
Sample point as a list of dictionary values to be updated for the current simulation | ||
|
||
>>> case.write() | ||
Return | ||
------ | ||
case [pyfoamd.ofCase]: | ||
The updated OpenFOAM case. | ||
|
||
""" | ||
turbModel = values[0] | ||
|
||
Run the Allrun script | ||
case.constant.case.constant.turbulenceProperties.RAS.RASModel = turbModel | ||
|
||
return case | ||
|
||
.. code-block:: python | ||
#- Create the OpenFOAM study | ||
study = pt.ofStudy('of.template', parameterNames, sample, updateCase) | ||
|
||
>>> case.run() | ||
#- Run all 4 simulations | ||
study.run() | ||
|
||
``` | ||
|
||
```bash | ||
#terminal | ||
# Run the study | ||
python runStudy.py | ||
``` | ||
|
||
Releasing | ||
--------- | ||
|
||
Releases are published automatically when a tag is pushed to GitHub. | ||
|
||
.. code-block:: bash | ||
|
||
# Set next version number | ||
export RELEASE=x.x.x | ||
```bash | ||
# Set next version number | ||
export RELEASE=x.x.x | ||
|
||
# Create tags | ||
git commit --allow-empty -m "Release $RELEASE" | ||
git tag -a $RELEASE -m "Version $RELEASE" | ||
# Create tags | ||
git commit --allow-empty -m "Release $RELEASE" | ||
git tag -a $RELEASE -m "Version $RELEASE" | ||
|
||
# Push | ||
git push upstream --tags | ||
# Push | ||
git push upstream --tags | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,7 @@ | ||
bash | ||
bin | ||
build | ||
dist | ||
pyfoamd | ||
scripts | ||
templates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.