Skip to content

Commit 7eb84c8

Browse files
authored
Merge pull request #696 from beomki-yeo/adjust-text5
Revert the RIdders algorithm back to original form
2 parents 50845bb + f8cd92c commit 7eb84c8

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

tests/integration_tests/cpu/propagator/jacobian_validation.cpp

+7-14
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,13 @@ namespace {
5656
const vector3 B_z{0.f, 0.f, 1.996f * unit<scalar>::T};
5757

5858
// Initial delta for numerical differentiaion
59-
const std::array<scalar, 5u> h_sizes_rect{2e0f, 2e0f, 2e-2f, 1e-3f, 1e-3f};
60-
const std::array<scalar, 5u> h_sizes_wire{2e0f, 2e0f, 2e-2f, 1e-3f, 1e-3f};
59+
const std::array<scalar, 5u> h_sizes_rect{3e0f, 3e0f, 2e-2f, 1e-3f, 1e-3f};
60+
const std::array<scalar, 5u> h_sizes_wire{3e0f, 3e0f, 2e-2f, 1e-3f, 1e-3f};
6161

6262
// Ridders' algorithm setup
6363
constexpr const unsigned int Nt = 50u;
64-
const std::array<scalar, 5u> safe{3.0f, 3.0f, 3.0f, 3.0f, 3.0f};
64+
const std::array<scalar, 5u> safe{5.0f, 5.0f, 5.0f, 5.0f, 5.0f};
6565
const std::array<scalar, 5u> con{1.2f, 1.2f, 1.2f, 1.2f, 1.2f};
66-
constexpr const scalar threshold_factor = 10.f;
6766
constexpr const scalar big = std::numeric_limits<scalar>::max();
6867

6968
std::random_device rd;
@@ -161,24 +160,18 @@ struct ridders_derivative {
161160
math::max(math::abs(Arr[j][q][p] - Arr[j][q - 1][p]),
162161
math::abs(Arr[j][q][p] - Arr[j][q - 1][p - 1]));
163162

164-
const scalar V = getter::element(differentiated_jacobian, j, i);
165-
166163
if (errt[j] <= err[j]) {
167-
if (complete[j] == false ||
168-
math::abs(Arr[j][q][p]) >
169-
threshold_factor * math::abs(V) ||
170-
V * Arr[j][q][p] < 0.f) {
171164

165+
if (complete[j] == false) {
172166
err[j] = errt[j];
173167
getter::element(differentiated_jacobian, j, i) =
174168
Arr[j][q][p];
175169
/*
176170
// Please leave this for debug
177-
if (j == e_bound_theta && i == e_bound_phi) {
171+
if (j == e_bound_theta && i == e_bound_loc1) {
178172
std::cout << getter::element(
179173
differentiated_jacobian, j, i)
180-
<< " " << math::abs(Arr[j][q][p]) << " "
181-
<< threshold_factor * math::abs(V) << " "
174+
<< " " << math::abs(Arr[j][q][p])
182175
<< std::endl;
183176
}
184177
*/
@@ -190,7 +183,7 @@ struct ridders_derivative {
190183
for (unsigned int j = 0; j < 5u; j++) {
191184
/*
192185
// Please leave this for debug
193-
if (j == e_bound_theta && i == e_bound_phi) {
186+
if (j == e_bound_theta && i == e_bound_loc1) {
194187
std::cout << getter::element(differentiated_jacobian, j, i)
195188
<< " " << Arr[j][p][p] << " "
196189
<< Arr[j][p - 1][p - 1] << " "

tests/validation/root/rk_tolerance_comparison.C

+23-15
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ double step_title_x = 0.175;
3333
double step_title_y = 0.835;
3434
double step_ygap = -0.05;
3535
double x_label_offset = 0.015;
36+
double x_margin = 1;
3637
double y_label_offset = 0.015;
3738
double rk_title_x_offset = 0.9;
38-
double rk_title_x = -15.57;
39+
double rk_title_offset_fraction = 0.0216;
3940
double rk_title_y = 13.765;
4041
double rk_ygap = -0.8;
4142
double rk_header_text_size = 0.046;
@@ -56,7 +57,7 @@ double pad_y0 = 0.005f;
5657
double pad_y1 = 1.f;
5758
double ymin = -2;
5859
double ymax = 4.;
59-
std::array<double, 4u> ldim{0.189233, 0.509404, 0.907268, 0.954545};
60+
std::array<double, 4u> ldim{0.189233, 0.510081, 0.907268, 0.954545};
6061
} // namespace
6162

6263
std::vector<std::string> create_labels() {
@@ -238,16 +239,17 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
238239
mg->GetYaxis()->SetLabelSize(label_font_size_rk_tol);
239240
mg->GetYaxis()->SetRangeUser(yaxis_min - yaxis_margin,
240241
yaxis_max + yaxis_margin);
241-
mg->GetYaxis()->SetNdivisions(406, kFALSE);
242242
mg->GetYaxis()->SetLabelOffset(0.01);
243243
mg->GetYaxis()->SetTitleFont(title_font);
244244
mg->GetXaxis()->SetTitleFont(title_font);
245245

246-
mg->GetYaxis()->SetLabelSize(0);
247-
mg->GetYaxis()->SetTickLength(0);
246+
double x_min = x_vec.front();
247+
double x_max = x_vec.back();
248248

249249
if (x_vec.size() > 10) {
250-
mg->GetXaxis()->SetLimits(x_vec.front() - 1, x_vec.back() + 1);
250+
x_min = x_min - x_margin;
251+
x_max = x_max + x_margin;
252+
mg->GetXaxis()->SetLimits(x_min, x_max);
251253
mg->GetXaxis()->SetLabelSize(0);
252254
mg->GetXaxis()->SetTickLength(0);
253255

@@ -260,25 +262,31 @@ void draw_graphs(const std::string header_title, const std::string geom_title,
260262
ga->SetLabelSize(label_font_size_rk_tol);
261263
ga->SetLabelOffset(-0.0065);
262264
ga->Draw();
265+
266+
mg->GetYaxis()->SetLabelSize(0);
267+
mg->GetYaxis()->SetTickLength(0);
268+
auto ga_y = new TGaxis(x_min, yaxis_min, x_min, yaxis_max, yaxis_min,
269+
yaxis_max, 406, "N");
270+
ga_y->SetLabelFont(label_font);
271+
ga_y->SetLabelOffset(0.02);
272+
ga_y->SetLabelSize(label_font_size_rk_tol);
273+
ga_y->Draw();
274+
263275
} else {
264276
mg->Draw("APL");
265277
}
266278

267-
auto ga_y = new TGaxis(x_vec.front() - 1, yaxis_min, x_vec.front() - 1,
268-
yaxis_max, yaxis_min, yaxis_max, 406, "N");
269-
ga_y->SetLabelFont(label_font);
270-
ga_y->SetLabelOffset(0.02);
271-
ga_y->SetLabelSize(label_font_size_rk_tol);
272-
ga_y->Draw();
273-
274279
TLegendEntry* header =
275280
(TLegendEntry*)legend->GetListOfPrimitives()->First();
276281
header->SetTextFont(22);
277282
header->SetTextSize(.033);
278283

284+
double rk_title_deltaX =
285+
(x_vec.back() - x_vec.front()) * rk_title_offset_fraction;
286+
279287
legend->Draw();
280-
draw_text(rk_title_x, rk_title_y, rk_ygap, rk_header_text_size,
281-
rk_geom_text_size, header_title, geom_title);
288+
draw_text(rk_title_deltaX + x_vec.front(), rk_title_y, rk_ygap,
289+
rk_header_text_size, rk_geom_text_size, header_title, geom_title);
282290
}
283291

284292
void draw_mean_step_size(const std::string header_title,

0 commit comments

Comments
 (0)