Skip to content

Commit 58e1c71

Browse files
committed
Update Elements for Alignment Support
1 parent ebf76cb commit 58e1c71

22 files changed

+208
-47
lines changed

src/particles/elements/Aperture.H

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313

1414
#include "particles/ImpactXParticleContainer.H"
15+
#include "mixin/alignment.H"
1516
#include "mixin/beamoptic.H"
1617
#include "mixin/thin.H"
1718
#include "mixin/nofinalize.H"
@@ -27,6 +28,7 @@ namespace impactx
2728
struct Aperture
2829
: public elements::BeamOptic<Aperture>,
2930
public elements::Thin,
31+
public elements::Alignment,
3032
public elements::NoFinalize
3133
{
3234
static constexpr auto name = "Aperture";
@@ -75,10 +77,13 @@ namespace impactx
7577
using namespace amrex::literals; // for _rt and _prt
7678

7779
// access AoS data such as positions and cpu/id
78-
amrex::ParticleReal const x = p.pos(RealAoS::x);
79-
amrex::ParticleReal const y = p.pos(RealAoS::y);
80+
amrex::ParticleReal x = p.pos(RealAoS::x);
81+
amrex::ParticleReal y = p.pos(RealAoS::y);
8082
auto const id = p.id();
8183

84+
// shift due to alignment errors of the element
85+
shift_in(x, y, px, py);
86+
8287
// scale horizontal and vertical coordinates
8388
amrex::ParticleReal const u = x / m_xmax;
8489
amrex::ParticleReal const v = y / m_ymax;
@@ -98,6 +103,9 @@ namespace impactx
98103
}
99104
break;
100105
}
106+
107+
// undo shift due to alignment errors of the element
108+
shift_out(x, y, px, py);
101109
}
102110

103111
/** This pushes the reference particle. */

src/particles/elements/Buncher.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_BUNCHER_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thin.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct Buncher
2728
: public elements::BeamOptic<Buncher>,
2829
public elements::Thin,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "Buncher";
@@ -64,10 +66,13 @@ namespace impactx
6466
using namespace amrex::literals; // for _rt and _prt
6567

6668
// access AoS data such as positions and cpu/id
67-
amrex::ParticleReal const x = p.pos(RealAoS::x);
68-
amrex::ParticleReal const y = p.pos(RealAoS::y);
69+
amrex::ParticleReal x = p.pos(RealAoS::x);
70+
amrex::ParticleReal y = p.pos(RealAoS::y);
6971
amrex::ParticleReal const t = p.pos(RealAoS::t);
7072

73+
// shift due to alignment errors of the element
74+
shift_in(x, y, px, py);
75+
7176
// access reference particle values to find (beta*gamma)^2
7277
amrex::ParticleReal const pt_ref = refpart.pt;
7378
amrex::ParticleReal const betgam2 = pow(pt_ref, 2) - 1.0_prt;
@@ -92,6 +97,8 @@ namespace impactx
9297
py = pyout;
9398
pt = ptout;
9499

100+
// undo shift due to alignment errors of the element
101+
shift_out(x, y, px, py);
95102
}
96103

97104
/** This pushes the reference particle. */

src/particles/elements/CFbend.H

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_CFBEND_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct CFbend
2728
: public elements::BeamOptic<CFbend>,
2829
public elements::Thick,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "CFbend";
@@ -73,10 +75,13 @@ namespace impactx
7375
using namespace amrex::literals; // for _rt and _prt
7476

7577
// access AoS data such as positions and cpu/id
76-
amrex::ParticleReal const x = p.pos(RealAoS::x);
77-
amrex::ParticleReal const y = p.pos(RealAoS::y);
78+
amrex::ParticleReal x = p.pos(RealAoS::x);
79+
amrex::ParticleReal y = p.pos(RealAoS::y);
7880
amrex::ParticleReal const t = p.pos(RealAoS::t);
7981

82+
// shift due to alignment errors of the element
83+
shift_in(x, y, px, py);
84+
8085
// initialize output values of momenta
8186
amrex::ParticleReal pxout = px;
8287
amrex::ParticleReal pyout = py;
@@ -151,6 +156,9 @@ namespace impactx
151156
px = pxout;
152157
py = pyout;
153158
pt = ptout;
159+
160+
// undo shift due to alignment errors of the element
161+
shift_out(x, y, px, py);
154162
}
155163

156164
/** This pushes the reference particle.

src/particles/elements/ChrDrift.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_CHRDRIFT_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct ChrDrift
2728
: public elements::BeamOptic<ChrDrift>,
2829
public elements::Thick,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "ChrDrift";
@@ -66,10 +68,13 @@ namespace impactx
6668
using namespace amrex::literals; // for _rt and _prt
6769

6870
// access AoS data such as positions and cpu/id
69-
amrex::ParticleReal const x = p.pos(RealAoS::x);
70-
amrex::ParticleReal const y = p.pos(RealAoS::y);
71+
amrex::ParticleReal x = p.pos(RealAoS::x);
72+
amrex::ParticleReal y = p.pos(RealAoS::y);
7173
amrex::ParticleReal const t = p.pos(RealAoS::t);
7274

75+
// shift due to alignment errors of the element
76+
shift_in(x, y, px, py);
77+
7378
// initialize output values of momenta
7479
amrex::ParticleReal const pxout = px;
7580
amrex::ParticleReal const pyout = py;
@@ -106,6 +111,8 @@ namespace impactx
106111
py = pyout;
107112
pt = ptout;
108113

114+
// undo shift due to alignment errors of the element
115+
shift_out(x, y, px, py);
109116
}
110117

111118
/** This pushes the reference particle.

src/particles/elements/ChrQuad.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_CHRQUAD_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -27,6 +28,7 @@ namespace impactx
2728
struct ChrQuad
2829
: public elements::BeamOptic<ChrQuad>,
2930
public elements::Thick,
31+
public elements::Alignment,
3032
public elements::NoFinalize
3133
{
3234
static constexpr auto name = "ChrQuad";
@@ -76,10 +78,13 @@ namespace impactx
7678
using namespace amrex::literals; // for _rt and _prt
7779

7880
// access AoS data such as positions and cpu/id
79-
amrex::ParticleReal const x = p.pos(RealAoS::x);
80-
amrex::ParticleReal const y = p.pos(RealAoS::y);
81+
amrex::ParticleReal x = p.pos(RealAoS::x);
82+
amrex::ParticleReal y = p.pos(RealAoS::y);
8183
amrex::ParticleReal const t = p.pos(RealAoS::t);
8284

85+
// shift due to alignment errors of the element
86+
shift_in(x, y, px, py);
87+
8388
// length of the current slice
8489
amrex::ParticleReal const slice_ds = m_ds / nslice();
8590

@@ -162,6 +167,8 @@ namespace impactx
162167
py = pyout;
163168
pt = ptout;
164169

170+
// undo shift due to alignment errors of the element
171+
shift_out(x, y, px, py);
165172
}
166173

167174
/** This pushes the reference particle.

src/particles/elements/ChrUniformAcc.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_CHRACC_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct ChrAcc
2728
: public elements::BeamOptic<ChrAcc>,
2829
public elements::Thick,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "ChrAcc";
@@ -71,10 +73,13 @@ namespace impactx
7173
using namespace amrex::literals; // for _rt and _prt
7274

7375
// access AoS data such as positions and cpu/id
74-
amrex::ParticleReal const x = p.pos(RealAoS::x);
75-
amrex::ParticleReal const y = p.pos(RealAoS::y);
76+
amrex::ParticleReal x = p.pos(RealAoS::x);
77+
amrex::ParticleReal y = p.pos(RealAoS::y);
7678
amrex::ParticleReal const t = p.pos(RealAoS::t);
7779

80+
// shift due to alignment errors of the element
81+
shift_in(x, y, px, py);
82+
7883
// length of the current slice
7984
amrex::ParticleReal const slice_ds = m_ds / nslice();
8085

@@ -149,6 +154,8 @@ namespace impactx
149154
py = py/bgf;
150155
pt = pt/bgf;
151156

157+
// undo shift due to alignment errors of the element
158+
shift_out(x, y, px, py);
152159
}
153160

154161
/** This pushes the reference particle.

src/particles/elements/ConstF.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_CONSTF_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct ConstF
2728
: public elements::BeamOptic<ConstF>,
2829
public elements::Thick,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "ConstF";
@@ -68,10 +70,13 @@ namespace impactx
6870
using namespace amrex::literals; // for _rt and _prt
6971

7072
// access AoS data such as positions and cpu/id
71-
amrex::ParticleReal const x = p.pos(RealAoS::x);
72-
amrex::ParticleReal const y = p.pos(RealAoS::y);
73+
amrex::ParticleReal x = p.pos(RealAoS::x);
74+
amrex::ParticleReal y = p.pos(RealAoS::y);
7375
amrex::ParticleReal const t = p.pos(RealAoS::t);
7476

77+
// shift due to alignment errors of the element
78+
shift_in(x, y, px, py);
79+
7580
// access reference particle values to find beta*gamma^2
7681
amrex::ParticleReal const pt_ref = refpart.pt;
7782
amrex::ParticleReal const betgam2 = pow(pt_ref, 2) - 1.0_prt;
@@ -99,6 +104,8 @@ namespace impactx
99104
py = pyout;
100105
pt = ptout;
101106

107+
// undo shift due to alignment errors of the element
108+
shift_out(x, y, px, py);
102109
}
103110

104111
/** This pushes the reference particle.

src/particles/elements/DipEdge.H

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_DIPEDGE_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thin.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct DipEdge
2728
: public elements::BeamOptic<DipEdge>,
2829
public elements::Thin,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "DipEdge";
@@ -74,8 +76,11 @@ namespace impactx
7476
using namespace amrex::literals; // for _rt and _prt
7577

7678
// access AoS data such as positions and cpu/id
77-
amrex::ParticleReal const x = p.pos(RealAoS::x);
78-
amrex::ParticleReal const y = p.pos(RealAoS::y);
79+
amrex::ParticleReal x = p.pos(RealAoS::x);
80+
amrex::ParticleReal y = p.pos(RealAoS::y);
81+
82+
// shift due to alignment errors of the element
83+
shift_in(x, y, px, py);
7984

8085
// access reference particle values if needed
8186

@@ -92,6 +97,9 @@ namespace impactx
9297
// apply edge focusing
9398
px = px + R21*x;
9499
py = py + R43*y;
100+
101+
// undo shift due to alignment errors of the element
102+
shift_out(x, y, px, py);
95103
}
96104

97105
/** This pushes the reference particle. */

