Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-07 10:01:38

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/field/Types.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/cont/Array.hh"
0010 #include "corecel/math/ArrayUtils.hh"
0011 #include "celeritas/Quantities.hh"
0012 #include "celeritas/Types.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 // STRUCTS
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Store a track's position and momentum for field integration.
0021  */
0022 struct OdeState
0023 {
0024     using MomentumUnits = units::MevMomentum;
0025     using Real3 = Array<real_type, 3>;
0026 
0027     Real3 pos;  //!< Particle position
0028     Real3 mom;  //!< Particle momentum
0029 };
0030 
0031 //---------------------------------------------------------------------------//
0032 /*!
0033  * The result of a single integration.
0034  */
0035 struct FieldIntegration
0036 {
0037     OdeState mid_state;  //!< OdeState at the middle
0038     OdeState end_state;  //!< OdeState at the end
0039     OdeState err_state;  //!< Delta between one full step and two half steps
0040 };
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * The result of moving up to a certain distance along a step.
0045  */
0046 struct Substep
0047 {
0048     OdeState state;  //!< Post-step state
0049     real_type length;  //!< Actual curved step
0050 };
0051 
0052 //! \cond (CELERITAS_DOC_DEV)
0053 //---------------------------------------------------------------------------//
0054 // FUNCTIONS
0055 //---------------------------------------------------------------------------//
0056 /*!
0057  * Perform y <- ax + y for OdeState.
0058  */
0059 inline CELER_FUNCTION void axpy(real_type a, OdeState const& x, OdeState* y)
0060 {
0061     axpy(a, x.pos, &y->pos);
0062     axpy(a, x.mom, &y->mom);
0063 }
0064 //! \endcond
0065 
0066 }  // namespace celeritas