Code Monkey home page Code Monkey logo

lettuce's Introduction

lettuce

https://travis-ci.com/Olllom/lettuce.svg?branch=master Documentation Status

GPU-accelerated Lattice Boltzmann in Python

  • Free software: MIT license

Features

  • Single-GPU performance (2D): 650 MLUPS on V100

Getting Started

  • Install the anaconda package manager from www.anaconda.org

  • Create a new conda repository and install all dependencies:

    conda create -n lettuce -c pytorch -c conda-forge\
         "pytorch>=1.1" matplotlib pytest click cudatoolkit "pyevtk>=1.1"
    
  • Activate the conda environment:

    conda activate lettuce
    
  • Clone this repository from github

  • Change into the cloned directory

  • Run the install script:

    python setup.py install
    
  • Run the test cases:

    python setup.py test
    
  • Check out the convergence order, running on CPU:

    lettuce --no-cuda convergence
    
  • For running a CUDA-driven LBM simulation on one GPU omit the --no-cuda. If CUDA is not found, make sure that cuda drivers are installed and compatible with the installed cudatoolkit (see conda install command above).

  • Check out the performance, running on CPU:

    lettuce benchmark
    

A first example

The following Python code will run a two-dimensional Taylor-Green vortex on a GPU:

import torch
from lettuce import BGKCollision, StandardStreaming, Lattice, D2Q9, TaylorGreenVortex2D, Simulation

device = "cuda:0"   # for running on cpu: device = "cpu"
dtype = torch.float32

lattice = Lattice(D2Q9, device, dtype)
flow = TaylorGreenVortex2D(resolution=256, reynolds_number=10, mach_number=0.05, lattice=lattice)
collision = BGKCollision(lattice, tau=flow.units.relaxation_parameter_lu)
streaming = StandardStreaming(lattice)
simulation = Simulation(flow=flow, lattice=lattice,  collision=collision, streaming=streaming)
mlups = simulation.step(num_steps=1000)

print("Performance in MLUPS:", mlups)

Next steps

  • Jonas Latt's approach of storing f_i-w_i instead of f_i, for better numerical accuracy at 16-bit precision; this can be added as a different Lattice class.
  • Benchmark storage formats for f (either Qx... or ...xQ) -- also add as a different Lattice class?
  • Standard Streaming and BGK collision as C++ functions, as an example and for testing performance gains https://pytorch.org/tutorials/advanced/cpp_extension.html
  • Boundary Conditions.
  • Multi-block lattices.
  • Semi-Lagrangian streaming step (specific benefit from half-precision, utilization of tensor cores on Volta cards).

Future Ideas

Credits

We use the following third-party packages:

  • pytorch
  • numpy
  • pytest
  • click
  • matplotlib
  • versioneer

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

lettuce's People

Contributors

dominikwilde avatar martinkliemank avatar mcbs avatar olllom avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.