# sod's test by lax-friedrichs method

 Register Blogs Members List Search Today's Posts Mark Forums Read

December 15, 2018, 07:14
sod's test by lax-friedrichs method
#1
New Member

Join Date: Dec 2018
Posts: 1
Rep Power: 0
hi everyone!
I've been solving Sod's Shock Tube Problem with Lax-Friedrichs method on C++. I use this link as the main one. But I face the problem with defining entropy. I found
• density,
• velocity,
• pressure,
• Mach number,
• speed of sound;
but entropy fails. Can anyone help me with it?

P.S. I attached the archive with code and graphs
Attached Files
 sod laxfriedrichs.zip (152.5 KB, 20 views)

 December 20, 2018, 13:40 #2 Senior Member     - Join Date: Jul 2012 Location: Germany Posts: 184 Rep Power: 13 Dear mend4x, Entropy in general is a value, which is calculated via integral relation. This means, you have to know the reference state to compare your solution. Nevertheless you can compare the difference between two neighboor cells or you can shift your solution to the correct level. You should also check if the reference solution uses Entropy per mass or Entropy per volume. If your calculation variables match the reference, then the problem is only a post-processing issue. __________________ Check out my side project: A multiphysics discontinuous Galerkin framework: Youtube, Gitlab.

 October 18, 2019, 00:58 #3 New Member   Join Date: Mar 2019 Posts: 2 Rep Power: 0 Hello, thanks for sharing. I've used your code to do some test of performance with c++. I would like to suggest to you two things. First is. The code is far from optimal because you are doing things in consecutive loops that take the same limits. For example here: for (int i = 0; i < nx; i++) { x[i] = x0 + i * dx; } for (int i = 0; i < nx; i++) { if (x[i] < 0) { ro[i] = 1.; u[i] = .0; p[i] = 100000.; } else if (x[i] >= 0) { ro[i] = .125; u[i] = .0; p[i] = 10000.; } } You can do simply: for (int i = 0; i < nx; i++) { x[i] = x0 + i * dx; if (x[i] < 0) { ro[i] = 1.; u[i] = .0; p[i] = 100000.; } else if (x[i] >= 0) { ro[i] = .125; u[i] = .0; p[i] = 10000.; } } But this things are minor issues, the real problem is you can't rely in your code since you don't initialize variables. I have done some memory test and some arrays like this V[nx][3], Vn[nx][3], F[nx][3] take eventually random values. Since your are passing this Vn[0][j] and Vn[nx][j] to V[0][j] and V[nx][j] without assign any value to Vn your code will give you unexpected results. You can simply initialize to some value by writing this simple line: double Vn[nx][3]{0}; thanks for sharing, cheers!

 Tags euler equation, lax-friedrichs, riemman, sod shock tube