Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:09:04

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/MakeMagFieldPropagator.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Assert.hh"
0010 #include "corecel/Macros.hh"
0011 #include "corecel/math/Algorithms.hh"
0012 #include "celeritas/Quantities.hh"
0013 #include "celeritas/geo/GeoTrackView.hh"
0014 #include "celeritas/phys/ParticleTrackView.hh"
0015 
0016 #include "FieldDriverOptions.hh"
0017 #include "FieldPropagator.hh"
0018 #include "FieldSubstepper.hh"
0019 #include "MagFieldEquation.hh"
0020 
0021 namespace celeritas
0022 {
0023 //---------------------------------------------------------------------------//
0024 /*!
0025  * Create an integrator for moving a charge in a magnetic field.
0026  *
0027  * Example:
0028  * \code
0029  * auto step = make_stepper<DormandPrinceIntegrator>(
0030  *    UniformField{{1, 2, 3}},
0031  *    particle.charge());
0032  * \endcode
0033  */
0034 template<template<class EquationT> class IntegratorT, class FieldT>
0035 CELER_FUNCTION decltype(auto)
0036 make_mag_field_integrator(FieldT&& field, units::ElementaryCharge charge)
0037 {
0038     using Equation_t = MagFieldEquation<FieldT>;
0039     return IntegratorT<Equation_t>{
0040         Equation_t{::celeritas::forward<FieldT>(field), charge}};
0041 }
0042 
0043 //---------------------------------------------------------------------------//
0044 /*!
0045  * Create a field propagator from an existing integrator.
0046  *
0047  * Example:
0048  * \code
0049  * FieldDriverOptions driver_options,
0050  * auto propagate = make_field_propagator(
0051  *    integrate,
0052  *    driver_options,
0053  *    particle,
0054  *    &geo);
0055  * propagate(0.123);
0056  * \endcode
0057  */
0058 template<class IntegratorT, class GTV>
0059 CELER_FUNCTION decltype(auto)
0060 make_field_propagator(IntegratorT&& integrate,
0061                       FieldDriverOptions const& options,
0062                       ParticleTrackView const& particle,
0063                       GTV&& geometry)
0064 {
0065     return FieldPropagator{
0066         FieldSubstepper{options, ::celeritas::forward<IntegratorT>(integrate)},
0067         particle,
0068         ::celeritas::forward<GTV>(geometry)};
0069 }
0070 
0071 //---------------------------------------------------------------------------//
0072 /*!
0073  * Create a magnetic field propagator.
0074  *
0075  * Example:
0076  * \code
0077  * FieldDriverOptions driver_options,
0078  * auto propagate = make_mag_field_propagator<DormandPrinceIntegrator>(
0079  *    UniformField{{1, 2, 3}},
0080  *    driver_options,
0081  *    particle,
0082  *    &geo);
0083  * propagate(0.123);
0084  * \endcode
0085  */
0086 template<template<class EquationT> class IntegratorT, class FieldT, class GTV>
0087 CELER_FUNCTION decltype(auto)
0088 make_mag_field_propagator(FieldT&& field,
0089                           FieldDriverOptions const& options,
0090                           ParticleTrackView const& particle,
0091                           GTV&& geometry)
0092 {
0093     return make_field_propagator(
0094         make_mag_field_integrator<IntegratorT>(
0095             ::celeritas::forward<FieldT>(field), particle.charge()),
0096         options,
0097         particle,
0098         ::celeritas::forward<GTV>(geometry));
0099 }
0100 
0101 //---------------------------------------------------------------------------//
0102 }  // namespace celeritas