Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[example] Add an Euler equation solver #796

Merged
merged 6 commits into from Apr 17, 2020
Merged

Conversation

KLozes
Copy link
Collaborator

@KLozes KLozes commented Apr 16, 2020

Here's a compressible Euler equation solver! Its just a simple finite volume scheme with a HLLC Riemann solver. It already creates some nice images, but needs to be polished up a bit. I'll work on that tomorrow night :)

Related issue = #776

[Click here for the format server]

@KLozes KLozes changed the title Add an Euler equation solver example [example] Add an Euler equation solver Apr 16, 2020
@yuanming-hu
Copy link
Member

WOW! As a graphics person, I've been mainly playing with incompressible fluid simulations - i.e. those with a Chorin-style projection. I didn't realize compressible fluids can have stunning visual results as well! Thanks for adding this.

The implementation looks great to me. Just one nit: would it be possible to remove the dependency on matplotlib?

Another quick question: does the Taichi implementation with the CUDA backend have a comparable performance to https://www.youtube.com/watch?v=k72_YeNO7yU? I'm just curious about the current CUDA backend performance in Taichi.

@yuanming-hu yuanming-hu self-requested a review April 16, 2020 09:53
examples/euler.py Outdated Show resolved Hide resolved
@KLozes
Copy link
Collaborator Author

KLozes commented Apr 16, 2020

Yeah! The shocks and acoustic waves really add beautiful visuals that you cant really get in incompressible flow. I'm also excited to improve this with some better discretization schemes and AMR. See https://youtu.be/txk-VO1hzBY?t=2079.

I can get rid of the matplotlib dependency. I guess I'll just make a colormap manually. Perhaps we could add colormap as an optional argument to set_image()? We could create our own library of colormaps if we need to.

I'll try time them both tonight and let you know. If everything is working right with Taichi, I think it should easily beat my CUDA version.

@archibate
Copy link
Collaborator

archibate commented Apr 16, 2020

I'll try time them both tonight and let you know. If everything is working right with Taichi, I think it should easily beat my CUDA version.

Many thanks! If possible, could you also try timing against ti.opengl? CUDA sometimes mysteriously run 2x slower than OpenGL... according to @yuanming-hu.

@yuanming-hu
Copy link
Member

I'll try time them both tonight and let you know. If everything is working right with Taichi, I think it should easily beat my CUDA version.

Many thanks! If possible, could you also try timing against ti.opengl? CUDA sometimes mysteriously run 2x slower than OpenGL... according to @yuanming-hu.

I tried OpenGL, yet it seems to get stuck at compilation...

@yuanming-hu
Copy link
Member

yuanming-hu commented Apr 16, 2020

Yeah! The shocks and acoustic waves really add beautiful visuals that you cant really get in incompressible flow.

Right - I guess in graphics explosion effects are somewhat underexploited.

I'm also excited to improve this with some better discretization schemes and AMR. See https://youtu.be/txk-VO1hzBY?t=2079.

Awesome!

I can get rid of the matplotlib dependency. I guess I'll just make a colormap manually. Perhaps we could add colormap as an optional argument to set_image()? We could create our own library of colormaps if we need to.

If that's > 5 lines of code let's simply do something like

try:
  import matplotlib
except:
  print('Please pip install matplotlib')
  exit(-1)

Installing matplotlib is no big deal, and it's a nice demonstration on how to use taichi with other libraries anyway.

I'll try time them both tonight and let you know. If everything is working right with Taichi, I think it should easily beat my CUDA version.

Thanks! I think this grid-based solver can be a great benchmark for taichi. Having timings on a handwritten CUDA reference is also awesome. We can even compare the lines of code in both implementations - this will definitely attract CDF people who are still hand-writting CUDA or using matlab.

@archibate archibate self-requested a review April 17, 2020 00:43
@archibate
Copy link
Collaborator

archibate commented Apr 17, 2020

I tried OpenGL, yet it seems to get stuck at compilation...

It's not stuck, it's just taking a very long time for NV GL to compile, once shaders in eular.py is compiled, the next time you launch eular.py won't take time since NV will cache it's compile result (by hashing glsl code!). (yes, even if you exit python, NV GL keep your shader caches!)
Try TI_LOG_LEVEL=trace, you'll see glCompileShader IN and no OUT.
edit: seems put dt to the first fix the problem.
edit: let's move discussion about this to #804.

@KLozes
Copy link
Collaborator Author

KLozes commented Apr 17, 2020

I think this is ready! I also added a fancy modern discretization scheme that seems to have almost 4x higher resolution than the classical muscl method :). I'll work on some timing comparisons tomorrow. heres a nice pic!
euler_equations

Copy link
Member

@yuanming-hu yuanming-hu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much! This looks incredibly beautiful...

@yuanming-hu yuanming-hu merged commit d3ada62 into taichi-dev:master Apr 17, 2020
yuanming-hu pushed a commit that referenced this pull request Apr 17, 2020
Co-authored-by: Kenneth Lozes <klozes@system76-pc.localdomain>
@KLozes KLozes deleted the euler branch June 23, 2021 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants