From fbef32528d3b4b2b2f694aa16d60c53511b1d402 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 9 Jul 2020 12:01:43 +0200 Subject: Add wavelength and electron_voltage, plus units, to geometry file --- libcrystfel/src/utils.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libcrystfel/src/utils.h') diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index a43263e0..04208530 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -54,9 +54,12 @@ /* -------------------------- Fundamental constants ------------------------ */ -/* Electron charge in C */ +/* Electron charge (Coulombs) */ #define ELECTRON_CHARGE (1.6021773e-19) +/* Electron rest mass (kg) */ +#define ELECTRON_MASS (9.1093837015e-31) + /* Planck's constant (Js) */ #define PLANCK (6.62606896e-34) @@ -194,6 +197,17 @@ static inline int within_tolerance(double a, double b, double percent) /* Photon energy (eV) to k (1/m) */ #define ph_eV_to_k(a) ((a)*ELECTRON_CHARGE/PLANCK/C_VACUO) +/* Electron accelerating voltage (V) to wavelength (m) */ +static inline double el_V_to_lambda(double E) +{ + double Estar; + + /* Relativistically corrected accelerating voltage */ + Estar = E * (1.0 + E * ELECTRON_CHARGE/(2.0*ELECTRON_MASS*C_VACUO*C_VACUO)); + + return PLANCK / sqrt(2.0*ELECTRON_MASS*ELECTRON_CHARGE*Estar); +} + /* ------------------------------ Message logging ---------------------------- */ -- cgit v1.2.3