Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-10 09:05:52

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/optical/detail/OpticalUtils.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "celeritas/Constants.hh"
0012 #include "celeritas/Quantities.hh"
0013 
0014 namespace celeritas
0015 {
0016 namespace optical
0017 {
0018 namespace detail
0019 {
0020 //---------------------------------------------------------------------------//
0021 /*!
0022  * Convert a native-system wavelength into a photon energy.
0023  */
0024 inline CELER_FUNCTION units::MevEnergy
0025 wavelength_to_energy(real_type wavelength)
0026 {
0027     CELER_EXPECT(wavelength > 0);
0028     return native_value_to<units::MevEnergy>(
0029         (constants::h_planck * constants::c_light) / wavelength);
0030 }
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Convert a photon energy to native-system wavelength.
0035  */
0036 inline CELER_FUNCTION real_type energy_to_wavelength(units::MevEnergy energy)
0037 {
0038     CELER_EXPECT(energy > zero_quantity());
0039     return (constants::h_planck * constants::c_light)
0040            / native_value_from(energy);
0041 }
0042 
0043 //---------------------------------------------------------------------------//
0044 }  // namespace detail
0045 }  // namespace optical
0046 }  // namespace celeritas