Version 5 (modified by 13 years ago) ( diff ) | ,
---|
Building a 1D Hydro Code
Introduction
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.
The Euler Equations
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.
Name of Law | Formula |
Conservation of Mass | |
Conservation of Momentum | |
Conservation of Energy |
Where
Solving the Riemann Problem
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.
Discretisation
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.
Godunov's First Order Upwind Scheme
Program Outline
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.
- Read all input data necessary for problem
- Initialize domain cells
- Begin time stepping procedure
- Apply boundary conditions for "ghost" cells
- Impose CFL condition to get appropriate time step
- Begin flux calculation procedure
- Solve local Riemann problem
- Use solution from Riemann solver to compute fluxes
- Repeat flux calculation procedure until fluxes are computed for all cells
- Use fluxes to update conserved variables
- Use updated conserved variables to update primitive variables
- Repeat time stepping procedure until final time is reached
- Output data to a file
Test Results
Five different tests were run in accordance with the tests in Ch. 6 of Toro's aforementioned book. All tests were run with a domain length of 1.0 and 100 computing cells. For the first five time steps a CFL of 0.18 was used to give the various waves time to develop. For the time steps following, a more natural CFL of 0.9 was used to obtain more accurate results. Here is a table of all the input data for each test:
Test Number | Discontinuity Position | Output Time | ||||||
---|---|---|---|---|---|---|---|---|
1 | 0.3 | 0.2 | 1.0 | 0.75 | 1.0 | 0.125 | 0.0 | 0.1 |
2 | 0.5 | 0.15 | 1.0 | -2.0 | 0.4 | 1.0 | 2.0 | 0.4 |
3 | 0.5 | 0.012 | 1.0 | 0.0 | 1000.0 | 1.0 | 0.0 | 0.01 |
4 | 0.4 | 0.035 | 5.99924 | 19.5975 | 460.894 | 5.99242 | -6.19633 | 46.0950 |
5 | 0.8 | 0.012 | 1.0 | -19.59745 | 1000.0 | 1.0 | -19.59745 | 0.01 |
Density, velocity, pressure, and internal energy were plotted for every test. The following images show the numerical results (points) alongside the exact solution (line). All plots appear to be the same as those presented by Toro. Therefore, the codes SEEQUOD and SEEQUODexact must be correct.
Test 1
![]() | ![]() |
![]() | ![]() |
Test 2
![]() | ![]() |
![]() | ![]() |
Test 3
![]() | ![]() |
![]() | ![]() |
Test 4
![]() | ![]() |
![]() | ![]() |
Test 5
![]() | ![]() |
![]() | ![]() |
Attachments (34)
- test1_intenergy.png (14.3 KB ) - added by 13 years ago.
- test1_pressure.png (13.7 KB ) - added by 13 years ago.
- test1_velocity.png (12.5 KB ) - added by 13 years ago.
- test2_density.png (17.1 KB ) - added by 13 years ago.
- test2_intenergy.png (17.9 KB ) - added by 13 years ago.
- test2_pressure.png (16.4 KB ) - added by 13 years ago.
- test2_velocity.png (15.2 KB ) - added by 13 years ago.
- test3_density.png (10.7 KB ) - added by 13 years ago.
- test3_intenergy.png (12.9 KB ) - added by 13 years ago.
- test3_pressure.png (12.4 KB ) - added by 13 years ago.
- test3_velocity.png (12.7 KB ) - added by 13 years ago.
- test4_density.png (10.9 KB ) - added by 13 years ago.
- test4_intenergy.png (12.2 KB ) - added by 13 years ago.
- test4_pressure.png (12.8 KB ) - added by 13 years ago.
- test4_velocity.png (9.9 KB ) - added by 13 years ago.
- test5_density.png (10.2 KB ) - added by 13 years ago.
- test5_intenergy.png (12.6 KB ) - added by 13 years ago.
- test5_pressure.png (12.5 KB ) - added by 13 years ago.
- test5_velocity.png (12.8 KB ) - added by 13 years ago.
- hllc_test1_density.png (11.5 KB ) - added by 13 years ago.
- test1_density.png (11.5 KB ) - added by 13 years ago.
- roe_nofix_test1_density.png (11.5 KB ) - added by 13 years ago.
- roe_withfix_test1_density.png (11.5 KB ) - added by 13 years ago.
- hllc_test1_intenergy.png (13.8 KB ) - added by 13 years ago.
- hllc_test1_pressure.png (11.5 KB ) - added by 13 years ago.
- hllc_test1_velocity.png (12.3 KB ) - added by 13 years ago.
- muscl_test1_density.png (11.3 KB ) - added by 13 years ago.
- muscl_test1_intenergy.png (13.7 KB ) - added by 13 years ago.
- muscl_test1_pressure.png (11.3 KB ) - added by 13 years ago.
- muscl_test1_velocity.png (12.2 KB ) - added by 13 years ago.
- muscl_test2_density.png (17.2 KB ) - added by 13 years ago.
- muscl_test2_intenergy.png (16.7 KB ) - added by 13 years ago.
- muscl_test2_pressure.png (16.0 KB ) - added by 13 years ago.
- muscl_test2_velocity.png (14.8 KB ) - added by 13 years ago.
Download all attachments as: .zip