From 25c19a8888197db68ada2a40c0917e1f534323d7 Mon Sep 17 00:00:00 2001 From: tlatorre Date: Thu, 5 Jul 2018 16:49:46 -0400 Subject: refractive_index.c -> optics.c --- Makefile | 2 +- optics.c | 30 ++++++++++++++++++++++++++++++ optics.h | 6 ++++++ refractive_index.c | 30 ------------------------------ refractive_index.h | 6 ------ test.c | 2 +- 6 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 optics.c create mode 100644 optics.h delete mode 100644 refractive_index.c delete mode 100644 refractive_index.h diff --git a/Makefile b/Makefile index 3e0c0ee..ee4d341 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ calculate_limits: calculate_limits.c solid_angle.o: solid_angle.c -test: test.c solid_angle.c refractive_index.c muon.c +test: test.c solid_angle.c optics.c muon.c clean: rm *.o calculate_limits test diff --git a/optics.c b/optics.c new file mode 100644 index 0000000..afcdd5e --- /dev/null +++ b/optics.c @@ -0,0 +1,30 @@ +#include +#include "optics.h" + +static double A0 = 0.243905091; +static double A1 = 9.53518094e-3; +static double A2 = -3.64358110e-3; +static double A3 = 2.65666426e-4; +static double A4 = 1.59189325e-3; +static double A5 = 2.45733798e-3; +static double A6 = 0.897478251; +static double A7 = -1.63066183e-2; +static double UV = 0.2292020; +static double IR = 5.432937; + +double get_index(double p, double wavelength, double T) +{ + /* Returns the index of pure water for a given density, wavelength, and + * temperature. The density should be in units of kg/m^3, the wavelength in + * nm, and the temperature in Celsius. */ + /* normalize the density, temperature, and pressure */ + p = p/1000.0; + wavelength = wavelength/589.0; + T = (T+273.15)/273.15; + + /* first we compute the right hand side of Equation 7 */ + double c = A0 + A1*p + A2*T + A3*pow(wavelength,2)*T + A4/pow(wavelength,2) + A5/(pow(wavelength,2)-pow(UV,2)) + A6/(pow(wavelength,2)-pow(IR,2)) + A7*pow(p,2); + c *= p; + + return sqrt((2*c+1)/(1-c)); +} diff --git a/optics.h b/optics.h new file mode 100644 index 0000000..5e39ea1 --- /dev/null +++ b/optics.h @@ -0,0 +1,6 @@ +#ifndef OPTICS_H +#define OPTICS_H + +double get_index(double p, double wavelength, double T); + +#endif diff --git a/refractive_index.c b/refractive_index.c deleted file mode 100644 index d7d07f9..0000000 --- a/refractive_index.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include "refractive_index.h" - -static double A0 = 0.243905091; -static double A1 = 9.53518094e-3; -static double A2 = -3.64358110e-3; -static double A3 = 2.65666426e-4; -static double A4 = 1.59189325e-3; -static double A5 = 2.45733798e-3; -static double A6 = 0.897478251; -static double A7 = -1.63066183e-2; -static double UV = 0.2292020; -static double IR = 5.432937; - -double get_index(double p, double wavelength, double T) -{ - /* Returns the index of pure water for a given density, wavelength, and - * temperature. The density should be in units of kg/m^3, the wavelength in - * nm, and the temperature in Celsius. */ - /* normalize the density, temperature, and pressure */ - p = p/1000.0; - wavelength = wavelength/589.0; - T = (T+273.15)/273.15; - - /* first we compute the right hand side of Equation 7 */ - double c = A0 + A1*p + A2*T + A3*pow(wavelength,2)*T + A4/pow(wavelength,2) + A5/(pow(wavelength,2)-pow(UV,2)) + A6/(pow(wavelength,2)-pow(IR,2)) + A7*pow(p,2); - c *= p; - - return sqrt((2*c+1)/(1-c)); -} diff --git a/refractive_index.h b/refractive_index.h deleted file mode 100644 index 5976eca..0000000 --- a/refractive_index.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef REFRACTIVE_INDEX_H -#define REFRACTIVE_INDEX_H - -double get_index(double p, double wavelength, double T); - -#endif diff --git a/test.c b/test.c index 3448565..7c5dd33 100644 --- a/test.c +++ b/test.c @@ -1,7 +1,7 @@ #include "solid_angle.h" #include #include -#include "refractive_index.h" +#include "optics.h" #include "muon.h" typedef int testFunction(char *err); -- cgit