Skip to content
Snippets Groups Projects
Commit 7fc4cc73 authored by Bert Vandenbroucke's avatar Bert Vandenbroucke
Browse files

Added extra adiabatic index definitions to be used in Riemann solvers. Added...

Added extra adiabatic index definitions to be used in Riemann solvers. Added unit test to check values.
parent 95c0564d
Branches
Tags
1 merge request!223Merge Gizmo-SPH into the master branch
......@@ -70,7 +70,7 @@ tests/testPair.sh
tests/testPairPerturbed.sh
tests/testParser.sh
tests/testReading.sh
tests/testRiemann
theory/latex/swift.pdf
theory/kernel/kernels.pdf
......
......@@ -36,18 +36,42 @@
#define hydro_gamma 1.66666666666666667f
#define hydro_gamma_minus_one 0.66666666666666667f
#define hydro_one_over_gamma_minus_one 1.5f
#define hydro_gamma_plus_one_over_two_gamma 0.8f
#define hydro_gamma_minus_one_over_two_gamma 0.2f
#define hydro_gamma_minus_one_over_gamma_plus_one 0.25f
#define hydro_two_over_gamma_plus_one 0.75f
#define hydro_two_over_gamma_minus_one 3.0f
#define hydro_gamma_minus_one_over_two 0.33333333333333333f
#define hydro_two_gamma_over_gamma_minus_one 5.0f
#define hydro_one_over_gamma 0.6f
#elif defined(HYDRO_GAMMA_4_3)
#define hydro_gamma 1.33333333333333333f
#define hydro_gamma_minus_one 0.33333333333333333f
#define hydro_one_over_gamma_minus_one 3.f
#define hydro_gamma_plus_one_over_two_gamma 0.875f
#define hydro_gamma_minus_one_over_two_gamma 0.125f
#define hydro_gamma_minus_one_over_gamma_plus_one 0.142857143f
#define hydro_two_over_gamma_plus_one 0.857142857f
#define hydro_two_over_gamma_minus_one 6.0f
#define hydro_gamma_minus_one_over_two 0.166666666666666666f
#define hydro_two_gamma_over_gamma_minus_one 8.0f
#define hydro_one_over_gamma 0.75f
#elif defined(HYDRO_GAMMA_2_1)
#define hydro_gamma 2.f
#define hydro_gamma_minus_one 1.f
#define hydro_one_over_gamma_minus_one 1.f
#define hydro_gamma_plus_one_over_two_gamma 0.75f
#define hydro_gamma_minus_one_over_two_gamma 0.25f
#define hydro_gamma_minus_one_over_gamma_plus_one 0.33333333333333333f
#define hydro_two_over_gamma_plus_one 0.66666666666666666f
#define hydro_two_over_gamma_minus_one 2.0f
#define hydro_gamma_minus_one_over_two 0.5f
#define hydro_two_gamma_over_gamma_minus_one 4.0f
#define hydro_one_over_gamma 0.5f
#else
......
......@@ -23,12 +23,14 @@ AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS
# List of programs and scripts to run in the test suite
TESTS = testGreetings testMaths testReading.sh testSingle testKernel testSymmetry \
testPair.sh testPairPerturbed.sh test27cells.sh test27cellsPerturbed.sh \
testParser.sh testSPHStep test125cells.sh testKernelGrav testFFT
testParser.sh testSPHStep test125cells.sh testKernelGrav testFFT \
testRiemann
# List of test programs to compile
check_PROGRAMS = testGreetings testReading testSingle testTimeIntegration \
testSPHStep testPair test27cells test125cells testParser \
testKernel testKernelGrav testFFT testInteractions testMaths testSymmetry
testKernel testKernelGrav testFFT testInteractions testMaths testSymmetry \
testRiemann
# Sources for the individual programs
testGreetings_SOURCES = testGreetings.c
......@@ -61,6 +63,8 @@ testFFT_SOURCES = testFFT.c
testInteractions_SOURCES = testInteractions.c
testRiemann_SOURCES = testRiemann.c
# Files necessary for distribution
EXTRA_DIST = testReading.sh makeInput.py testPair.sh testPairPerturbed.sh \
test27cells.sh test27cellsPerturbed.sh tolerance.dat testParser.sh \
......
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (C) 2016 Bert Vandenbroucke (bert.vandenbroucke@gmail.com).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "adiabatic_index.h"
#include "error.h"
void check_value(float a, float b, const char* s) {
if (fabsf(a - b) > 1.e-6f) {
error("Values are inconsistent: %g %g (%s)!", a, b, s);
} else {
message("Values are consistent: %g %g (%s).", a, b, s);
}
}
void check_constants() {
float val;
val = 0.5 * (hydro_gamma + 1.0f) / hydro_gamma;
check_value(val, hydro_gamma_plus_one_over_two_gamma, "(gamma+1)/(2 gamma)");
val = 0.5 * (hydro_gamma - 1.0f) / hydro_gamma;
check_value(val, hydro_gamma_minus_one_over_two_gamma, "(gamma-1)/(2 gamma)");
val = (hydro_gamma - 1.0f) / (hydro_gamma + 1.0f);
check_value(val, hydro_gamma_minus_one_over_gamma_plus_one,
"(gamma-1)/(gamma+1)");
val = 2.0f / (hydro_gamma + 1.0f);
check_value(val, hydro_two_over_gamma_plus_one, "2/(gamma+1)");
val = 2.0f / (hydro_gamma - 1.0f);
check_value(val, hydro_two_over_gamma_minus_one, "2/(gamma-1)");
val = 0.5f * (hydro_gamma - 1.0f);
check_value(val, hydro_gamma_minus_one_over_two, "(gamma-1)/2");
val = 2.0f * hydro_gamma / (hydro_gamma - 1.0f);
check_value(val, hydro_two_gamma_over_gamma_minus_one, "(2 gamma)/(gamma-1)");
val = 1.0f / hydro_gamma;
check_value(val, hydro_one_over_gamma, "1/gamma");
}
int main() {
check_constants();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment