No project description provided
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfoamd-0.0.10.tar.gz.
File metadata
- Download URL: pyfoamd-0.0.10.tar.gz
- Upload date:
- Size: 114.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e71dcfa29b846cacf28934b73e884c4ed66c1f78c0859bdc2d96fc3ea1a3ee38
|
|
| MD5 |
af7be185ca83796d0be6d160c5270cb7
|
|
| BLAKE2b-256 |
dd0786ae7d380c2962acce571c866c3b19c204dcb4748c44c2dd2bdb58b6916f
|
File details
Details for the file pyfoamd-0.0.10-py3-none-any.whl.
File metadata
- Download URL: pyfoamd-0.0.10-py3-none-any.whl
- Upload date:
- Size: 120.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
253019aa799ba3aaf088b520f675e005b3b2194c650d702b44cffc3c7e5af817
|
|
| MD5 |
63f9ff8179e3b6c6bf12bc1a8c05fa66
|
|
| BLAKE2b-256 |
2b49b9189853397de3ac5df722392ed0859b4186e9da587d28cadad49b6fbb2b
|