Skip to main content

Python utilities for snek5000 project

Project description

snek5000

Python framework for Nek5000.

Warning: This framework is experimental and of alpha-quality. The API can also change.

Documentation: https://exabl.github.io/snek5000/

Installation

# Clone
git clone --recursive https://github.com:exabl/snek5000.git

# Activate paths: Start here. Always!
cd snek5000
source activate.sh

Now you should setup a Python environment. There are two ways to do this (and it has to be done only once):

  • Using venv
    python -m venv venv
    source venv/bin/activate
    pip install -e .
    
  • Using conda
    conda env create -n snek5000 -f environment.yml
    conda activate snek5000
    pip install -e .
    

Why and why not use snek5000?

The snek5000 Python API is based on fluidsim, which allows you to launch a simulation using scripts. For example the periodic hill example can be launched as.

from phill.solver import Simul

params = Simul.create_default_params()

# modify parameters as needed

sim = Simul(params)
sim.make.exec()  # by default starts a run
sim.make.exec(["mesh", "compile"])  # run rules in order
sim.make.exec(["run"], dryrun=True)  # simulate simulation
sim.make.exec(["run"])  # actual simulation

Advantages

  • Saves you from the trouble in setting up multiple source files (.box, .par, SIZE)
  • Checks for consistency of parameters
  • Out of source builds and runs, which can be inspected or executed using the conventional makenek for debugging
  • Avoid typos and human errors
  • Better than bash scripting like:
    # Build case
    cd src/phill/
    CASE="phill"
    echo "$CASE.box" | genbox
    mv -f box.re2 phill.re2
    echo "$CASE\n0.01" | genmap
    FFLAGS="-mcmodel=medium -march=native" CFLAGS="-mcmodel=medium -march=native" makenek
    cd -
    
    # Run case
    cd src/phill/
    nekmpi $CASE <nb_procs> # foreground
    nekbmpi $CASE <nb_procs> # background
    cd -
    
    
    # Clean
    makenek clean
    
  • Use of Snakemake which is similar to GNU Make, but allows one to blend bash and python scripting and uses simple YAML files for managing custom configurations of compilers and flags for different computers.

Disadvantages

  • In development
  • Requires some basic knowledge of Python to use
  • Modification of the API requires learning how Snakemake functions and how to write Jinja templates (which are not so hard, btw)

Roadmap

Short term

  • Implement post processing API: with matplotlib and Paraview

Long term

  • Interface Nek5000 states and time-integration event loop

Contributing

Contributions are welcome! You can help by testing out the code, filing issues and submitting patches. See contributing guidelines.

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

snek5000-0.3.0a0.tar.gz (166.9 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page