|
[Sponsors] |
December 15, 2018, 08: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
P.S. I attached the archive with code and graphs |
|
December 20, 2018, 14:40 |
|
#2 |
Senior Member
-
Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 14 |
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. |
|
October 18, 2019, 01: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 |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OF 1.6 | Ubuntu 9.10 (64bit) | GLIBCXX_3.4.11 not found | piprus | OpenFOAM Installation | 22 | February 25, 2010 14:43 |
Problems in compiling paraview in Suse 10.3 platform | chiven | OpenFOAM Installation | 3 | December 1, 2009 08:21 |
SIMPLEC Method | meshkati | Main CFD Forum | 6 | November 19, 2009 01:48 |
test cases | Maciej Matyka | Main CFD Forum | 3 | November 24, 2004 09:27 |
time accuracy test | nat | Main CFD Forum | 0 | April 2, 2003 00:24 |