Code Monkey home page Code Monkey logo

fvmhd-dante's Introduction

Dante

3D finite volume ideal MHD solver on structured grid.

NOTE This code has been completely rewritten in Julia. Future versions will be maintained there.

Practice is more important than theory. Dante is a toy 3D finite-volume code for learning. This first version is implemented in MATLAB. Some main features of the code include:

  • Use primitive variables for visualization and conservative variables for computation;
  • Assimilate the idea of object and class for defining variables and function checks;
  • Apply to 1D/2D/3D Cartesian grid with the same kernel code;
  • 1st/2nd order Rusanov/HLLE scheme with forwar-Euler/modified-Euler explicit timestepping;
  • User-friendly input parameter control;
  • Optimized matrix operation, avoid nested loops as much as possible;
  • One logical CPU/GPU switch.

This code solves ideal MHD equations on a Cartesian mesh in 1/2/3D. It has the option of solving the energy equation (conservative form) or the pressure equation (nonconservative form). Currently only 1st and 2nd order face values are implemented. Rusanov and HLLE fluxes are implemented for face flux calculation.

One highlight feature is that there are no diverse branches for different dimensions: no additional "if" statement for 3D compared with 1D cases. The code is also organized in OOP, allowing potentially flexible extensions.

Getting Started

To get started, type

Main

All the parameters are set in Parameters.m. The initial condition setup needs to be improved, so that we don't need to modify inside State.m to switch between Riemann problems and custom tests.

Note that moments instead of velocities are stored in state_GV. I may need to change the index (Ux_,Uy_,Uz_) to (RhoUx_,RhoUy_,RhoUz_) for clarification. Also, there are no DivB control besides the eight-wave scheme. General Lagrange multiplier is for sure something to try.

GPU-enabled part is easily implemented in MATLAB. For 100,000 cells in 1D, this gives roughly 10 times speedup using GTX1080 compared with 4 core intel i7 6700k.

Prerequisites

MATLAB, Parallel Computing Toolbox, GPU-enabled driver (if using gpuArray).

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • All the nice guys who share their codes

fvmhd-dante's People

Contributors

henry2004y avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

fvmhd-dante's Issues

Missing parts

  • In order to fit in general structured grids, we need to take the face areas into account, as what is being done in BATS-R-US.

  • To handle 2nd order schemes, we need to modify the way of calculating face values while keeping face flux calculation the same.

  • In principle, it shouldn't be hard to solve a different set of conservative equations with the same module. I need to learn how OpenFoam do this. In BAT-S-RUS, all the fluxes are already implemented in one module ModFaceFlux|, and we select from a set of equation modules to choose the needed equations (i.e. number of variables, indexes, etc.).

Future development will continue in other places.

Problems found during debugging

Here is a record of bugs I introduced in coding.

  • One of the toughest problems in coding is to handle the transition between velocity and momentum. It is the missing of density in the formula of calculating phyical fluxes that kept me away from getting the correct solutions while debugging. The design choice is using momentum rather than velocity because it follows the natural pattern of conservation laws (i.e. primitive variables) and it is much eaiser to extend to relativistic scenarios.
  • Missing coefficients
  • Wrong signs for the source terms
  • Index shifts

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.