Skip to content

Commit 1c6937b

Browse files
committed
move_pkt_withtime: Use template parameter for CLIGHT_ASSUMED
1 parent 919b112 commit 1c6937b

File tree

2 files changed

+21
-20
lines changed

2 files changed

+21
-20
lines changed

gammapkt.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,8 @@ static auto thomson_angle() -> double {
409409
return mu;
410410
}
411411

412-
[[nodiscard]] static auto scatter_dir(const std::array<double, 3> dir_in, const double cos_theta)
413-
-> std::array<double, 3>
412+
[[nodiscard]] static auto scatter_dir(const std::array<double, 3> dir_in,
413+
const double cos_theta) -> std::array<double, 3>
414414
// Routine for scattering a direction through angle theta.
415415
{
416416
// begin with setting the direction in coordinates where original direction
@@ -1000,15 +1000,15 @@ void wollaeger_thermalisation(Packet &pkt) {
10001000
bool end_packet = false;
10011001
while (!end_packet) {
10021002
// distance to the next cell
1003-
const auto [sdist, snext] =
1004-
grid::boundary_distance(pkt_copy.dir, pkt_copy.pos, pkt_copy.prop_time, pkt_copy.where, &pkt_copy.last_cross, true);
1003+
const auto [sdist, snext] = grid::boundary_distance(pkt_copy.dir, pkt_copy.pos, pkt_copy.prop_time, pkt_copy.where,
1004+
&pkt_copy.last_cross, true);
10051005
const double s_cont = sdist * t_current * t_current * t_current / std::pow(pkt_copy.prop_time, 3);
10061006
const int mgi = grid::get_cell_modelgridindex(pkt_copy.where);
10071007
if (mgi != grid::get_npts_model()) {
10081008
tau += grid::get_rho(mgi) * s_cont * mean_gamma_opac; // contribution to the integral
10091009
}
10101010
// move packet copy now
1011-
move_pkt_withtime(pkt_copy, sdist, true);
1011+
move_pkt_withtime<100 * CLIGHT_PROP>(pkt_copy, sdist);
10121012

10131013
grid::change_cell(pkt_copy, snext);
10141014
end_packet = (pkt_copy.type == TYPE_ESCAPE);
@@ -1070,7 +1070,7 @@ void guttman_thermalisation(Packet &pkt) {
10701070
column_densities[i] += grid::get_rho_tmin(mgi) * s_cont; // contribution to the integral
10711071
}
10721072
// move packet copy now
1073-
move_pkt_withtime(pkt_copy, sdist, true);
1073+
move_pkt_withtime<100 * CLIGHT_PROP>(pkt_copy, sdist);
10741074

10751075
grid::change_cell(pkt_copy, snext);
10761076
end_packet = (pkt_copy.type == TYPE_ESCAPE);

vectors.h

+15-14
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ template <size_t VECDIM>
3434
}
3535

3636
template <size_t S1, size_t S2>
37-
[[nodiscard]] [[gnu::const]] constexpr auto dot(const std::array<double, S1> x, const std::array<double, S2> y)
38-
-> double
37+
[[nodiscard]] [[gnu::const]] constexpr auto dot(const std::array<double, S1> x,
38+
const std::array<double, S2> y) -> double
3939
// vector dot product
4040
{
4141
return std::inner_product(x.begin(), x.end(), y.begin(), 0.);
4242
}
4343

44-
[[nodiscard]] [[gnu::pure]] constexpr auto get_velocity(std::span<const double, 3> x, const double t)
45-
-> std::array<double, 3>
44+
[[nodiscard]] [[gnu::pure]] constexpr auto get_velocity(std::span<const double, 3> x,
45+
const double t) -> std::array<double, 3>
4646
// Routine for getting velocity vector of the flow at a position with homologous expansion.
4747
{
4848
return std::array<double, 3>{x[0] / t, x[1] / t, x[2] / t};
@@ -59,8 +59,8 @@ template <size_t S1, size_t S2>
5959
return std::array<double, 3>{vec[0] * scalefactor, vec[1] * scalefactor, vec[2] * scalefactor};
6060
}
6161

62-
[[nodiscard]] [[gnu::const]] constexpr auto angle_ab(const std::array<double, 3> dir1, const std::array<double, 3> vel)
63-
-> std::array<double, 3>
62+
[[nodiscard]] [[gnu::const]] constexpr auto angle_ab(const std::array<double, 3> dir1,
63+
const std::array<double, 3> vel) -> std::array<double, 3>
6464
// aberation of angles in special relativity
6565
// dir1: direction unit vector in frame1
6666
// vel: velocity of frame2 relative to frame1
@@ -141,17 +141,17 @@ template <size_t S1, size_t S2>
141141
return doppler_nucmf_on_nurf(dir_rf, get_velocity(pos_rf, prop_time));
142142
}
143143

144+
template <double CLIGHT_ASSUMED = CLIGHT_PROP>
144145
constexpr auto move_pkt_withtime(std::span<double, 3> pos_rf, const std::array<double, 3> dir_rf, double &prop_time,
145146
const double nu_rf, double &nu_cmf, const double e_rf, double &e_cmf,
146-
const double distance, bool neglect_exp = false) -> double
147+
const double distance) -> double
147148
/// Subroutine to move a packet along a straight line (specified by current
148149
/// dir vector). The distance moved is in the rest frame.
149150
{
150-
double CLIGHT_PROP_DIST_CALC = (neglect_exp) ? 100 * CLIGHT_PROP : CLIGHT_PROP;
151151
assert_always(distance >= 0);
152152

153153
const double nu_cmf_old = nu_cmf;
154-
prop_time += distance / CLIGHT_PROP_DIST_CALC;
154+
prop_time += distance / CLIGHT_ASSUMED;
155155

156156
pos_rf[0] += (dir_rf[0] * distance);
157157
pos_rf[1] += (dir_rf[1] * distance);
@@ -171,9 +171,10 @@ constexpr auto move_pkt_withtime(std::span<double, 3> pos_rf, const std::array<d
171171
return dopplerfactor;
172172
}
173173

174-
constexpr auto move_pkt_withtime(Packet &pkt, const double distance, bool neglect_exp = false) -> double {
175-
return move_pkt_withtime(pkt.pos, pkt.dir, pkt.prop_time, pkt.nu_rf, pkt.nu_cmf, pkt.e_rf, pkt.e_cmf, distance,
176-
neglect_exp);
174+
template <double CLIGHT_ASSUMED = CLIGHT_PROP>
175+
constexpr auto move_pkt_withtime(Packet &pkt, const double distance) -> double {
176+
return move_pkt_withtime<CLIGHT_ASSUMED>(pkt.pos, pkt.dir, pkt.prop_time, pkt.nu_rf, pkt.nu_cmf, pkt.e_rf, pkt.e_cmf,
177+
distance);
177178
}
178179

179180
[[nodiscard]] [[gnu::const]] constexpr auto get_arrive_time(const Packet &pkt) -> double
@@ -310,8 +311,8 @@ constexpr auto move_pkt_withtime(Packet &pkt, const double distance, bool neglec
310311
}
311312

312313
// Routine to transform the Stokes Parameters from RF to CMF
313-
constexpr auto frame_transform(const std::array<double, 3> n_rf, double *Q, double *U, const std::array<double, 3> v)
314-
-> std::array<double, 3> {
314+
constexpr auto frame_transform(const std::array<double, 3> n_rf, double *Q, double *U,
315+
const std::array<double, 3> v) -> std::array<double, 3> {
315316
// Meridian frame in the RF
316317
const auto [ref1_rf, ref2_rf] = meridian(n_rf);
317318

0 commit comments

Comments
 (0)