src/particles/elements/Drift.H

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define IMPACTX_DRIFT_H
1212

1313
#include "particles/ImpactXParticleContainer.H"
14+
#include "mixin/alignment.H"
1415
#include "mixin/beamoptic.H"
1516
#include "mixin/thick.H"
1617
#include "mixin/nofinalize.H"
@@ -26,6 +27,7 @@ namespace impactx
2627
struct Drift
2728
: public elements::BeamOptic<Drift>,
2829
public elements::Thick,
30+
public elements::Alignment,
2931
public elements::NoFinalize
3032
{
3133
static constexpr auto name = "Drift";
@@ -63,10 +65,13 @@ namespace impactx
6365
using namespace amrex::literals; // for _rt and _prt
6466

6567
// access AoS data such as positions and cpu/id
66-
amrex::ParticleReal const x = p.pos(RealAoS::x);
67-
amrex::ParticleReal const y = p.pos(RealAoS::y);
68+
amrex::ParticleReal x = p.pos(RealAoS::x);
69+
amrex::ParticleReal y = p.pos(RealAoS::y);
6870
amrex::ParticleReal const t = p.pos(RealAoS::t);
6971

72+
// shift due to alignment errors of the element
73+
shift_in(x, y, px, py);
74+
7075
// initialize output values of momenta
7176
amrex::ParticleReal const pxout = px;
7277
amrex::ParticleReal const pyout = py;
@@ -92,6 +97,8 @@ namespace impactx
9297
py = pyout;
9398
pt = ptout;
9499

100+
// undo shift due to alignment errors of the element
101+
shift_out(x, y, px, py);
95102
}
96103

97104
/** This pushes the reference particle.

0 commit comments

Comments
 (0)