Code Monkey home page Code Monkey logo

javacfd's Introduction

JavaCFD


Computational fluid dynamics software written in Java using the Lattice-Boltzmann method. Allows custom-defined, arbitrary geometries in 2D incompressible flow field.


TO RUN: Execute JavaCFD.pde in the NonOOP folder of the main branch. The object-oriented version optimizes the Lattice-Boltzmann code for Java but is still a work in progress. Check the demo folder for newest updates on the OOP version.
1) set sliders for velocity and viscosity
2) set display to velocity
3) click start, and draw geometry on the fluid field by clicking and dragging
- set the scaling slider to optimize display
- clicking start again resets the simulation
- enter 1 on the keyboard for a line, 2 for a line at 45 degrees, and 3 for a circle (there is no need to click the start button in this case: it runs automatically)
- when in doubt, reset the fluid! Play with the scaling slider a lot as it requires somewhat different values for different display modes/simulations
- viscosity should be somewhat on the low end, otherwise the calculated relaxation time will cause inaccurate flow

If the screen has a uniform color, adjust the scale slider until you have good contrast. It is good to start on velocity mode as that gives the normal, intuitive picture of fluid flow.

If the fluid looks like it is being infested with a red virus erasing all the elements, you have saturated the algorithm and caused it to diverge. Simply click start again to reset.


Note that the simulation is highly CPU intensive and only small fluid fields should be attempted on most machines.

***NonOOP is the best version***
The object oriented version is included as it runs but is unstable and inaccurate. This is what was described in the project prototype and introduces new methods (NonOOP LBM on its own is kind of boring and is written in the same way as C/Fortran implementations which have been used in commercial products for decades).


Computational fluid dynamics is used extensively in engineering to accurately model fluid flow and its associated phenomena. Turbulent flow/hypersonic flow/vortex shredding etc can be simulated using the Navier-Stokes equations, which describe fluid flow using the conservation of momenta and mass flow. However, as they are nonlinear partial differential equations, a solver is very difficult to code.

The Lattice-Boltzmann method works in a way comparable to cellular automata. By discretizing thermal velocities for each element and then reassigning it based on the Boltzmann distribution, it is able to very accurately reconstruct the behavior of the Navier-Stokes equations in subsonic velocities (higher velocities require thermal coupling). In fact it is even more accurate in modeling turbulent flow and is optimized for massively parallel architectures. We have created our own implementation of the Lattice-Boltzmann algorithm with the D2Q9 model (two dimensions, 9 discretized velocities).

Written for Mr. Konstantinovich's AP Computer Science Class, Stuyvesant High School.



References:
The bulk of the math comes from Alex Wagner's paper, A Practical Introduction to the Lattice-Boltzmann Method. https://www.ndsu.edu/fileadmin/physics.ndsu.edu/Wagner/LBbook.pdf
Lindsay Crowl's GSAC Talk, http://www.math.utah.edu/~crowl/pres.pdf
Great thanks to Weber State University's project on Lattice-Boltzmann, which outlined the equations and steps in great detail http://physics.weber.edu/schroeder/javacourse/LatticeBoltzmann.pdf

javacfd's People

Contributors

sihaohuang avatar

Watchers

James Cloos avatar  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.