use super::*;
use crate::utils::from_celsius_to_kelvin;
use dim::{
f64prefixes::MICRO,
ucum::{self, K, M},
};
pub const META: CrystalMeta = CrystalMeta {
id: "LiNbO3_1",
name: "LiNbO3 1",
reference_url: "http://www.newlightphotonics.com/v1/LN-crystal.html",
axis_type: OpticAxisType::NegativeUniaxial,
point_group: PointGroup::HM_3m,
transmission_range: Some(ValidWavelengthRange(0.4e-9, 3.4e-9)),
temperature_dependence_known: true,
};
const DNX: f64 = -0.874e-6;
const DNY: f64 = DNX;
const DNZ: f64 = 39.073e-6;
#[allow(clippy::unreadable_literal)]
pub fn get_indices(wavelength: Wavelength, temperature: ucum::Kelvin<f64>) -> Indices {
let lambda_sq = (wavelength / (MICRO * M)).powi(2);
let mut nx = (4.9048 + 0.11768 / (lambda_sq - 0.04750) - 0.027169 * lambda_sq).sqrt();
let mut ny = nx;
let mut nz = (4.5820 + 0.099169 / (lambda_sq - 0.044432) - 0.021950 * lambda_sq).sqrt();
let f = *((temperature - from_celsius_to_kelvin(20.0)) / K);
nx += f * DNX;
ny += f * DNY;
nz += f * DNZ;
Indices::new(na::Vector3::new(nx, ny, nz))
}