From 767d9932c1c65c7288ed741a1f9d73f934b7a976 Mon Sep 17 00:00:00 2001 From: Snehaa Ganesh Kumar Date: Wed, 1 May 2024 02:44:55 -0400 Subject: [PATCH] added vid --- .DS_Store | Bin 8196 -> 8196 bytes final-project/.DS_Store | Bin 0 -> 6148 bytes final-project/index.html | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 final-project/.DS_Store diff --git a/.DS_Store b/.DS_Store index b91c03793461d5feb9375e0f26682d4dd5947c89..561b5d523a142b8d34af45f282def0c4b7ebf2ee 100644 GIT binary patch delta 61 zcmV-D0K)%-K!iY$PXQ9KP`eKS5|a!NV+CUX008%sIuIt4nh@f%JQB+Vk$}Ln2N?DQ Tlfe+6lRpy%vtt&d0g-^cbv+g6 delta 135 zcmZp1XmOa}&nUJrU^hRb*km4oWY%R23=FR)TM4L5o+a>zFDKnFI5|JJ04N9qlN|&U zL~`?8T#|C~lYo4Vx!e9e`1j$c40J;_*9e|w-OMiWjb*c~2s<+X Do|Y^w diff --git a/final-project/.DS_Store b/final-project/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..8fc132206d9e17c765b4d7ecc5f03650fd88c788 GIT binary patch literal 6148 zcmeHKyGjE=6g{IUf;K6&n=g;{F^fEuve-}GzroS6~aWJxKa zca}Tn&V9_|z|I4J8?N#m&;ih<2%VIMB6Fi_Cj|>#=;IAXxW_9VQ8sk+8%>(~9v<+7 z90k73|EgThXXSE6zsPx~Tz`Z@4Yzv{lBdqX3-Q$*PpC+yFhx8S+-q5DLJ;qqD z?y+6aa*k8#T?}xHGulpwIonf8fj(>52mHE>?ekk;j$&!N939E?eMfQ+R Pw2MF>#42Op2N?JSGJ!V4 literal 0 HcmV?d00001 diff --git a/final-project/index.html b/final-project/index.html index 38b70ed..4856ae1 100644 --- a/final-project/index.html +++ b/final-project/index.html @@ -679,7 +679,7 @@ ,p_{shared},\rho_{neighbor} ) = \frac{d}{dx} \rho \frac{\mathbf{v}p_{shared}}{\rho_{neighbor}}
  • viscosityKernel: This function calculates the viscous forces acting between particles, which are essential for simulating the internal friction of the fluid, allowing us to model the energy dissipation and angular momentum transfer that occur in the turbulent gas clouds of a supernova.
    • We calculate viscosity force by using a cubic spline kernel function that is commonly used in SPH simulations. hh is our smoothing radius, rr is the distance between particles
    viscosityKernel(r,h)={31564πh9(h2r2)3if r<h0otherwise\text{viscosityKernel}(r,h) = \begin{cases} \frac{315}{64 \pi h^9} (h^2 - r^2)^3 & \text{{if }} r < h \\0 & \text{{otherwise}}\end{cases}
    viscosityForce=j(vjvi)×viscosityKernel(rij,h)\text{{viscosityForce}} = \sum_{j} (\mathbf{v}_j - \mathbf{v}_i) \times \text{{viscosityKernel}}(r_{ij}, h) -
    • This approach effectively models the internal friction between particles, which is crucial for simulating fluid flow and interactions in scenarios such as gas dynamics in supernovae. The choice of the cubic spline kernel for viscosity is motivated by its smoothness and compact support, which are beneficial for numerical stability and computational efficiency in particle-based simulations.

2. Temperature Calculation:

  • computeTemperature: This method estimates the temperature of particles based on their kinetic energy. The kinetic theory of gases relates the microscopic motions of individual particles to the macroscopic temperatures observed in a gas. By calculating the temperature as a function of kinetic energy using the Boltzmann constant, this method allows the simulation to dynamically update particle properties in response to changes in their velocities and interactions, facilitating the accurate simulation of heat transfer and thermal effects crucial for modeling the thermonuclear processes in supernovas.

Integration into the Simulation Loop

Within ParticleSolverCPUFluid.cpp, these methods are integrated into the particle update loop, ensuring that each particle's behavior is governed by physically accurate, temperature-dependent properties:

  • Temperature-dependent dynamics: By integrating the temperature calculations directly into the update loop, we ensure that the physical properties of each particle, such as viscosity and pressure forces, are correctly updated based on the local thermal conditions. This integration is critical for modeling the complex interplay of thermal energy, radiation pressure, and gravity that drives the evolution of a supernova.
  • Pressure and gravitational forces: Modifications to the pressure force computations account for the additional explosive outward forces generated by high temperatures in the supernova core. Similarly, gravitational calculations are adjusted to accurately simulate the collapse of the core and the subsequent expulsion of the outer layers. This approach allows our simulation to dynamically model both the implosion and explosion phases of a supernova, capturing the cyclical nature of compression and expansion seen in these events.

By carefully implementing and integrating these advanced computational methods, we have significantly enhanced the realism and scientific accuracy of our supernova simulation. Each method has been tailored to reflect the unique conditions of supernova physics, allowing us to explore this cataclysmic event with unprecedented detail and fidelity.

Shader Improvements

Implementation

Using knowledge from Project 4, we modified the original vertex and fragment shaders to fit our needs. The main features we added were gaseous particles and better color mapping.

For gaseous particles, this mostly involved rendering each individual particle as a blurred sphere based on particle characteristics such as mass, and distance from origin. The mass component was important since each simulation particle represents multiple gaseous particles which would make up the region around that simulation particle. The more mass, the more apparent and brighter the simulation particle should appear. The distance from the origin was used to fix a problem where particles appeared clumpy when they spread apart. The essential idea is for each pixel, we adjust the alpha based on its distance on the distance from the particle and the size of the particle (more spread-out gasses are thinner). The formula we ended up using was (0.25f-abs(dist)) * 4.0f / particleSize.

The particles don’t feel cohesive as they should be.
When adjusting sizes of spread out particles, it resembles a gas more.

We then added back the original particles to make the cloud fuller and less like a random blur in the screen.

Blue initial state
Yellow after explosion

Then, for colors, we essentially used the temperature for the hue, velocity for the value, and a constant float of 1.0f for our saturation. This involved using the OpenGL C++ API to create a new buffer to feed in particle temperatures. We also normalized the temperatures and velocities using this formula (generalized): clamp(characteristic - min_val / max_val, 0.0, 1.0). We then converted this HSV color to RGB.

Side view
Temperatures are a little inaccurate

Debugging

In general, debugging shaders was difficult since there was no way to tell what values were actually being calculated in the shaders, so it involved visual debugging (i.e. using the grey scale to show the alphas, tuning parameters in the render loop). One particular trick that was useful for determining the max and min temperatures was to test values based on printed-out temperatures for thresholds between temperatures (using a simple if statement for the cutoff and playing through the simulation). An ideal cut off would mean that 99% of the particles fall in the same color.

These images show that there was something wrong with the clipping, which was fixed by reading the OpenGL documentation to set up blending properly. They did help with tuning the alpha calculation though.
This was a pretty good cut-off, most of the particles were above the temperature threshold except for the portions in red.

Results

Below is a selected demo of our final simulation:

All the demos: google drive

Key Takeaways

  1. Challenges in 3D Supernova Simulation:
    • Simulating a supernova explosion in three dimensions presented significant challenges due to the complex interplay of gravitational forces, fluid dynamics, and thermodynamic properties like temperature, velocity, and pressure. We encountered difficulties in realistically modeling these forces simultaneously, which required a deep dive into astrophysical principles and iterative refinement of our simulation parameters.
  1. Learning from Fluid Mechanics Integration:
    • Integrating fluid mechanics into our particle simulation framework was both challenging and enlightening. The process highlighted the critical role of fluid dynamics in simulating the behavior of gaseous elements within a star. We learned to adapt fluid dynamics theories to the discrete nature of particle systems, enhancing our understanding of how gases behave under extreme conditions like those found in supernovas.
  1. Complexities of Temperature Computation and Visualization:
    • Calculating and visualizing temperature within the simulation proved to be one of the most complex aspects of our project. We struggled with the accurate computation of temperature gradients and the dynamic updating of shader parameters to visually represent these changes. This challenge emphasized the necessity for robust computational algorithms and underscored the intricate relationship between physical properties and their visual representation.
  1. Selecting and Implementing Appropriate Physics Equations:
    • Choosing the right physics equations to model the detailed stages of a supernova required extensive research and practical testing. We learned the importance of selecting equations that not only reflect true astrophysical phenomena but also integrate seamlessly into our computational framework, balancing accuracy with computational feasibility.
  1. Lack of References:
    • As mentioned before, a supernova explosion is much more complex than what we initially thought. Papers detailing how the astrophysics of a supernova explosion worked involved numerous complex equations where the correct ones to use vary tremendously across different stages of the explosion. Most of the simulations that are available are rendered on much more capable machines like supercomputers which achieve computational speeds far beyond what we have available. As a result, we could only create a simplified version of the explosion based on the research that we have done into those papers based on our own understanding.

Member Contributions

Manan Bhargava (manan.bhargava@berkeley.edu)

  • Ideation, brainstorming, physics equations development
  • Organizing documentation, compiling research
  • Adding some logic into the codebase for the temperature
  • Report creation

+

  • This approach effectively models the internal friction between particles, which is crucial for simulating fluid flow and interactions in scenarios such as gas dynamics in supernovae. The choice of the cubic spline kernel for viscosity is motivated by its smoothness and compact support, which are beneficial for numerical stability and computational efficiency in particle-based simulations.

2. Temperature Calculation:

  • computeTemperature: This method estimates the temperature of particles based on their kinetic energy. The kinetic theory of gases relates the microscopic motions of individual particles to the macroscopic temperatures observed in a gas. By calculating the temperature as a function of kinetic energy using the Boltzmann constant, this method allows the simulation to dynamically update particle properties in response to changes in their velocities and interactions, facilitating the accurate simulation of heat transfer and thermal effects crucial for modeling the thermonuclear processes in supernovas.

Integration into the Simulation Loop

Within ParticleSolverCPUFluid.cpp, these methods are integrated into the particle update loop, ensuring that each particle's behavior is governed by physically accurate, temperature-dependent properties:

  • Temperature-dependent dynamics: By integrating the temperature calculations directly into the update loop, we ensure that the physical properties of each particle, such as viscosity and pressure forces, are correctly updated based on the local thermal conditions. This integration is critical for modeling the complex interplay of thermal energy, radiation pressure, and gravity that drives the evolution of a supernova.
  • Pressure and gravitational forces: Modifications to the pressure force computations account for the additional explosive outward forces generated by high temperatures in the supernova core. Similarly, gravitational calculations are adjusted to accurately simulate the collapse of the core and the subsequent expulsion of the outer layers. This approach allows our simulation to dynamically model both the implosion and explosion phases of a supernova, capturing the cyclical nature of compression and expansion seen in these events.

By carefully implementing and integrating these advanced computational methods, we have significantly enhanced the realism and scientific accuracy of our supernova simulation. Each method has been tailored to reflect the unique conditions of supernova physics, allowing us to explore this cataclysmic event with unprecedented detail and fidelity.

Shader Improvements

Implementation

Using knowledge from Project 4, we modified the original vertex and fragment shaders to fit our needs. The main features we added were gaseous particles and better color mapping.

For gaseous particles, this mostly involved rendering each individual particle as a blurred sphere based on particle characteristics such as mass, and distance from origin. The mass component was important since each simulation particle represents multiple gaseous particles which would make up the region around that simulation particle. The more mass, the more apparent and brighter the simulation particle should appear. The distance from the origin was used to fix a problem where particles appeared clumpy when they spread apart. The essential idea is for each pixel, we adjust the alpha based on its distance on the distance from the particle and the size of the particle (more spread-out gasses are thinner). The formula we ended up using was (0.25f-abs(dist)) * 4.0f / particleSize.

The particles don’t feel cohesive as they should be.
When adjusting sizes of spread out particles, it resembles a gas more.

We then added back the original particles to make the cloud fuller and less like a random blur in the screen.

Blue initial state
Yellow after explosion

Then, for colors, we essentially used the temperature for the hue, velocity for the value, and a constant float of 1.0f for our saturation. This involved using the OpenGL C++ API to create a new buffer to feed in particle temperatures. We also normalized the temperatures and velocities using this formula (generalized): clamp(characteristic - min_val / max_val, 0.0, 1.0). We then converted this HSV color to RGB.

Side view
Temperatures are a little inaccurate

Debugging

In general, debugging shaders was difficult since there was no way to tell what values were actually being calculated in the shaders, so it involved visual debugging (i.e. using the grey scale to show the alphas, tuning parameters in the render loop). One particular trick that was useful for determining the max and min temperatures was to test values based on printed-out temperatures for thresholds between temperatures (using a simple if statement for the cutoff and playing through the simulation). An ideal cut off would mean that 99% of the particles fall in the same color.

These images show that there was something wrong with the clipping, which was fixed by reading the OpenGL documentation to set up blending properly. They did help with tuning the alpha calculation though.

program-structure

This was a pretty good cut-off, most of the particles were above the temperature threshold except for the portions in red.

Results

Below is a selected demo of our final simulation:

All the demos: google drive

Final Project Video

Key Takeaways

  1. Challenges in 3D Supernova Simulation:
    • Simulating a supernova explosion in three dimensions presented significant challenges due to the complex interplay of gravitational forces, fluid dynamics, and thermodynamic properties like temperature, velocity, and pressure. We encountered difficulties in realistically modeling these forces simultaneously, which required a deep dive into astrophysical principles and iterative refinement of our simulation parameters.
  1. Learning from Fluid Mechanics Integration:
    • Integrating fluid mechanics into our particle simulation framework was both challenging and enlightening. The process highlighted the critical role of fluid dynamics in simulating the behavior of gaseous elements within a star. We learned to adapt fluid dynamics theories to the discrete nature of particle systems, enhancing our understanding of how gases behave under extreme conditions like those found in supernovas.
  1. Complexities of Temperature Computation and Visualization:
    • Calculating and visualizing temperature within the simulation proved to be one of the most complex aspects of our project. We struggled with the accurate computation of temperature gradients and the dynamic updating of shader parameters to visually represent these changes. This challenge emphasized the necessity for robust computational algorithms and underscored the intricate relationship between physical properties and their visual representation.
  1. Selecting and Implementing Appropriate Physics Equations:
    • Choosing the right physics equations to model the detailed stages of a supernova required extensive research and practical testing. We learned the importance of selecting equations that not only reflect true astrophysical phenomena but also integrate seamlessly into our computational framework, balancing accuracy with computational feasibility.
  1. Lack of References:
    • As mentioned before, a supernova explosion is much more complex than what we initially thought. Papers detailing how the astrophysics of a supernova explosion worked involved numerous complex equations where the correct ones to use vary tremendously across different stages of the explosion. Most of the simulations that are available are rendered on much more capable machines like supercomputers which achieve computational speeds far beyond what we have available. As a result, we could only create a simplified version of the explosion based on the research that we have done into those papers based on our own understanding.

Member Contributions

Manan Bhargava (manan.bhargava@berkeley.edu)

  • Ideation, brainstorming, physics equations development
  • Organizing documentation, compiling research
  • Adding some logic into the codebase for the temperature
  • Report creation

Snehaa Ganesh Kumar (snehaa@berkeley.edu)

  • Shock Wave Dynamics
  • Pressure & Gravity Modifications for Core-Collapse, Explosion Multiplier
  • Report creation
  • Help Out With Report + Brainstorming

Nak Vong (kiriratanakvong@berkeley.edu)

  • Added Density, Temperature, and Viscosity for particles in the particle system
  • Added Pressure Force exerted on each particle from neighboring particles
  • Help Out With Report + Brainstorming

Brandon Wong (bwong928@berkeley.edu)

  • Coding Shaders, Temperature Map, and Gaseous Particles
  • Coding Miscellaneous Infrastructure and Boilerplate
  • Help Out With Report + Brainstorming

References

  1. Murphy, Jeremiah W., and Adam Burrows. "An Analytic Model of the Ray-by-Ray Approximation for Rotating Core Collapse." Accepted for publication in ApJ. arXiv preprint arXiv:0805.3345 (2008).
  1. Bethe, Hans A. "Supernova Mechanisms." Reviews of Modern Physics 62, no. 4 (1990): 801.
  1. Koschier, Dan, Jan Bender, Barbara Solenthaler, and Matthias Teschner. "Smoothed Particle Hydrodynamics Techniques for the Physics Based Simulation of Fluids and Solids." arXiv preprint arXiv:2010.11254 (2020).
  1. Pan, Kuo-Chuan, Matthias Liebendörfer, Matthias Hempel, and Friedrich-Karl Thielemann. "Two-Dimensional Core-Collapse Supernova Simulations with the Isotropic Diffusion Source Approximation for Neutrino Transport." Accepted for publication in ApJ. arXiv preprint arXiv:1505.02513 (2015).
  1. Vivas, Marc. "N-body Simulation GitHub Repository." Accessed April 30, 2024. https://github.com/MarcVivas/N-body/tree/main.