Skip to content

Commit 768035c

Browse files
committed
RefPart.s: Compensated Sums
Use the compensated sum type to calculate `s`.
1 parent 954f41f commit 768035c

22 files changed

Lines changed: 46 additions & 60 deletions

src/elements/CFbend.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ namespace impactx::elements
229229
amrex::ParticleReal const pz = refpart.pz;
230230
amrex::ParticleReal const t = refpart.t;
231231
amrex::ParticleReal const pt = refpart.pt;
232-
amrex::ParticleReal const s = refpart.s;
233232

234233
// length of the current slice
235234
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -252,8 +251,8 @@ namespace impactx::elements
252251
refpart.z = z - (refpart.px - px)/B;
253252
refpart.t = t - (theta/B)*pt;
254253

255-
// advance integrated path length
256-
refpart.s = s + slice_ds;
254+
// advance integrated path length using compensated summation
255+
refpart.s += slice_ds;
257256
}
258257

259258
/** This pushes the covariance matrix. */

src/elements/ChrDrift.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ namespace impactx::elements
191191
amrex::ParticleReal const pz = refpart.pz;
192192
amrex::ParticleReal const t = refpart.t;
193193
amrex::ParticleReal const pt = refpart.pt;
194-
amrex::ParticleReal const s = refpart.s;
195194

196195
// length of the current slice
197196
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -205,8 +204,8 @@ namespace impactx::elements
205204
refpart.z = z + step*pz;
206205
refpart.t = t - step*pt;
207206

208-
// advance integrated path length
209-
refpart.s = s + slice_ds;
207+
// advance integrated path length using compensated summation
208+
refpart.s += slice_ds;
210209
}
211210

212211
/** This pushes the covariance matrix. */

src/elements/ChrPlasmaLens.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ namespace impactx::elements
276276
amrex::ParticleReal const pz = refpart.pz;
277277
amrex::ParticleReal const t = refpart.t;
278278
amrex::ParticleReal const pt = refpart.pt;
279-
amrex::ParticleReal const s = refpart.s;
280279

281280
// length of the current slice
282281
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -290,8 +289,8 @@ namespace impactx::elements
290289
refpart.z = z + step*pz;
291290
refpart.t = t - step*pt;
292291

293-
// advance integrated path length
294-
refpart.s = s + slice_ds;
292+
// advance integrated path length using compensated summation
293+
refpart.s += slice_ds;
295294
}
296295

297296
/** This pushes the covariance matrix. */

src/elements/ChrQuad.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ namespace impactx::elements
270270
amrex::ParticleReal const pz = refpart.pz;
271271
amrex::ParticleReal const t = refpart.t;
272272
amrex::ParticleReal const pt = refpart.pt;
273-
amrex::ParticleReal const s = refpart.s;
274273

275274
// length of the current slice
276275
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -284,8 +283,8 @@ namespace impactx::elements
284283
refpart.z = z + step*pz;
285284
refpart.t = t - step*pt;
286285

287-
// advance integrated path length
288-
refpart.s = s + slice_ds;
286+
// advance integrated path length using compensated summation
287+
refpart.s += slice_ds;
289288
}
290289

291290
/** This pushes the covariance matrix. */

src/elements/ChrUniformAcc.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ namespace impactx::elements
249249
amrex::ParticleReal const pz = refpart.pz;
250250
amrex::ParticleReal const t = refpart.t;
251251
amrex::ParticleReal const pt = refpart.pt;
252-
amrex::ParticleReal const s = refpart.s;
253252

254253
// length of the current slice
255254
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -277,8 +276,8 @@ namespace impactx::elements
277276
refpart.py = py*bgf/bgi;
278277
refpart.pz = pz*bgf/bgi;
279278

280-
// advance integrated path length
281-
refpart.s = s + slice_ds;
279+
// advance integrated path length using compensated summation
280+
refpart.s += slice_ds;
282281
}
283282

284283
/** This pushes the covariance matrix. */

src/elements/ConstF.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@ namespace impactx::elements
202202
amrex::ParticleReal const pz = refpart.pz;
203203
amrex::ParticleReal const t = refpart.t;
204204
amrex::ParticleReal const pt = refpart.pt;
205-
amrex::ParticleReal const s = refpart.s;
206205

207206
// length of the current slice
208207
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -216,8 +215,8 @@ namespace impactx::elements
216215
refpart.z = z + step*pz;
217216
refpart.t = t - step*pt;
218217

219-
// advance integrated path length
220-
refpart.s = s + slice_ds;
218+
// advance integrated path length using compensated summation
219+
refpart.s += slice_ds;
221220

222221
}
223222

src/elements/Drift.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ namespace impactx::elements
179179
amrex::ParticleReal const pz = refpart.pz;
180180
amrex::ParticleReal const t = refpart.t;
181181
amrex::ParticleReal const pt = refpart.pt;
182-
amrex::ParticleReal const s = refpart.s;
183182

184183
// length of the current slice
185184
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -193,8 +192,8 @@ namespace impactx::elements
193192
refpart.z = z + step*pz;
194193
refpart.t = t - step*pt;
195194

196-
// advance integrated path length
197-
refpart.s = s + slice_ds;
195+
// advance integrated path length using compensated summation
196+
refpart.s += slice_ds;
198197
}
199198

200199
/** This pushes the covariance matrix. */

src/elements/ExactCFbend.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ namespace impactx::elements
476476
amrex::ParticleReal const pz = refpart.pz;
477477
amrex::ParticleReal const t = refpart.t;
478478
amrex::ParticleReal const pt = refpart.pt;
479-
amrex::ParticleReal const s = refpart.s;
480479
amrex::ParticleReal const brho = refpart.rigidity_Tm();
481480

482481
#if AMREX_DEVICE_COMPILE
@@ -522,8 +521,8 @@ namespace impactx::elements
522521

523522
}
524523

525-
// advance integrated path length
526-
refpart.s = s + slice_ds;
524+
// advance integrated path length using compensated summation
525+
refpart.s += slice_ds;
527526
}
528527

529528

src/elements/ExactDrift.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ namespace impactx::elements
187187
amrex::ParticleReal const pz = refpart.pz;
188188
amrex::ParticleReal const t = refpart.t;
189189
amrex::ParticleReal const pt = refpart.pt;
190-
amrex::ParticleReal const s = refpart.s;
191190

192191
// length of the current slice
193192
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -201,8 +200,8 @@ namespace impactx::elements
201200
refpart.z = z + step*pz;
202201
refpart.t = t - step*pt;
203202

204-
// advance integrated path length
205-
refpart.s = s + slice_ds;
203+
// advance integrated path length using compensated summation
204+
refpart.s += slice_ds;
206205
}
207206

208207
/** This pushes the covariance matrix. */

src/elements/ExactMultipole.H

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ namespace impactx::elements
416416
amrex::ParticleReal const pz = refpart.pz;
417417
amrex::ParticleReal const t = refpart.t;
418418
amrex::ParticleReal const pt = refpart.pt;
419-
amrex::ParticleReal const s = refpart.s;
420419

421420
// length of the current slice
422421
amrex::ParticleReal const slice_ds = m_ds / nslice();
@@ -430,8 +429,8 @@ namespace impactx::elements
430429
refpart.z = z + step*pz;
431430
refpart.t = t - step*pt;
432431

433-
// advance integrated path length
434-
refpart.s = s + slice_ds;
432+
// advance integrated path length using compensated summation
433+
refpart.s += slice_ds;
435434
}
436435

437436
/** This function returns the linear transport map.

0 commit comments

Comments
 (0)