pub struct Photon {
pub energy_joules: f64,
}Expand description
A lightweight photon wrapper stored by energy in joules.
Fields§
§energy_joules: f64Photon energy in joules.
Implementations§
Source§impl Photon
impl Photon
Sourcepub fn from_energy_joules(energy_joules: f64) -> Option<Photon>
pub fn from_energy_joules(energy_joules: f64) -> Option<Photon>
Creates a photon from non-negative finite energy in joules.
Sourcepub fn from_frequency(frequency: f64) -> Option<Photon>
pub fn from_frequency(frequency: f64) -> Option<Photon>
Creates a photon from frequency.
Examples found in repository?
examples/facade_quantum.rs (line 9)
8fn main() -> Result<(), &'static str> {
9 let photon = Photon::from_frequency(1.0).ok_or("expected valid photon")?;
10 let quantum_numbers =
11 QuantumNumbers::new(2, 1, 0, 1).ok_or("expected valid quantum numbers")?;
12 let wavelength =
13 hydrogen_transition_wavelength(2, 1).ok_or("expected transition wavelength")?;
14
15 assert!(approx_eq(
16 photon.energy_joules(),
17 use_physics::PLANCK_CONSTANT
18 ));
19 assert!(approx_eq(quantum_numbers.spin_projection(), 0.5));
20 assert!(wavelength > 0.0);
21
22 Ok(())
23}Sourcepub fn from_wavelength(wavelength: f64) -> Option<Photon>
pub fn from_wavelength(wavelength: f64) -> Option<Photon>
Creates a photon from wavelength.
§Examples
use use_quantum::Photon;
let photon = Photon::from_wavelength(500.0e-9).ok_or("expected valid wavelength")?;
assert!(photon.energy_joules() > 0.0);Sourcepub const fn energy_joules(&self) -> f64
pub const fn energy_joules(&self) -> f64
Returns the photon energy in joules.
Examples found in repository?
examples/facade_quantum.rs (line 16)
8fn main() -> Result<(), &'static str> {
9 let photon = Photon::from_frequency(1.0).ok_or("expected valid photon")?;
10 let quantum_numbers =
11 QuantumNumbers::new(2, 1, 0, 1).ok_or("expected valid quantum numbers")?;
12 let wavelength =
13 hydrogen_transition_wavelength(2, 1).ok_or("expected transition wavelength")?;
14
15 assert!(approx_eq(
16 photon.energy_joules(),
17 use_physics::PLANCK_CONSTANT
18 ));
19 assert!(approx_eq(quantum_numbers.spin_projection(), 0.5));
20 assert!(wavelength > 0.0);
21
22 Ok(())
23}Sourcepub fn wavelength(&self) -> Option<f64>
pub fn wavelength(&self) -> Option<f64>
Returns the photon wavelength in meters.
Trait Implementations§
impl Copy for Photon
impl StructuralPartialEq for Photon
Auto Trait Implementations§
impl Freeze for Photon
impl RefUnwindSafe for Photon
impl Send for Photon
impl Sync for Photon
impl Unpin for Photon
impl UnsafeUnpin for Photon
impl UnwindSafe for Photon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more