Changes between Version 1 and Version 2 of u/ehansen/buildcode
- Timestamp:
- 10/28/11 10:12:38 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
u/ehansen/buildcode
v1 v2 4 4 I've created this page to document the important aspects of building a hydro code. It contains general information that I have learned from reading ''Riemann Solvers and Numerical Methods for Fluid Dynamics: A Practical Introduction'' by E.F. Toro. In the near future, it will contain useful information from my own personal experience as I build my first hydro code. 5 5 [[BR]] 6 == The E quations of Fluid Dynamics ==7 The first time I saw the fluid equations was in the normalconservative-law form. These are conceptually simple and make intuitive sense.6 == The Euler Equations == 7 These are the so called Euler Equations. They are also known as the fluid equations in conservative-law form. These are conceptually simple and make intuitive sense. 8 8 || Name of Law || Formula || 9 9 || Conservation of Mass || [[latex($\frac{\partial}{\partial t}\rho + \frac{\partial}{\partial x} (\rho v) = 0$)]] || 10 10 || Conservation of Momentum || [[latex($\frac{\partial}{\partial t} (\rho v) + \frac{\partial}{\partial x} (\rho v^2 + p) = 0$)]] || 11 11 || Conservation of Energy || [[latex($\frac{\partial}{\partial t} E + \frac{\partial}{\partial x} (v(E+p)) = 0$)]] || 12 Where [[latex($\rho$)]] is mass density, v is velocity (only in x-direction for 1D), p is pressure, and E is total energy per unit volume. E is further defined as [[latex($E = \rho(\frac{1}{2}v^2 + e)$)]] where e is the specific internal energy. Basically, these laws state that in a given volume, the change in a conserved quantity must be equal to the flux through the boundaries of that volume.12 Where [[latex($\rho$)]] is mass density, v is velocity (only in x-direction for 1D), p is pressure, and E is total energy per unit volume. E is further defined as [[latex($E = \rho(\frac{1}{2}v^2 + e)$)]] where e is the specific internal energy. The specific internal energy depends on the equation of state. For an ideal gas [[latex($e = \frac{p}{\rho(\gamma - 1)}$)]] where [[latex($\gamma$)]] is the ratio of specific heats. Basically, these laws state that in a given volume, the change in a conserved quantity must be equal to the flux through the boundaries of that volume. In other words, the conserved quantity is in front of the time derivative and its flux is in front of the spatial derivative. 13 13 [[BR]] 14 14 == Solving the Riemann Problem == 15 The Riemann problem is essentially the Euler equations with discrete initial conditions. Initial data has a left state and a right state, separated by a discontinuity. 15 16 [[BR]] 16 17 == Discretisation == 18 Discretisation is the process of taking a domain and dividing it into cells. Each cell contains data corresponding to a specific problem initialization thus creating many Riemann problems. In other words, each neighboring pair of cells is now a "local" Riemann problem. Given two neighboring cells, the left cell is the left data state, the right cell is the right data state, and the intercell boundary is the discontinuity position. Now each local Riemann problem can be solved and that solution can be used to calculate the fluxes required to update the cells to the next time step. 17 19 [[BR]] 18 20 == Godunov's First Order Upwind Scheme == 21 [[BR]] 22 == Program Outline == 23 These are the basic steps in my program SEEQUOD (Solver for Euler EQUations in One Dimension). SEEQUOD currently uses an exact Riemann solver, but will later be updated to use approximate Riemann solvers as well. Also, SEEQUOD currently uses a first order Godunov upwind scheme, but again will later be updated to use higher order update schemes. These steps should be general enough to apply to many codes that are used to solve the Euler Equations. 24 25 * Read all input data necessary for problem 26 * Initialize domain cells 27 * Begin time stepping procedure 28 * Apply boundary conditions for "ghost" cells 29 * Impose CFL condition to get appropriate time step 30 * Begin flux calculation procedure 31 * Solve local Riemann problem 32 * Use solution from Riemann solver to compute fluxes 33 * Repeat flux calculation procedure until fluxes are computed for all cells 34 * Use fluxes to update conserved variables 35 * Use updated conserved variables to update primitive variables 36 * Repeat time stepping procedure until final time is reached 37 * Output data to a file