All Projects → marinlauber → 2D-Turbulence-Python

marinlauber / 2D-Turbulence-Python

Licence: MIT License
Simple OOP Python Code to run some Pseudo-Spectral 2D Simulations of Turbulence

Programming Languages

HTML
75241 projects
Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to 2D-Turbulence-Python

TEGAN
Generative Adversarial Network (GAN) for physically realistic enrichment of turbulent flow fields
Stars: ✭ 60 (+150%)
Mutual labels:  turbulence
EmptyDrops2017
Code for the empty droplet and cell detection project from the HCA Hackathon.
Stars: ✭ 16 (-33.33%)
Mutual labels:  simulations
exadg
ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
Stars: ✭ 62 (+158.33%)
Mutual labels:  turbulence
PowerSimulations.jl
Julia for optimization simulation and modeling of PowerSystems. Part of the Scalable Integrated Infrastructure Planning Initiative at the National Renewable Energy Lab.
Stars: ✭ 202 (+741.67%)
Mutual labels:  simulations
nlexperiment
🐟 R package for NetLogo experiments http://bergant.github.io/nlexperiment/
Stars: ✭ 16 (-33.33%)
Mutual labels:  simulations
neutronics-workshop
A workshop covering a range of fusion relevant analysis and simulations with OpenMC, DAGMC, Paramak and other open source fusion neutronics tools
Stars: ✭ 29 (+20.83%)
Mutual labels:  simulations
Haskell-abinitio
contains a package in Haskell to calculate the electronic structure properties of molecules using the Hartree-Fock method
Stars: ✭ 14 (-41.67%)
Mutual labels:  simulations
SciCompforChemists
Scientific Computing for Chemists text for teaching basic computing skills to chemistry students using Python, Jupyter notebooks, and the SciPy stack. This text makes use of a variety of packages including NumPy, SciPy, matplotlib, pandas, seaborn, NMRglue, SymPy, scikit-image, and scikit-learn.
Stars: ✭ 65 (+170.83%)
Mutual labels:  simulations
rsimsum
Analysis of simulation studies including Monte Carlo error
Stars: ✭ 19 (-20.83%)
Mutual labels:  simulations
Pylians3
Libraries to analyze numerical simulations (python3)
Stars: ✭ 35 (+45.83%)
Mutual labels:  simulations
CaNS
A code for fast, massively-parallel direct numerical simulations (DNS) of canonical flows
Stars: ✭ 144 (+500%)
Mutual labels:  turbulence
DeclareDesign
DeclareDesign: Declare and Diagnose Research Designs
Stars: ✭ 92 (+283.33%)
Mutual labels:  simulations
tlab
No description or website provided.
Stars: ✭ 19 (-20.83%)
Mutual labels:  turbulence
ThePhysicsHub
The Physics Hub is an open source physics simulations project that is being developed by physics students worldwide and aims to deliver clear and easy to understand physics simulations free for everyone!
Stars: ✭ 116 (+383.33%)
Mutual labels:  simulations
Maroon
An interactive and immersive laboratory for Web, PC and VR.
Stars: ✭ 16 (-33.33%)
Mutual labels:  simulations
cluster toolkit
Tools for analyzing galaxy clusters.
Stars: ✭ 16 (-33.33%)
Mutual labels:  simulations
simulate
A collection of simulations and visualizations for all sorts of stuff (Majorly Algorithmic or Mathematical)
Stars: ✭ 82 (+241.67%)
Mutual labels:  simulations
GoogleHashCode2018
Solutions to Google HashCode 2018
Stars: ✭ 14 (-41.67%)
Mutual labels:  simulations
PyRates
Open-source, graph-based Python code generator and analysis toolbox for dynamical systems (pre-implemented and custom models). Most pre-implemented models belong to the family of neural population models.
Stars: ✭ 33 (+37.5%)
Mutual labels:  simulations
negative-mass-simulator
Negative Mass N-body Simulation Codes
Stars: ✭ 57 (+137.5%)
Mutual labels:  simulations

Decaying Turbulence in Python (OOP)

Build Status

Coverage Status

DOI

Pseudo-spectral collocation code for two-dimensional turbulence simulations written in object-oriented python.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

To run the code provided in this repository, you will need standard python packages, such as numpy and matplotlib. These should already be installed on most machines.

To use the master branch of this code (the fast one!), you will need to have pyFFTW installed. Installation instructions can be found here.

Alternatively, you can create a new conda environment using the environment.yml file provided. First, got in the '2D-Turbulence-Python' cloned repository and creat the new environment

$ conda env create -f environment.yml

This will create a new conda environment called 2D-Turbulence-Python. Then activate it

$ conda activate 2D-Turbulence-Python

This will install all the required packages and allows you to use this repo.

This repository contains three (as of today) branches, the master branch that includes the pseudo-spectral code running with the pyFFTW library, the CDS branch that contains the high-order (up to 6th) compact difference scheme version and the numpy branch that contains a numpy-only version of the code. When the repository has been cloned/downloaded, you can switch between branches using

git checkout numpy (or CDS)

to switch to the desired branch. The solver is implemented such that functions calls perform the same tasks on each branch.

Running The Tests

Once you are happy with the version you are going to use, check that everything works by running the validation script

python valid.py

This runs a simulation of the Taylor-Green Vortex for which we have an analytical solution. The output should look similar to this

Starting integration on field.

Iteration    100, time   0.020, time remaining   0.079. TKE: 0.180  ENS: 23580.54
Iteration    200, time   0.041, time remaining   0.058. TKE: 0.129  ENS: 16934.10
Iteration    300, time   0.061, time remaining   0.038. TKE: 0.092  ENS: 12157.35
Iteration    400, time   0.082, time remaining   0.017. TKE: 0.066  ENS: 8725.782

Execution time for 484 iterations is 2.737 seconds.
The L2-norm of the Error in the Taylor-Green vortex on a 128x128 grid is 1.362e-10.
The Linf-norm of the Error in the Taylor-Green vortex on a 128x128 grid is 2.725e-10.

You should get errors in both norms close to the values displayed above.

This repo also contains some more basic test, that can be run using pytest

$ pytest

Using the code

Simulations are initialized by defining a grid, and specifying the Reynolds number of the flow

flow = Fluid(nx=64, ny=64, Re=1)
flow.init_solver()
flow.init_field(TaylorGreen)

Here we have initialized the Taylor-Green vortex. The solver initiation generates all the working arrays and transforms the initial conditions. Simulations can also be initialized using results from previous runs (these need to have been saved with flow.write(folder='', 1))

from src.field import FromDat
flow.init_field(FromDat, name="vort_000001.dat")

here we reset the flow timer using the time value saved in the vort_ID.dat file. The finish time of the simulation must be adjusted accordingly, as well as the ID if the field is saved. This allows user-generated field to be used, within the limitations of the method (periodic boundary conditions). The main loop of the solver is called as

# loop to solve
while(flow.time<=finish):
    flow.update()
    if(flow.it % 1000 == 0):
        print("Iteration \t %d, time \t %f, time remaining \t %f. TKE: %f, ENS: %f" %(flow.it,
              flow.time, finish-flow.time, flow.tke(), flow.enstrophy()))
        flow.write(file="fluid")

Small simulations can also be run live, which can also be handy for de-bugging

flow.run_live(finish, every=100)

Additional Content

For a description of the theory behind this code, or to run other cases, such as a double shear layer, or decaying isotropic turbulence, look at this.

Authors

  • Marin Lauber - Initial work - github

License

This project is licensed under the MIT License - see the LICENSE file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].