diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-07-04 18:02:05 -0400 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-07-04 18:02:05 -0400 |
commit | fe4e7c42ab6198e4ebeb26e31ada1078a0965dba (patch) | |
tree | 91c0d5275a8dae8fb73d5f85e530ac9307003b8e /refractive_index.c | |
parent | 38a45d34f4c96e92a2a34ccd97383449fd5207ee (diff) | |
download | sddm-fe4e7c42ab6198e4ebeb26e31ada1078a0965dba.tar.gz sddm-fe4e7c42ab6198e4ebeb26e31ada1078a0965dba.tar.bz2 sddm-fe4e7c42ab6198e4ebeb26e31ada1078a0965dba.zip |
add a function to compute the refractive index of water as a function of wavelength
Diffstat (limited to 'refractive_index.c')
-rw-r--r-- | refractive_index.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/refractive_index.c b/refractive_index.c new file mode 100644 index 0000000..d7d07f9 --- /dev/null +++ b/refractive_index.c @@ -0,0 +1,30 @@ +#include <math.h> +#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)); +} |