ImpactX
Toggle main menu visibility
Loading...
Searching...
No Matches
src
particles
transformation
ToFixedT.H
Go to the documentation of this file.
1
/* Copyright 2022-2026 The Regents of the University of California, through Lawrence
2
* Berkeley National Laboratory (subject to receipt of any required
3
* approvals from the U.S. Dept. of Energy). All rights reserved.
4
*
5
* This file is part of ImpactX.
6
*
7
* Authors: Chad Mitchell, Axel Huebl
8
* License: BSD-3-Clause-LBNL
9
*/
10
#ifndef IMPACTX_TO_FIXED_T_H
11
#define IMPACTX_TO_FIXED_T_H
12
13
#include "
particles/ImpactXParticleContainer.H
"
14
15
#include <
AMReX_GpuQualifiers.H
>
16
#include <
AMReX_Math.H
>
17
#include <
AMReX_REAL.H
>
18
19
#include <cmath>
20
21
22
namespace
impactx::transformation
23
{
24
struct
ToFixedT
25
{
26
using
PType
=
ImpactXParticleContainer::ParticleType
;
27
35
ToFixedT
(
amrex::ParticleReal
const
ptd)
36
:
m_ptd
(ptd)
37
{
38
}
39
50
AMREX_GPU_HOST_DEVICE
AMREX_FORCE_INLINE
51
void
operator()
(
52
amrex::ParticleReal
& x,
53
amrex::ParticleReal
& y,
54
amrex::ParticleReal
&
t
,
55
amrex::ParticleReal
& px,
56
amrex::ParticleReal
& py,
57
amrex::ParticleReal
& pt)
const
58
{
59
using namespace
amrex::literals
;
60
using
amrex::Math::powi
;
61
62
// small tolerance to avoid NaN for pz<0:
63
constexpr
amrex::ParticleReal
tol =
64
#ifdef AMREX_SINGLE_PRECISION_PARTICLES
65
1.0e-6_prt;
66
#else
67
1.0e-12_prt;
68
#endif
69
70
// compute value of reference pzd = beta*gamma
71
amrex::ParticleReal
const
argd = -1.0_prt + powi<2>(
m_ptd
);
72
// AMREX_ASSERT_WITH_MESSAGE(argd > 0.0_prt, "invalid pzd arg (<=0)");
73
amrex::ParticleReal
const
pzdf = argd > 0.0_prt ? std::sqrt(argd) : tol;
74
75
// transform momenta to dynamic units (eg, so that momenta are
76
// normalized by mc):
77
px = px * pzdf;
78
py = py * pzdf;
79
pt = pt * pzdf;
80
81
// compute value of particle pz = beta*gamma
82
amrex::ParticleReal
const
arg
= -1.0_prt + powi<2>(
m_ptd
+pt) - powi<2>(px) - powi<2>(py);
83
// AMREX_ASSERT_WITH_MESSAGE(arg > 0.0_prt, "invalid pz arg (<=0)");
84
amrex::ParticleReal
const
pzf =
arg
> 0.0_prt ? std::sqrt(
arg
) : tol;
85
86
// transform position and momentum (from fixed s to fixed t)
87
x = x + px*
t
/(
m_ptd
+pt);
88
// px = px;
89
y = y + py*
t
/(
m_ptd
+pt);
90
// py = py;
91
auto
& z =
t
;
// We store z in the same memory slot as t.
92
z = pzf *
t
/ (
m_ptd
+ pt);
93
auto
& pz = pt;
// We store pz in the same memory slot as pt.
94
pz = pzf - pzdf;
95
96
// transform momenta to static units (eg, so that momenta are
97
// normalized by pzdf):
98
px = px / pzdf;
99
py = py / pzdf;
100
pz = pz / pzdf;
101
}
102
103
private
:
104
amrex::ParticleReal
m_ptd
;
105
};
106
107
}
// namespace impactx::transformation
108
109
#endif
// IMPACTX_TO_FIXED_T_H
AMREX_FORCE_INLINE
#define AMREX_FORCE_INLINE
AMReX_GpuQualifiers.H
AMREX_GPU_HOST_DEVICE
#define AMREX_GPU_HOST_DEVICE
AMReX_Math.H
AMReX_REAL.H
ImpactXParticleContainer.H
amrex::ParticleContainer_impl< SoAParticle< T_NArrayReal, T_NArrayInt >, T_NArrayReal, T_NArrayInt, Allocator, CellAssignor >::ParticleType
T_ParticleType ParticleType
amrex::ParticleReal
amrex_particle_real ParticleReal
amrex::Math::powi
constexpr T powi(T x) noexcept
amrex::literals
amrex::arg
__host__ __device__ T arg(const GpuComplex< T > &a_z) noexcept
impactx::transformation
Definition
CoordinateTransformation.cpp:24
impactx::CoordSystem::t
@ t
fixed t as the independent variable
Definition
ImpactXParticleContainer.H:38
impactx::transformation::ToFixedT::ToFixedT
ToFixedT(amrex::ParticleReal const ptd)
Definition
ToFixedT.H:35
impactx::transformation::ToFixedT::m_ptd
amrex::ParticleReal m_ptd
Design value of pt/mc2 = -gamma.
Definition
ToFixedT.H:104
impactx::transformation::ToFixedT::operator()
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(amrex::ParticleReal &x, amrex::ParticleReal &y, amrex::ParticleReal &t, amrex::ParticleReal &px, amrex::ParticleReal &py, amrex::ParticleReal &pt) const
Definition
ToFixedT.H:51
impactx::transformation::ToFixedT::PType
ImpactXParticleContainer::ParticleType PType
Definition
ToFixedT.H:26
Generated by
1.17.0