Skip to content
Snippets Groups Projects
Commit 6497e9a5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'updated_difffloat' into 'master'

Updated difffloat

Two changes:

 - By default, `testPair` does not produce cells with perturbed positions.
 - The difffloat script takes an additional (optional) argument to specify how many lines/particles have to be checked. I have updated the bash scripts to follow that new policy.

Re-assign to me if you are happy with it. Thanks !

See merge request !142
parents 4effc52c 3b602c34
No related branches found
No related tags found
1 merge request!142Updated difffloat
......@@ -28,12 +28,18 @@ rel_tol = 1e-7
# Comparisons are done both in absolute and relative terms
# Individual tolerances for each column can be provided in a file
# The (cube root of) the number of lines to check is provided as
# an optional 4th argument
file1 = sys.argv[1]
file2 = sys.argv[2]
fileTol = ""
number_to_check = -1
if len(sys.argv) == 5:
number_to_check = int(sys.argv[4])
if len(sys.argv) == 4:
fileTol = ""
if len(sys.argv) >= 4:
fileTol = sys.argv[3]
data1 = loadtxt(file1)
......@@ -67,8 +73,17 @@ else:
absTol = dataTol[0,:]
relTol = dataTol[1,:]
n_lines_to_check = 0
if number_to_check > 0:
n_lines_to_check = number_to_check**3
n_lines_to_check = min(n_lines_to_check, n_lines)
print "Checking the first %d particles."%n_lines_to_check
else:
n_lines_to_check = n_lines
print "Checking all particles in the file."
error = False
for i in range(n_lines):
for i in range(n_lines_to_check):
for j in range(n_columns):
abs_diff = abs(data1[i,j] - data2[i,j])
......@@ -80,7 +95,7 @@ for i in range(n_lines):
rel_diff = 0.
if( abs_diff > absTol[j]):
print "Absolute difference larger than tolerance (%e) on line %d, column %d:"%(absTol[j], i,j)
print "Absolute difference larger than tolerance (%e) for particle %d, column %d:"%(absTol[j], i,j)
print "%10s: a = %e"%("File 1", data1[i,j])
print "%10s: b = %e"%("File 2", data2[i,j])
print "%10s: |a-b| = %e"%("Difference", abs_diff)
......@@ -88,7 +103,7 @@ for i in range(n_lines):
error = True
if( rel_diff > relTol[j]):
print "Relative difference larger than tolerance (%e) on line %d, column %d:"%(relTol[j], i,j)
print "Relative difference larger than tolerance (%e) for particle %d, column %d:"%(relTol[j], i,j)
print "%10s: a = %e"%("File 1", data1[i,j])
print "%10s: b = %e"%("File 2", data2[i,j])
print "%10s: |a-b|/|a+b| = %e"%("Difference", rel_diff)
......
......@@ -3,6 +3,6 @@ rm brute_force_27_standard.dat swift_dopair_27_standard.dat
./test27cells -p 6 -r 1 -d 0 -f standard
python difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat tolerance.dat
python difffloat.py brute_force_27_standard.dat swift_dopair_27_standard.dat tolerance.dat 6
exit $?
......@@ -3,6 +3,6 @@ rm brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat
./test27cells -p 6 -r 1 -d 0.1 -f perturbed
python difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat tolerance.dat
python difffloat.py brute_force_27_perturbed.dat swift_dopair_27_perturbed.dat tolerance.dat 6
exit $?
......@@ -180,7 +180,7 @@ void runner_dopair1_density(struct runner *r, struct cell *ci, struct cell *cj);
int main(int argc, char *argv[]) {
size_t particles = 0, runs = 0, volume, type = 0;
double offset[3] = {0, 0, 0}, h = 1.1255, size = 1., rho = 1.;
double perturbation = 0.1;
double perturbation = 0.;
struct cell *ci, *cj;
struct space space;
struct engine engine;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment