ImpactX
Loading...
Searching...
No Matches
ExactCFbend.H
Go to the documentation of this file.
1/* Copyright 2022-2023 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_EXACTCFBEND_H
11#define IMPACTX_EXACTCFBEND_H
12
15#include "mixin/alignment.H"
16#include "mixin/pipeaperture.H"
17#include "mixin/beamoptic.H"
18#include "mixin/thick.H"
19#include "mixin/named.H"
20#include "mixin/nofinalize.H"
22
23#include <AMReX_Extension.H>
24#include <AMReX_REAL.H>
25#include <AMReX_Print.H>
26#include <AMReX_GpuComplex.H>
27#include <AMReX_Math.H>
28
29#include <cmath>
30#include <stdexcept>
31#include <vector>
32
33namespace impactx::elements
34{
35
43 {
45 inline int next_id = 0;
46
48 inline std::map<int, std::vector<amrex::ParticleReal>> h_k_normal = {};
50 inline std::map<int, std::vector<amrex::ParticleReal>> h_k_skew = {};
51
53 inline std::map<int, amrex::Gpu::DeviceVector<amrex::ParticleReal>> d_k_normal = {};
55 inline std::map<int, amrex::Gpu::DeviceVector<amrex::ParticleReal>> d_k_skew = {};
56
57 } // namespace ExactCFbendData
58
59
61 : public mixin::Named,
62 public mixin::BeamOptic<ExactCFbend>,
63 public mixin::LinearTransport<ExactCFbend>,
64 public mixin::Thick,
65 public mixin::Alignment,
68 {
69 static constexpr auto type = "ExactCFbend";
71
98 amrex::ParticleReal ds,
99 std::vector<amrex::ParticleReal> k_normal,
100 std::vector<amrex::ParticleReal> k_skew,
101 int unit,
102 amrex::ParticleReal dx = 0,
103 amrex::ParticleReal dy = 0,
104 amrex::ParticleReal rotation_degree = 0,
105 amrex::ParticleReal aperture_x = 0,
106 amrex::ParticleReal aperture_y = 0,
107 int int_order = 2,
108 int mapsteps = 1,
109 int nslice = 1,
110 std::optional<std::string> name = std::nullopt
111 )
112 : Named(std::move(name)),
113 Thick(ds, nslice),
114 Alignment(dx, dy, rotation_degree),
116 m_unit(unit),m_int_order(int_order),m_mapsteps(mapsteps),m_id(ExactCFbendData::next_id)
117 {
118 // next created ExactCFbend has another id for its data
120
121 // validate symplectic integration order is implemented
122 if (m_int_order != 2 && m_int_order != 4 && m_int_order != 6)
123 throw std::runtime_error("ExactCFbend: The order used for symplectic integration must be 2, 4 or 6.");
124
125 // validate normal and skew coefficients are the same length
126 m_ncoef = int(k_normal.size());
127 if (m_ncoef != int(k_skew.size()))
128 throw std::runtime_error("ExactMultipole: normal and skew coefficient arrays must have same length!");
129
130 // host data
135
136 // device data
140 k_normal.begin(), k_normal.end(),
143 k_skew.begin(), k_skew.end(),
146
147 // low-level objects we can use on device
150
151 }
152
154 using BeamOptic::operator();
155
163 void compute_constants (RefPart const & refpart)
164 {
165 using namespace amrex::literals; // for _rt and _prt
166
167 Alignment::compute_constants(refpart);
168
169 // access reference particle values to find relativistic factors
170 m_beta = refpart.beta();
171 m_ibeta = 1_prt / m_beta;
172 m_ibetgam2 = 1_prt / amrex::Math::powi<2>(refpart.beta_gamma());
173 m_brho = refpart.rigidity_Tm();
174
175 amrex::ParticleReal* k_normal = m_k_normal_h_data;
176
177 // find magnetic field and curvature; normalize units to MAD-X convention if needed
178 amrex::ParticleReal curvature = m_unit == 1 ? k_normal[0] / m_brho : k_normal[0];
179 m_rc = curvature == 0.0 ? 0.0_prt : 1.0_prt/curvature;
180
181 // arc length and angle of the current slice
182 m_slice_ds = m_ds / nslice();
183
184 }
185
201 amrex::ParticleReal & AMREX_RESTRICT x,
202 amrex::ParticleReal & AMREX_RESTRICT y,
203 amrex::ParticleReal & AMREX_RESTRICT t,
204 amrex::ParticleReal & AMREX_RESTRICT px,
205 amrex::ParticleReal & AMREX_RESTRICT py,
206 amrex::ParticleReal & AMREX_RESTRICT pt,
207 uint64_t & AMREX_RESTRICT idcpu,
208 [[maybe_unused]] RefPart const & AMREX_RESTRICT refpart
209 ) const
210 {
211 using namespace amrex::literals; // for _rt and _prt
212
213 // shift due to alignment errors of the element
214 shift_in(x, y, px, py);
215
216 // numerical integration parameters
217 amrex::ParticleReal const zin = 0_prt;
218 amrex::ParticleReal const zout = m_slice_ds;
219 int const nsteps = m_mapsteps;
220
221 // initialize phase space 6-vector
223 x, px, y, py, t, pt
224 };
225
226 // call integrator to advance through slice (int_order = 2 or 4, otherwise default 2)
227 if (m_int_order == 2) {
228 integrators::symp2_integrate_particle(particle,zin,zout,nsteps,*this);
229 } else if (m_int_order == 4) {
230 integrators::symp4_integrate_particle(particle,zin,zout,nsteps,*this);
231 } else if (m_int_order == 6) {
232 integrators::symp6_integrate_particle(particle,zin,zout,nsteps,*this);
233 }
234
235 // assign updated values
236 x = particle(1);
237 px = particle(2);
238 y = particle(3);
239 py = particle(4);
240 t = particle(5);
241 pt = particle(6);
242
243 // apply transverse aperture
244 apply_aperture(x, y, idcpu);
245
246 // undo shift due to alignment errors of the element
247 shift_out(x, y, px, py);
248 }
249
259 void map1 (amrex::ParticleReal const tau,
261 amrex::ParticleReal & zeval) const
262 {
263 using namespace amrex::literals; // for _rt and _prt
264 using namespace amrex::Math; // for powi
265
266 amrex::ParticleReal const x = particle(1);
267 amrex::ParticleReal const px = particle(2);
268 amrex::ParticleReal const y = particle(3);
269 amrex::ParticleReal const py = particle(4);
270 amrex::ParticleReal const t = particle(5);
271 amrex::ParticleReal const pt = particle(6);
272
273 amrex::ParticleReal xout = x;
274 amrex::ParticleReal pxout = px;
275 amrex::ParticleReal yout = y;
276 amrex::ParticleReal pyout = py;
277 amrex::ParticleReal tout = t;
278 amrex::ParticleReal ptout = pt;
279
280 // treat the special case of zero field
281 if (m_rc==0_prt) {
282 // compute the radical in the denominator (= pz):
283 amrex::ParticleReal const inv_pzden = 1_prt / std::sqrt(
284 powi<2>(pt - m_ibeta) -
285 m_ibetgam2 -
286 powi<2>(px) -
287 powi<2>(py)
288 );
289
290 // advance position and momentum (exact drift)
291 xout = x + tau * px * inv_pzden;
292 yout = y + tau * py * inv_pzden;
293 tout = t - tau * (m_ibeta + (pt - m_ibeta) * inv_pzden);
294
295 // assign updated momenta
296 pxout = px;
297 pyout = py;
298 ptout = pt;
299
300 } else {
301
302 // assign intermediate quantities
303 amrex::ParticleReal const pperp2 = powi<2>(pt)-2.0_prt * m_ibeta * pt - powi<2>(py)+1.0_prt;
304 amrex::ParticleReal const px2 = powi<2>(px);
305
306 // trigonometric evaluations
307 amrex::ParticleReal const slice_phi = tau / m_rc;
308 auto const [sin_phi, cos_phi] = amrex::Math::sincos(slice_phi);
309
310 // determine if particle lies within the domain of map definition
311 if (pperp2 > px2)
312 {
313 amrex::ParticleReal const pperp = std::sqrt(pperp2);
314 amrex::ParticleReal const pzi = std::sqrt(powi<2>(pperp) - powi<2>(px));
315 amrex::ParticleReal const rho = m_rc + x;
316
317 // update momenta
318 pxout = px * cos_phi + (pzi - rho / m_rc) * sin_phi;
319 pyout = py;
320 ptout = pt;
321
322 // angle of momentum rotation
323 amrex::ParticleReal const px2f = powi<2>(pxout);
324 // determine if particle lies within domain of map definition
325 if (pperp2 > px2f)
326 {
327 amrex::ParticleReal const pzf = std::sqrt(powi<2>(pperp)-powi<2>(pxout));
328 amrex::ParticleReal const theta = slice_phi + std::asin(px/pperp) - std::asin(pxout/pperp);
329
330 // update position coordinates
331 xout = -m_rc + rho*cos_phi + m_rc*(pzf + px*sin_phi - pzi*cos_phi);
332 yout = y + theta * m_rc * py;
333 tout = t - theta * m_rc * (pt - 1.0_prt * m_ibeta) - slice_phi * m_rc * m_ibeta;
334
335 } // else { amrex::Print() << "Warning: outside map domain." << "\n"; }
336 } // else { amrex::Print() << "Warning: outside map domain." << "\n"; }
337 }
338
339 // push particle coordinates
340 particle(1) = xout;
341 particle(2) = pxout;
342 particle(3) = yout;
343 particle(4) = pyout;
344 particle(5) = tout;
345 particle(6) = ptout;
346
347 zeval += 0_prt;
348 }
349
360 void map2 (amrex::ParticleReal const tau,
362 amrex::ParticleReal & zeval) const
363 {
364 using namespace amrex::literals; // for _rt and _prt
365 using namespace amrex::Math; // for powi
366
367 amrex::ParticleReal const x = particle(1);
368 amrex::ParticleReal const px = particle(2);
369 amrex::ParticleReal const y = particle(3);
370 amrex::ParticleReal const py = particle(4);
371 amrex::ParticleReal const t = particle(5);
372 amrex::ParticleReal const pt = particle(6);
373
374 amrex::ParticleReal xout = x;
375 amrex::ParticleReal pxout = px;
376 amrex::ParticleReal yout = y;
377 amrex::ParticleReal pyout = py;
378 amrex::ParticleReal tout = t;
379 amrex::ParticleReal ptout = pt;
380
381 amrex::ParticleReal* k_normal = m_k_normal_d_data;
382 amrex::ParticleReal* k_skew = m_k_skew_d_data;
383
384 // defined dimensionless variables scaled by radius of curvature
385 amrex::ParticleReal rho = 1_prt + x / m_rc;
386 amrex::ParticleReal y_scl = y / m_rc;
387 amrex::ParticleReal ln_rho = std::log(rho);
388
389 // initialize the momentum kick
390 amrex::ParticleReal dpx = 0_prt;
391 amrex::ParticleReal dpy = 0_prt;
392
393 // loop over array of multipole coefficients
394 for (int m = 1; m < m_ncoef; m++) {
395
396 // normalize units to MAD-X convention if needed
397 amrex::ParticleReal kn = m_unit == 1 ? k_normal[m] / m_brho : k_normal[m];
398 amrex::ParticleReal ks = m_unit == 1 ? k_skew[m] / m_brho : k_skew[m];
399
400 int n = m+1; // multipole order
401
402 //amrex::Print() << "n, kn, ks before scaling: " << n << ", " << kn << ", " << ks << "\n";
403
404 // define dimensionless multipole coefficients (scaled by radius of curvature)
405 kn = std::pow(m_rc, m) * kn;
406 ks = std::pow(m_rc, m) * ks;
407
408 switch (n) {
409
410 case 1: // dipole-like contribution (not used - contributing to map 1)
411 dpx += -rho * kn;
412 dpy += ks;
413 break;
414 case 2: // quadrupole-like contribution
415 dpx += -rho*ln_rho*kn + y_scl*rho*ks;
416 dpy += y_scl*kn + 0.5_prt*(rho*rho - 1_prt)*ks;
417 break;
418 case 3: // sextupole-like contribution
419 dpx += 0.25_prt*rho*(1_prt + 2_prt*y_scl*y_scl - rho*rho + 2_prt*ln_rho)*kn + y_scl*rho*ln_rho*ks;
420 dpy += 0.5_prt*y_scl*(rho*rho - 1_prt)*kn + 0.25_prt*(1_prt - 2_prt*y_scl*y_scl - rho*rho + 2_prt*rho*rho*ln_rho)*ks;
421 break;
422 case 4: // octupole-like contribution
423 dpx += -0.25_prt*(rho - powi<3>(rho) + (rho - 2_prt*y_scl*y_scl*rho + powi<3>(rho))*ln_rho)*kn
424 -1_prt/12_prt*y_scl*rho*(3_prt + 2_prt*y_scl*y_scl - 3_prt*rho*rho + 6_prt*ln_rho)*ks;
425 dpy += -1_prt/12_prt*y_scl*(-3_prt + 2_prt*y_scl*y_scl + 3_prt*rho*rho - 6_prt*rho*rho*ln_rho)*kn
426 -1_prt/16_prt*((-1_prt + 4_prt*y_scl*y_scl - rho*rho)*(-1_prt + rho*rho) + 4_prt*rho*rho*ln_rho)*ks;
427 //amrex::Print() << "x, y, dpx, dpy = " << x << ", " << y << ", " << dpx << ", " << dpy << "\n";
428 break;
429 case 5: // decapole-like contribution
430 dpx += -1_prt/192_prt*rho*(8_prt*powi<4>(y_scl) - 24_prt*powi<2>(y_scl)*(-1_prt + rho*rho)
431 + 3_prt*(-5_prt + 4_prt*powi<2>(rho) + powi<4>(rho))
432 +12_prt*(-1_prt + 4_prt*y_scl*y_scl - 2_prt*rho*rho)*ln_rho)*kn
433 +1_prt/12_prt*y_scl*rho*(3_prt*(-1_prt + rho*rho) + (2_prt*y_scl*y_scl - 3_prt*(1_prt + rho*rho))*ln_rho)*ks;
434 dpy += -1_prt/48_prt*y_scl*((-1_prt + rho*rho)*(4_prt*y_scl*y_scl - 3_prt*(1_prt + rho*rho)) + 12_prt*rho*rho*ln_rho)*kn
435 + 1_prt/192_prt*(3_prt + 8_prt*powi<4>(y_scl) + 12_prt*rho*rho
436 - 15_prt*powi<4>(rho) + 24_prt*y_scl*y_scl*(-1_prt + rho*rho)
437 +12_prt*rho*rho*(2_prt - 4_prt*y_scl*y_scl + rho*rho)*ln_rho)*ks;
438 break;
439 // default:
440 // TODO: print a warning here that order > 5 is not currently supported
441 }
442
443 }
444
445 // advance momentum by a step of length tau
446 pxout = pxout + tau * dpx;
447 pyout = pyout + tau * dpy;
448
449 //update the particle coordinates
450 particle(1) = xout;
451 particle(2) = pxout;
452 particle(3) = yout;
453 particle(4) = pyout;
454 particle(5) = tout;
455 particle(6) = ptout;
456
457 zeval += tau;
458 }
459
460
466 void operator() (RefPart & AMREX_RESTRICT refpart) const
467 {
468 using namespace amrex::literals; // for _rt and _prt
469
470 // assign input reference particle values
471 amrex::ParticleReal const x = refpart.x;
472 amrex::ParticleReal const px = refpart.px;
473 amrex::ParticleReal const y = refpart.y;
474 amrex::ParticleReal const py = refpart.py;
475 amrex::ParticleReal const z = refpart.z;
476 amrex::ParticleReal const pz = refpart.pz;
477 amrex::ParticleReal const t = refpart.t;
478 amrex::ParticleReal const pt = refpart.pt;
479 amrex::ParticleReal const s = refpart.s;
480 amrex::ParticleReal const brho = refpart.rigidity_Tm();
481
482#if AMREX_DEVICE_COMPILE
483 amrex::ParticleReal* k_normal = m_k_normal_d_data;
484#else
485 amrex::ParticleReal* k_normal = m_k_normal_h_data;
486#endif
487 // find magnetic field and curvature; normalize units to MAD-X convention if needed
488 amrex::ParticleReal const curvature = m_unit == 1 ? k_normal[0] / brho : k_normal[0];
489 amrex::ParticleReal const rc = curvature == 0.0 ? 0.0_prt : 1.0_prt/curvature;
490
491 // length of the current slice
492 amrex::ParticleReal const slice_ds = m_ds / nslice();
493
494 // special case of zero field = an exact drift
495 if (rc==0_prt) {
496 // advance position and momentum (drift)
497 amrex::ParticleReal const step = slice_ds / std::sqrt(amrex::Math::powi<2>(pt) - 1.0_prt);
498 refpart.x = x + step*px;
499 refpart.y = y + step*py;
500 refpart.z = z + step*pz;
501 refpart.t = t - step*pt;
502
503 } else {
504
505 // assign intermediate parameters
506 amrex::ParticleReal const B = refpart.beta_gamma() /rc;
507 amrex::ParticleReal const theta = slice_ds / rc;
508
509 // calculate expensive terms once
510 auto const [sin_theta, cos_theta] = amrex::Math::sincos(theta);
511
512 // advance position and momentum (bend)
513 refpart.px = px*cos_theta - pz*sin_theta;
514 refpart.py = py;
515 refpart.pz = pz*cos_theta + px*sin_theta;
516 refpart.pt = pt;
517
518 refpart.x = x + (refpart.pz - pz)/B;
519 refpart.y = y + (theta/B)*py;
520 refpart.z = z - (refpart.px - px)/B;
521 refpart.t = t - (theta/B)*pt;
522
523 }
524
525 // advance integrated path length
526 refpart.s = s + slice_ds;
527 }
528
529
530
536 Map6x6
537 transport_map (RefPart const & AMREX_RESTRICT refpart) const // TODO: update as well, but needs more careful placement of calc_constants
538 {
539 using namespace amrex::literals; // for _rt and _prt
540
541 // length of the current slice
542 amrex::ParticleReal const slice_ds = m_ds / nslice();
543
544 // find beta*gamma^2, beta
545 amrex::ParticleReal const betgam2 = amrex::Math::powi<2>(refpart.pt) - 1_prt;
546 amrex::ParticleReal const bet = refpart.beta();
547 amrex::ParticleReal const ibetgam2 = 1_prt / betgam2;
548
549 amrex::ParticleReal* k_normal = m_k_normal_h_data;
550
551 // find magnetic field and curvature; normalize units to MAD-X convention if needed
552 amrex::ParticleReal const curvature = m_unit == 1 ? k_normal[0] / m_brho : k_normal[0];
553 amrex::ParticleReal const rc = curvature == 0.0 ? 0.0_prt : 1.0_prt/curvature;
554 amrex::ParticleReal const kn = m_unit == 1 ? k_normal[1] / m_brho : k_normal[1];
555 amrex::ParticleReal const b2rc2 = amrex::Math::powi<2>(bet) * amrex::Math::powi<2>(rc);
556
557 // update horizontal and longitudinal phase space variables
558 amrex::ParticleReal const gx = kn + amrex::Math::powi<-2>(rc);
559 amrex::ParticleReal const omega_x = std::sqrt(std::abs(gx));
560
561 // update vertical phase space variables
562 amrex::ParticleReal const gy = -kn;
563 amrex::ParticleReal const omega_y = std::sqrt(std::abs(gy));
564
565 // trigonometry
566 auto const [sinx, cosx] = amrex::Math::sincos(omega_x * slice_ds);
567 amrex::ParticleReal const sinhx = std::sinh(omega_x * slice_ds);
568 amrex::ParticleReal const coshx = std::cosh(omega_x * slice_ds);
569 auto const [siny, cosy] = amrex::Math::sincos(omega_y * slice_ds);
570 amrex::ParticleReal const sinhy = std::sinh(omega_y * slice_ds);
571 amrex::ParticleReal const coshy = std::cosh(omega_y * slice_ds);
572
573 amrex::ParticleReal const igbrc = 1_prt / (gx * bet * rc);
574 amrex::ParticleReal const iobrc = 1_prt / (omega_x * bet * rc);
575 amrex::ParticleReal const igobr = 1_prt / (gx * omega_x * b2rc2);
576
577 // initialize linear map matrix elements
579
580 R(1,1) = gx > 0_prt ? cosx : coshx;
581 R(1,2) = gx > 0_prt ? sinx / omega_x : sinhx / omega_x;
582 R(1,6) = gx > 0_prt ? -(1_prt - cosx) * igbrc : -(1_prt - coshx) * igbrc;
583 R(2,1) = gx > 0_prt ? -omega_x * sinx : omega_x * sinhx;
584 R(2,2) = gx > 0_prt ? cosx : coshx;
585 R(2,6) = gx > 0_prt ? -sinx * iobrc : -sinhx * iobrc;
586 R(3,3) = gy > 0_prt ? cosy : coshy;
587 R(3,4) = gy > 0_prt ? siny / omega_y : sinhy / omega_y;
588 R(4,3) = gy > 0_prt ? -omega_y * siny : omega_y * sinhy;
589 R(4,4) = gy > 0_prt ? cosy : coshy;
590 R(5,1) = gx > 0_prt ? sinx * iobrc : sinhx * iobrc;
591 R(5,2) = gx > 0_prt ? (1_prt - cosx) * igbrc : (1_prt - coshx) * igbrc;
592 R(5,6) = gx > 0_prt ?
593 slice_ds * ibetgam2 + (sinx - omega_x * slice_ds) * igobr :
594 slice_ds * ibetgam2 + (sinhx - omega_x * slice_ds) * igobr;
595
596 return R;
597 }
598
600 using LinearTransport::operator();
601
602
605 void
607 {
608 // remove from unique data map
609 if (ExactCFbendData::h_k_normal.count(m_id) != 0u)
611 if (ExactCFbendData::h_k_skew.count(m_id) != 0u)
613
614 if (ExactCFbendData::d_k_normal.count(m_id) != 0u)
616 if (ExactCFbendData::d_k_skew.count(m_id) != 0u)
618 }
619
620 int m_unit;
623 int m_id;
624
625 int m_ncoef = 0;
626 amrex::ParticleReal* m_k_normal_h_data = nullptr;
627 amrex::ParticleReal* m_k_skew_h_data = nullptr;
628 amrex::ParticleReal* m_k_normal_d_data = nullptr;
629 amrex::ParticleReal* m_k_skew_d_data = nullptr;
630
631 private:
632 // constants that are independent of the individually tracked particle,
633 // see: compute_constants() to refresh
634 amrex::ParticleReal m_slice_ds;
635 amrex::ParticleReal m_ibetgam2;
636 amrex::ParticleReal m_beta;
637 amrex::ParticleReal m_ibeta;
638 amrex::ParticleReal m_brho;
639 amrex::ParticleReal m_rc;
640 };
641
642} // namespace impactx
643
644#endif // IMPACTX_EXACTCFBEND_H
#define AMREX_FORCE_INLINE
#define AMREX_RESTRICT
#define AMREX_GPU_HOST_DEVICE
#define AMREX_GPU_HOST
void copyAsync(HostToDevice, InIter begin, InIter end, OutIter result) noexcept
static constexpr HostToDevice hostToDevice
void streamSynchronize() noexcept
PODVector< T, ArenaAllocator< T > > DeviceVector
__host__ __device__ std::pair< double, double > sincos(double x)
constexpr T powi(T x) noexcept
SmallMatrix< T, N, 1, Order::F, StartIndex > SmallVector
Definition ExactCFbend.H:43
std::map< int, amrex::Gpu::DeviceVector< amrex::ParticleReal > > d_k_normal
device: normal multipole coefficients of the magnetic field
Definition ExactCFbend.H:53
int next_id
last used id for a created ExactCFbend
Definition ExactCFbend.H:45
std::map< int, amrex::Gpu::DeviceVector< amrex::ParticleReal > > d_k_skew
device: skew multipole coefficients of the magnetic field
Definition ExactCFbend.H:55
std::map< int, std::vector< amrex::ParticleReal > > h_k_normal
host: normal multipole coefficients of the magnetic field
Definition ExactCFbend.H:48
std::map< int, std::vector< amrex::ParticleReal > > h_k_skew
host: skew multipole coefficients of the magnetic field
Definition ExactCFbend.H:50
Definition All.H:54
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp4_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition Integrators.H:225
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp6_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition Integrators.H:284
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void symp2_integrate_particle(amrex::SmallVector< T_Real, 6, 1 > &particle, amrex::ParticleReal const zin, amrex::ParticleReal const zout, int const nsteps, T_Element const &element)
Definition Integrators.H:178
@ s
fixed s as the independent variable
Definition ImpactXParticleContainer.H:37
@ t
fixed t as the independent variable
Definition ImpactXParticleContainer.H:38
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > Map6x6
Definition CovarianceMatrix.H:20
static constexpr __host__ __device__ SmallMatrix< T, NRows, NCols, ORDER, StartIndex > Identity() noexcept
Definition ReferenceParticle.H:31
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta_gamma() const
Definition ReferenceParticle.H:110
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal rigidity_Tm() const
Definition ReferenceParticle.H:203
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal beta() const
Definition ReferenceParticle.H:94
ImpactXParticleContainer::ParticleType PType
Definition ExactCFbend.H:70
int m_int_order
unit specification for Multipole strength
Definition ExactCFbend.H:621
amrex::ParticleReal m_ibeta
beta
Definition ExactCFbend.H:637
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map1(amrex::ParticleReal const tau, amrex::SmallVector< amrex::ParticleReal, 6, 1 > &particle, amrex::ParticleReal &zeval) const
Definition ExactCFbend.H:259
amrex::ParticleReal * m_k_skew_h_data
non-owning pointer to host cosine coefficients
Definition ExactCFbend.H:627
int m_id
number of integration steps per slice
Definition ExactCFbend.H:623
amrex::ParticleReal m_rc
magnetic ridigity in T-m
Definition ExactCFbend.H:639
int m_mapsteps
order used for the symplectic integration (2 or 4)
Definition ExactCFbend.H:622
amrex::ParticleReal m_beta
1 / m_betgam2
Definition ExactCFbend.H:636
amrex::ParticleReal m_slice_ds
non-owning pointer to device sine coefficients
Definition ExactCFbend.H:634
int m_ncoef
unique ExactMultipole id used for data lookup map
Definition ExactCFbend.H:625
amrex::ParticleReal * m_k_normal_d_data
non-owning pointer to host sine coefficients
Definition ExactCFbend.H:628
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void map2(amrex::ParticleReal const tau, amrex::SmallVector< amrex::ParticleReal, 6, 1 > &particle, amrex::ParticleReal &zeval) const
Definition ExactCFbend.H:360
amrex::ParticleReal * m_k_normal_h_data
number of Fourier coefficients
Definition ExactCFbend.H:626
amrex::ParticleReal * m_k_skew_d_data
non-owning pointer to device cosine coefficients
Definition ExactCFbend.H:629
amrex::ParticleReal m_ibetgam2
m_ds / nslice();
Definition ExactCFbend.H:635
void compute_constants(RefPart const &refpart)
Definition ExactCFbend.H:163
void finalize()
Definition ExactCFbend.H:606
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition ExactCFbend.H:537
amrex::ParticleReal m_brho
1 / m_beta
Definition ExactCFbend.H:638
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void operator()(amrex::ParticleReal &AMREX_RESTRICT x, amrex::ParticleReal &AMREX_RESTRICT y, amrex::ParticleReal &AMREX_RESTRICT t, amrex::ParticleReal &AMREX_RESTRICT px, amrex::ParticleReal &AMREX_RESTRICT py, amrex::ParticleReal &AMREX_RESTRICT pt, uint64_t &AMREX_RESTRICT idcpu, RefPart const &AMREX_RESTRICT refpart) const
Definition ExactCFbend.H:200
ExactCFbend(amrex::ParticleReal ds, std::vector< amrex::ParticleReal > k_normal, std::vector< amrex::ParticleReal > k_skew, int unit, amrex::ParticleReal dx=0, amrex::ParticleReal dy=0, amrex::ParticleReal rotation_degree=0, amrex::ParticleReal aperture_x=0, amrex::ParticleReal aperture_y=0, int int_order=2, int mapsteps=1, int nslice=1, std::optional< std::string > name=std::nullopt)
Definition ExactCFbend.H:97
int m_unit
Definition ExactCFbend.H:620
static constexpr auto type
Definition ExactCFbend.H:69
Definition alignment.H:27
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_out(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:109
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dy() const
Definition alignment.H:146
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal dx() const
Definition alignment.H:136
Alignment(amrex::ParticleReal dx, amrex::ParticleReal dy, amrex::ParticleReal rotation_degree)
Definition alignment.H:36
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void shift_in(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_Real &AMREX_RESTRICT px, T_Real &AMREX_RESTRICT py) const
Definition alignment.H:78
Definition beamoptic.H:219
Definition lineartransport.H:29
Definition named.H:29
AMREX_GPU_HOST Named(std::optional< std::string > name)
Definition named.H:57
AMREX_FORCE_INLINE std::string name() const
Definition named.H:122
Definition nofinalize.H:22
Definition pipeaperture.H:26
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void apply_aperture(T_Real &AMREX_RESTRICT x, T_Real &AMREX_RESTRICT y, T_IdCpu &AMREX_RESTRICT idcpu) const
Definition pipeaperture.H:59
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_x() const
Definition pipeaperture.H:90
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal aperture_y() const
Definition pipeaperture.H:101
PipeAperture(amrex::ParticleReal aperture_x, amrex::ParticleReal aperture_y)
Definition pipeaperture.H:32
Definition thick.H:24
Thick(amrex::ParticleReal ds, int nslice)
Definition thick.H:30
amrex::ParticleReal m_ds
Definition thick.H:58
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::ParticleReal ds() const
Definition thick.H:53
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE int nslice() const
Definition thick.H:43