@@ -415,6 +415,7 @@ DETRAY_HOST_DEVICE inline auto detray::rk_stepper<
415
415
bvec2[1u ] = bvec2_tmp[1u ];
416
416
bvec2[2u ] = bvec2_tmp[2u ];
417
417
418
+ assert (delta != 0 .f );
418
419
const vector3_type gradient = (bvec1 - bvec2) * (1 .f / (2 .f * delta));
419
420
420
421
getter::element (dBdr, 0u , i) = gradient[0u ];
@@ -475,6 +476,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper<
475
476
return 0 .f ;
476
477
}
477
478
479
+ assert (qop != 0 .f );
478
480
const scalar_type q = this ->particle_hypothesis ().charge ();
479
481
const scalar_type p = q / qop;
480
482
const scalar_type mass = this ->particle_hypothesis ().mass ();
@@ -487,6 +489,7 @@ DETRAY_HOST_DEVICE auto detray::rk_stepper<
487
489
488
490
// Assert that a momentum is a positive value
489
491
assert (p >= 0 .f );
492
+ assert (q != 0 .f );
490
493
491
494
// d(qop)ds, which is equal to (qop) * E * (-dE/ds) / p^2
492
495
// or equal to (qop)^3 * E * (-dE/ds) / q^2
@@ -532,6 +535,8 @@ detray::rk_stepper<magnetic_field_t, algebra_t, constraint_t, policy_t,
532
535
533
536
// Check Eq 3.12 of
534
537
// (https://iopscience.iop.org/article/10.1088/1748-0221/4/04/P04016/meta)
538
+ assert (E2 != 0 .f );
539
+ assert (g != 0 .f );
535
540
return dqopds * (1 .f / qop * (3 .f - p2 / E2 ) + 1 .f / g * dgdqop);
536
541
}
537
542
@@ -545,6 +550,10 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
545
550
const detray::stepping::config& cfg, const bool do_reset,
546
551
const material<scalar_type>* vol_mat_ptr) const {
547
552
553
+ // Check navigator and actor results
554
+ assert (dist_to_next != 0 .f );
555
+ assert (!stepping ().is_invalid ());
556
+
548
557
// Get stepper and navigator states
549
558
auto & magnetic_field = stepping.m_magnetic_field ;
550
559
@@ -564,6 +573,9 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
564
573
565
574
// First Runge-Kutta point
566
575
const auto bvec = magnetic_field.at (pos[0 ], pos[1 ], pos[2 ]);
576
+ assert (math::isfinite (bvec[0 ]));
577
+ assert (math::isfinite (bvec[1 ]));
578
+ assert (math::isfinite (bvec[2 ]));
567
579
sd.b_first [0 ] = bvec[0 ];
568
580
sd.b_first [1 ] = bvec[1 ];
569
581
sd.b_first [2 ] = bvec[2 ];
@@ -577,6 +589,7 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
577
589
578
590
// / RKN step trial and error estimation
579
591
const auto estimate_error = [&](const scalar_type& h) {
592
+ assert (h != 0 );
580
593
// State the square and half of the step size
581
594
const scalar_type h2{h * h};
582
595
const scalar_type half_h{h * 0 .5f };
@@ -587,6 +600,9 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
587
600
const point3_type pos1 =
588
601
pos + half_h * sd.t [0u ] + h2 * 0 .125f * sd.dtds [0u ];
589
602
const auto bvec1 = magnetic_field.at (pos1[0 ], pos1[1 ], pos1[2 ]);
603
+ assert (math::isfinite (bvec1[0 ]));
604
+ assert (math::isfinite (bvec1[1 ]));
605
+ assert (math::isfinite (bvec1[2 ]));
590
606
sd.b_middle [0 ] = bvec1[0 ];
591
607
sd.b_middle [1 ] = bvec1[1 ];
592
608
sd.b_middle [2 ] = bvec1[2 ];
@@ -609,6 +625,9 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
609
625
// Eq (84) of https://doi.org/10.1016/0029-554X(81)90063-X
610
626
const point3_type pos2 = pos + h * sd.t [0u ] + h2 * 0 .5f * sd.dtds [2u ];
611
627
const auto bvec2 = magnetic_field.at (pos2[0 ], pos2[1 ], pos2[2 ]);
628
+ assert (math::isfinite (bvec2[0 ]));
629
+ assert (math::isfinite (bvec2[1 ]));
630
+ assert (math::isfinite (bvec2[2 ]));
612
631
sd.b_last [0 ] = bvec2[0 ];
613
632
sd.b_last [1 ] = bvec2[1 ];
614
633
sd.b_last [2 ] = bvec2[2 ];
@@ -620,8 +639,7 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
620
639
621
640
// Compute and check the local integration error estimate
622
641
// @Todo
623
- constexpr const scalar_type one_sixth{
624
- static_cast <scalar_type>(1 . / 6 .)};
642
+ constexpr auto one_sixth{static_cast <scalar_type>(1 . / 6 .)};
625
643
const vector3_type err_vec =
626
644
one_sixth * h2 *
627
645
(sd.dtds [0u ] - sd.dtds [1u ] - sd.dtds [2u ] + sd.dtds [3u ]);
@@ -633,6 +651,7 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
633
651
// / estimate @param err
634
652
const auto step_size_scaling =
635
653
[&cfg](const scalar_type& err) -> scalar_type {
654
+ assert (err != 0 .f );
636
655
return static_cast <scalar_type>(
637
656
math::min (math::max (math::sqrt (math::sqrt (cfg.rk_error_tol / err)),
638
657
static_cast <scalar_type>(0.25 )),
@@ -649,6 +668,7 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
649
668
650
669
error = math::max (estimate_error (stepping.step_size ()),
651
670
static_cast <scalar_type>(1e-20 ));
671
+ assert (math::isfinite (error));
652
672
653
673
// Error is small enough
654
674
// ---> break and advance track
@@ -683,6 +703,7 @@ DETRAY_HOST_DEVICE inline bool detray::rk_stepper<
683
703
684
704
// Advance track state
685
705
stepping.advance_track (sd, vol_mat_ptr);
706
+ assert (!stepping ().is_invalid ());
686
707
687
708
// Advance jacobian transport
688
709
if (cfg.do_covariance_transport ) {
0 commit comments