use specs::prelude::*;
pub trait AtomicTransition {
fn mup() -> f64;
fn mum() -> f64;
fn muz() -> f64;
fn frequency() -> f64;
fn linewidth() -> f64;
fn saturation_intensity() -> f64;
fn rate_prefactor() -> f64;
fn gamma() -> f64;
fn wavelength() -> f64;
}
pub trait TransitionComponent : AtomicTransition + Component + Send + Sync + Default + Copy {}
impl<T: AtomicTransition + Component + Send + Sync + Default + Copy> TransitionComponent for T {}
#[macro_export]
macro_rules! transition {
(
$transition_name:ident,
$frequency: literal,
$linewidth: literal,
$saturation_intensity: literal,
$mup: expr,
$mum: expr,
$muz: expr
) => {
#[derive(Copy, Clone, Default)]
pub struct $transition_name;
impl $crate::laser_cooling::transition::AtomicTransition for $transition_name {
fn frequency() -> f64 { $frequency }
fn linewidth() -> f64 { $linewidth }
fn wavelength() -> f64 { crate::constant::C / $frequency }
fn mup() -> f64 { $mup }
fn mum() -> f64 { $mum }
fn muz() -> f64 { $muz }
fn saturation_intensity() -> f64 { $saturation_intensity }
fn rate_prefactor() -> f64 { ($linewidth * 2.0 * std::f64::consts::PI).powi(3) / ($saturation_intensity * 8.0) }
fn gamma() -> f64 { $linewidth * 2.0 * std::f64::consts::PI }
}
impl specs::Component for $transition_name {
type Storage = specs::VecStorage<Self>;
}
};
}