Skip to main content

FoamKit

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 foamkit

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

FoamKit 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 foamkit.functions as pf
import foamkit.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 [foamkit.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 [foamkit.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 foamkit 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foamkit 0.1.0
File Size Uploaded
foamkit-0.1.0.tar.gz 113.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foamkit 0.1.0
File Interpreter ABI Platform
foamkit-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 232.8 kB

Release files / foamkit-0.1.0.tar.gz

Download URL foamkit-0.1.0.tar.gz
Size 113.5 kB
Tags Source
SHA-256 checksum
How to use checksums
4606f25d9a5e9309eb23a953aea1ccdb4a5f12294fb4ec99a520fea15e0ca60c
BLAKE2b-256 checksum
How to use checksums
9d20e9d9a6952f34d6ea2b378d4b51db04e6d99004e5c4c68b978d26a2c17dee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release files / foamkit-0.1.0-py3-none-any.whl

Download URL foamkit-0.1.0-py3-none-any.whl
Size 119.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96d4dd274411d7d7fe8c46ba40999591109d02d26c420c90a482fcba322a447e
BLAKE2b-256 checksum
How to use checksums
3af6f736254a3d280df95859995e607ddc780be95c44ca56a0a4aa845275a0c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page