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
#terminal
python -m pip install pyfoamd
Basic Usage
Copy a template case and load as a python object
#terminal
cp $FOAM_TUTORIALS/incompressible/simpleFoam/pitzDaily .
cd pitzDaily
pf init
View case variables
#terminal
pf edit
#Python console
>>> case.constant.turbulenceProperties.RAS.RASModel
kEpsilon
Change case dictionary entries
#Python console
>>> case.constant.case.constant.turbulenceProperties.RAS.RASModel = kOmega
Write the updated case to file
#Python console
>>> case.write()
Run the Allrun script
#Python console
>>> case.run()
Scripting
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):
#terminal
#- Setup the OpenFOAM study directory
cd ~
mkdir ofStudy
cd ofStudy
cp $FOAM_TEMPLATES/incompressible/simpleFoam/pitzDaily of.template
touch runStudy.py
runStudy.py
import pyfoamd.functions as pf
import pyfoamd.types as pt
import pamdas as pd
turbulenceModels = [kEpsilon, realizableKE, kOmega, kOmegaSST]
parameterNames = ['Turbulence Model']
samples = pd.DataFrame(
[[model] for model in turbulenceModels],
columns = parameterNames
)
def updateCase(case, values):
"""
This function is called from the ofStudy.
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
Return
------
case [pyfoamd.ofCase]:
The updated OpenFOAM case.
"""
turbModel = values[0]
case.constant.case.constant.turbulenceProperties.RAS.RASModel = turbModel
return case
#- Create the OpenFOAM study
study = pt.ofStudy('of.template', parameterNames, sample, updateCase)
#- Run all 4 simulations
study.run()
#terminal
# Run the study
python runStudy.py
Releasing
Releases are published automatically when a tag is pushed to GitHub.
# 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"
# Push
git push upstream --tags
Metadata
Release files for pyfoamd 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyfoamd-0.0.10.tar.gz | 114.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyfoamd-0.0.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 234.9 kB
Release files / pyfoamd-0.0.10.tar.gz
| Download URL | pyfoamd-0.0.10.tar.gz |
|---|---|
| Size | 114.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e71dcfa29b846cacf28934b73e884c4ed66c1f78c0859bdc2d96fc3ea1a3ee38
|
|
BLAKE2b-256 checksum How to use checksums |
dd0786ae7d380c2962acce571c866c3b19c204dcb4748c44c2dd2bdb58b6916f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / pyfoamd-0.0.10-py3-none-any.whl
| Download URL | pyfoamd-0.0.10-py3-none-any.whl |
|---|---|
| Size | 120.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
253019aa799ba3aaf088b520f675e005b3b2194c650d702b44cffc3c7e5af817
|
|
BLAKE2b-256 checksum How to use checksums |
2b49b9189853397de3ac5df722392ed0859b4186e9da587d28cadad49b6fbb2b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|