diff options
-rw-r--r-- | test.c | 45 |
1 files changed, 41 insertions, 4 deletions
@@ -2,6 +2,10 @@ #include <math.h> #include <stdio.h> +/* Table of the values of solid angle for various values of r0/r and L/r. + * + * See Table 1 in http://www.umich.edu/~ners312/CourseLibrary/SolidAngleOfADiskOffAxis.pdf. */ + struct solid_angle_results { double L; double r0; @@ -17,7 +21,40 @@ struct solid_angle_results { {0.5,1.4,0.7428889}, {0.5,1.6,0.4841273}, {0.5,1.8,0.3287007}, - {0.5,2.0,0.2324189} + {0.5,2.0,0.2324189}, + {1.0,0.0,1.8403024}, + {1.0,0.2,1.8070933}, + {1.0,0.4,1.7089486}, + {1.0,0.6,1.5517370}, + {1.0,0.8,1.3488367}, + {1.0,1.0,1.1226876}, + {1.0,1.2,0.9003572}, + {1.0,1.4,0.7039130}, + {1.0,1.6,0.5436956}, + {1.0,1.8,0.4195415}, + {1.0,2.0,0.3257993}, + {1.5,0.0,1.0552591}, + {1.5,0.2,1.0405177}, + {1.5,0.4,0.9975504}, + {1.5,0.6,0.9301028}, + {1.5,0.8,0.8441578}, + {1.5,1.0,0.7472299}, + {1.5,1.2,0.6472056}, + {1.5,1.4,0.5509617}, + {1.5,1.6,0.4632819}, + {1.5,1.8,0.3866757}, + {1.5,2.0,0.3217142}, + {2.0,0.0,0.6633335}, + {2.0,0.2,0.6566352}, + {2.0,0.4,0.6370508}, + {2.0,0.6,0.6060694}, + {2.0,0.8,0.5659755}, + {2.0,1.0,0.5195359}, + {2.0,1.2,0.4696858}, + {2.0,1.4,0.4191714}, + {2.0,1.6,0.3702014}, + {2.0,1.8,0.3243908}, + {2.0,2.0,0.282707} }; int isclose(double a, double b, double rel_tol, double abs_tol) @@ -42,7 +79,7 @@ int test_solid_angle(char *err) solid_angle = get_solid_angle(pos,pmt,n,r); if (!isclose(solid_angle, 2*M_PI*(1-1/sqrt(2)), 1e-9, 0)) { - sprintf(err, "solid angle = %.2f, but expected %.2f", solid_angle, 2*M_PI*(1-1/sqrt(2))); + sprintf(err, "solid angle = %.5f, but expected %.5f", solid_angle, 2*M_PI*(1-1/sqrt(2))); return 1; } @@ -52,8 +89,8 @@ int test_solid_angle(char *err) solid_angle = get_solid_angle(pos,pmt,n,r); - if (!isclose(solid_angle, solid_angle_results[i].omega, 1e-5, 0)) { - sprintf(err, "solid angle = %.2f, but expected %.2f", solid_angle, solid_angle_results[i].omega); + if (!isclose(solid_angle, solid_angle_results[i].omega, 1e-4, 0)) { + sprintf(err, "solid angle = %.5f, but expected %.5f", solid_angle, solid_angle_results[i].omega); return 1; } } |