Skip to content

IzyumovMaxim/FluidSimulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

69 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FluidSimulation

A real-time fluid simulation written in Haskell, using Smoothed Particle Hydrodynamics (SPH) for physics modeling. You can interact with the fluid by clicking and dragging the mouseโ€”adjust simulation parameters on the fly for a customizable experience.

๐Ÿ‘‰View Simulation Demo

๐Ÿ‘ฅ Contributors

Maxim
Maxim Izyumov
Albert
Albert Khechoyan
Irina
Irina Perekrestova
Computations Optimization
Complex Environments
Fluid-based Puzzle

๐Ÿš€Getting started

Clone repository

git clone https://github.com/IzyumovMaxim/FluidSimulation

Execute program

cd FluidSimulation
stack build
stack exec -- sph-fluid -- +RTS -N8 -s -RTS

๐Ÿ“Project structure

fluid-simulation/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ assets/
โ”‚   โ””โ”€โ”€ i.png         -- Swampy image๐ŸŠ
โ”‚   โ”œโ”€โ”€ Physics.hs    -- SPH calculations
โ”‚   โ”œโ”€โ”€ Types.hs      -- Data types
โ”‚   โ”œโ”€โ”€ Level.hs      -- Game level with fluid-based puzzle
โ”‚   โ”œโ”€โ”€ Render.hs     -- Gloss visualization
โ”‚   โ””โ”€โ”€ Main.hs       -- Entry point
โ”œโ”€โ”€ app.cabal         -- Build config
โ””โ”€โ”€ stack.yaml        -- Stack config

๐ŸŽฎUser guide

Explore different simulation scenarios and our game mode!

  • Game mode control keys:

    • 1 - Square fluid simulation
    • 2 - Hourglass fluid simulation
    • 3 - Ball fluid simulation
    • 4 - Windmill simulation
    • 5 - Puzzle Level (Where's My Water)
  • Fluid Simulation Controls:

    • R - Reset simulation
    • Arrow keys - Adjust gravity
    • T/G - Mass up/down
    • U/J - Stiffness up/down
    • I/K - Viscosity up/down
    • P/; - Surface tension up/down
    • Q/q - Smoothing radius (affects performance)
    • W/w - Add/remove particles
    • Hold Shift for larger adjustments
    • Click and drag to interact with particles
  • Puzzle Game Controls:

    • Click - Dig dirt blocks
    • R - Reset level
    • Goal: Collect all stars and get water to Swampy!

๐Ÿ“ ChangeLog

Stage I

  • Basic 2D visualisation and modelling;
  • One scene with some shape containing the fluid;
  • Easily configurable model (via coefficients and kernel functions).

Stage II

  • Improved physics (added surface tension);
  • Several fluid simulation scenes: sware, circle, hourglass, windmill;
  • Added one level of game mode: "Where Is My Water?", as a simple fluid-based puzzle;
  • Optimizations enabled:
    • Parallel computation (8 cores)
    • Vectorized operations
    • Optimized spatial grid

About

Our version of fluid simulation on haskell ๐Ÿ˜Ž

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors