/*//////////////////////////////////////////////////////////////////// // // // Differential Rayleigh scattering cross section // // for polarized beam (cm2/g/sterad) // // // // Z : atomic number // // E : Energy (keV) // // theta : scattering polar angle (rad) // // phi : scattering azimuthal angle (rad) // // // /////////////////////////////////////////////////////////////////// */ float DCSP_Rayl(int Z, float E, float theta, float phi) { float F, q; if (Z<1 || Z>ZMAX) { ErrorExit("Z out of range in function DCSP_Rayl"); return 0; } if (E <= 0.) { ErrorExit("Energy <=0 in function DCSP_Rayl"); return 0; } q = MomentTransf(E , theta); F = FF_Rayl(Z, q); return AVOGNUM / AtomicWeight(Z) * F*F * DCSP_Thoms(theta, phi); }
int main(int argc, char **argv) { xrl_error *error = NULL; double cs; cs = DCSP_Rayl(26, 10.0, M_PI/4, M_PI/4, &error); assert(error == NULL); assert(fabs(cs - 0.17394690792051704) < 1E-6); cs = DCSP_Rayl(0, 10.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0); xrl_clear_error(&error); cs = DCSP_Rayl(ZMAX + 1, 10.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0); xrl_clear_error(&error); cs = DCSP_Rayl(26, 0.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, NEGATIVE_ENERGY) == 0); xrl_clear_error(&error); cs = DCSP_Rayl(26, 10.0, 0.0, M_PI/4, &error); assert(error == NULL); assert(fabs(cs - 0.5788126901827545) < 1E-6); cs = DCSP_Compt(26, 10.0, M_PI/4, M_PI/4, &error); assert(error == NULL); assert(fabs(cs - 0.005489497545806118) < 1E-6); cs = DCSP_Compt(0, 10.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0); xrl_clear_error(&error); cs = DCSP_Compt(ZMAX + 1, 10.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, Z_OUT_OF_RANGE) == 0); xrl_clear_error(&error); cs = DCSP_Compt(26, 0.0, M_PI/4, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, NEGATIVE_ENERGY) == 0); xrl_clear_error(&error); cs = DCSP_Compt(26, 10.0, 0.0, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, NEGATIVE_Q) == 0); xrl_clear_error(&error); cs = DCSP_KN(10.0, M_PI/4, M_PI/4, &error); assert(error == NULL); assert(fabs(cs - 0.05888029282784654) < 1E-6); cs = DCSP_KN(0.0, 0.0, M_PI/4, &error); assert(cs == 0.0); assert(error != NULL); assert(error->code == XRL_ERROR_INVALID_ARGUMENT); assert(strcmp(error->message, NEGATIVE_ENERGY) == 0); xrl_clear_error(&error); cs = DCSP_Thoms(M_PI/4, M_PI/4, &error); assert(error == NULL); assert(fabs(cs - 0.05955590775) < 1E-6); return 0; }