CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > System Analysis

sod's test by lax-friedrichs method

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 15, 2018, 08:14
Default sod's test by lax-friedrichs method
  #1
New Member
 
Join Date: Dec 2018
Posts: 1
Rep Power: 0
mend4x is on a distinguished road
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
File Type: zip sod laxfriedrichs.zip (152.5 KB, 20 views)
mend4x is offline   Reply With Quote

Old   December 20, 2018, 14:40
Default
  #2
Senior Member
 
Eifoehn4's Avatar
 
-
Join Date: Jul 2012
Location: Germany
Posts: 184
Rep Power: 14
Eifoehn4 is on a distinguished road
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.
Eifoehn4 is offline   Reply With Quote

Old   October 18, 2019, 01:58
Default
  #3
New Member
 
Join Date: Mar 2019
Posts: 2
Rep Power: 0
set::set() is on a distinguished road
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!
set::set() is offline   Reply With Quote

Reply

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


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 23:59.