Skip to content

Java implementation of smoothed particle hydrodynamics (SPH), to simulate the collisions of planetary scale bodies.

Notifications You must be signed in to change notification settings

Jazz-Coding/SmoothedPlanetaryHydrodynamics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SmoothedPlanetaryHydrodynamics

Java implementation of smoothed particle hydrodynamics (SPH), to simulate the collisions of planetary scale bodies in realtime using CUDA (~32,000 particles at 60 FPS on an RTX 4090, 64,000 at 30 FPS). sim1 A snapshot from a collision simulation, shortly following collision of a small mass with an Earth-sized mass.

simulation_collage Moon formation simulation: planet Theia impacting the proto-Earth at a 45 degree angle at 8km/s.

SPH simulates matter in four steps:

  1. Matter is assumed to have continuous fields like density, pressure, and velocity.
  2. The continuum is divided into a finite collection of discrete elements, "particles".
  3. These particles interact pairwise (n^2), each particle influencing their neighbors weighted by a special "smoothing kernel", which weights more distant interactions weakly.
  4. The sum of these interactions provides a net force determined through the Euler-Lagrange equations. This is then integrated over time to compute new velocities and positions on the next timestep (a finite subdivision of time, which is also assumed to be continuous). This is repeated throughout the simulation.

Main.java contains the rendering pipeline and dispatches to SPH_GPU. gpulib/SPH_GPU.java is the core of the SPH simulation.

Currently, to execute, you must clone the repository and run from source code (I am in the process of building a JAR release file). JDK version 19 was used for development. Keybinds:

  • PAUSE BREAK = Pause time.
  • UP/DOWN Arrows = Accelerate/Deaccelerate time (may destabilize the simulation if increased too far).
  • BACKSPACE = Reverse time.
  • Right click = Orbit camera target.
  • Shift + Right click = Translate camera left/right/up/down relative to the camera.
  • Scroll = Zoom out
  • 0 = Zero all velocities.

About

Java implementation of smoothed particle hydrodynamics (SPH), to simulate the collisions of planetary scale bodies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published