Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ cc_test(
srcs = ["laplace_solver_test.cc"],
data = [
"//vmecpp/test_data:cth_like_free_bdy",
"//vmecpp/test_data:cth_like_free_bdy_asym",
"//vmecpp_large_cpp_tests/test_data:cth_like_free_bdy",
"//vmecpp_large_cpp_tests/test_data:cth_like_free_bdy_asym",
],
deps = [
"//vmecpp/free_boundary/laplace_solver",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,44 @@ TEST_P(FourPTest, CheckFourP) {
static_cast<double>(vac1n_fourp["grpmn"][m][nf - n][k][l]) -
grpmn_sin_singular_negn;

// TODO(jons): for lasym, need cos-part of grpmn from
// educational_VMEC
EXPECT_TRUE(IsCloseRelAbs(grpmn_sin_reference_posn,
grpmn_sin_regular_posn, tolerance));
EXPECT_TRUE(IsCloseRelAbs(grpmn_sin_reference_negn,
grpmn_sin_regular_negn, tolerance));

if (!s.lasym) {
continue;
}

// The cos part exists only for an asymmetric equilibrium, where
// educational_VMEC writes it as grpmn_cos.
const double grpmn_cos_singular_posn =
scale_to_match_fortran_singular *
si.grpmn_cos[idx_m_posn * numLocal + klRel];
const double grpmn_cos_singular_negn =
scale_to_match_fortran_singular *
si.grpmn_cos[idx_m_negn * numLocal + klRel];
const double grpmn_cos_regular_posn =
scale_to_match_fortran_regular *
ls.grpmn_cos[idx_m_posn * numLocal + klRel];
const double grpmn_cos_regular_negn =
scale_to_match_fortran_regular *
ls.grpmn_cos[idx_m_negn * numLocal + klRel];
const double grpmn_cos_reference_posn =
static_cast<double>(
vac1n_fourp["grpmn_cos"][m][nf + n][k][l]) -
grpmn_cos_singular_posn;
const double grpmn_cos_reference_negn =
static_cast<double>(
vac1n_fourp["grpmn_cos"][m][nf - n][k][l]) -
grpmn_cos_singular_negn;

EXPECT_TRUE(IsCloseRelAbs(grpmn_cos_reference_posn,
grpmn_cos_regular_posn, tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
EXPECT_TRUE(IsCloseRelAbs(grpmn_cos_reference_negn,
grpmn_cos_regular_negn, tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
} // kl
} // m
} // n
Expand All @@ -154,7 +186,11 @@ TEST_P(FourPTest, CheckFourP) {
INSTANTIATE_TEST_SUITE_P(TestLaplaceSolver, FourPTest,
Values(DataSource{.identifier = "cth_like_free_bdy",
.tolerance = 1.0e-9,
.iter2_to_test = {53, 54}}));
.iter2_to_test = {53, 54}},
DataSource{
.identifier = "cth_like_free_bdy_asym",
.tolerance = 1.0e-9,
.iter2_to_test = {53}}));

class FourISymmTest : public TestWithParam<DataSource> {
protected:
Expand Down Expand Up @@ -309,12 +345,32 @@ TEST_P(FourIAccumulateGrpmnTest, CheckFourIAccumulateGrpmn) {
scale_to_match_fortran_regular *
ls.grpmn_sin[idx_m_negn * numLocal + klRel];

// TODO(jons): for lasym, need cos-part of grpmn from
// educational_VMEC
EXPECT_TRUE(IsCloseRelAbs(vac1n_fourp["grpmn"][m][nf + n][k][l],
grpmn_sin_regular_posn, tolerance));
EXPECT_TRUE(IsCloseRelAbs(vac1n_fourp["grpmn"][m][nf - n][k][l],
grpmn_sin_regular_negn, tolerance));

if (!s.lasym) {
continue;
}

// The cos part exists only for an asymmetric equilibrium, where
// educational_VMEC writes it as grpmn_cos.
const double grpmn_cos_regular_posn =
scale_to_match_fortran_regular *
ls.grpmn_cos[idx_m_posn * numLocal + klRel];
const double grpmn_cos_regular_negn =
scale_to_match_fortran_regular *
ls.grpmn_cos[idx_m_negn * numLocal + klRel];

EXPECT_TRUE(
IsCloseRelAbs(vac1n_fourp["grpmn_cos"][m][nf + n][k][l],
grpmn_cos_regular_posn, tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
EXPECT_TRUE(
IsCloseRelAbs(vac1n_fourp["grpmn_cos"][m][nf - n][k][l],
grpmn_cos_regular_negn, tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
} // kl
} // m
} // n
Expand All @@ -326,7 +382,11 @@ TEST_P(FourIAccumulateGrpmnTest, CheckFourIAccumulateGrpmn) {
INSTANTIATE_TEST_SUITE_P(TestLaplaceSolver, FourIAccumulateGrpmnTest,
Values(DataSource{.identifier = "cth_like_free_bdy",
.tolerance = 1.0e-9,
.iter2_to_test = {53, 54}}));
.iter2_to_test = {53, 54}},
DataSource{
.identifier = "cth_like_free_bdy_asym",
.tolerance = 1.0e-9,
.iter2_to_test = {53}}));

class FourIKvDftTest : public TestWithParam<DataSource> {
protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ cc_test(
srcs = ["singular_integrals_test.cc"],
data = [
"//vmecpp/test_data:cth_like_free_bdy",
"//vmecpp/test_data:cth_like_free_bdy_asym",
"//vmecpp_large_cpp_tests/test_data:cth_like_free_bdy",
"//vmecpp_large_cpp_tests/test_data:cth_like_free_bdy_asym",
],
deps = [
"//vmecpp/free_boundary/singular_integrals",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ TEST_P(AnalytTest, CheckAnalyt) {
const int mf = s.mpol + 1;
const int mnfull = (2 * nf + 1) * (mf + 1);
std::vector<double> bvec_sin(mnfull, 0.0);
std::vector<double> bvec_cos(mnfull, 0.0);

for (int thread_id = 0; thread_id < vmec.vac_num_threads_; ++thread_id) {
const Nestor& n = static_cast<const Nestor&>(*vmec.fb_vac_[thread_id]);
Expand Down Expand Up @@ -172,6 +173,9 @@ TEST_P(AnalytTest, CheckAnalyt) {
// --> accumulate contributions to Fourier transform from all threads
for (int mn = 0; mn < mnfull; ++mn) {
bvec_sin[mn] += si.bvec_sin[mn];
if (s.lasym) {
bvec_cos[mn] += si.bvec_cos[mn];
}
}

if (vmec.m_[0]->get_ivacskip() == 0) {
Expand Down Expand Up @@ -205,8 +209,6 @@ TEST_P(AnalytTest, CheckAnalyt) {
// cmns in Fortran has alp (= 2 pi / nfp) in it; VMEC++ does not
const double scale_to_match_fortran = 2.0 * M_PI / s.nfp;

// TODO(jons): for lasym, need cos-part of grpmn from
// educational_VMEC
EXPECT_TRUE(
IsCloseRelAbs(vac1n_analyt["grpmn"][m][nf + n][k][l],
scale_to_match_fortran *
Expand All @@ -217,6 +219,21 @@ TEST_P(AnalytTest, CheckAnalyt) {
scale_to_match_fortran *
si.grpmn_sin[idx_m_negn * numLocal + klRel],
tolerance));

if (s.lasym) {
EXPECT_TRUE(IsCloseRelAbs(
vac1n_analyt["grpmn_cos"][m][nf + n][k][l],
scale_to_match_fortran *
si.grpmn_cos[idx_m_posn * numLocal + klRel],
tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
EXPECT_TRUE(IsCloseRelAbs(
vac1n_analyt["grpmn_cos"][m][nf - n][k][l],
scale_to_match_fortran *
si.grpmn_cos[idx_m_negn * numLocal + klRel],
tolerance))
<< "m = " << m << ", n = " << n << ", kl = " << kl;
}
} // kl
} // m
} // n
Expand All @@ -233,8 +250,6 @@ TEST_P(AnalytTest, CheckAnalyt) {
const double scale_to_match_fortran =
2.0 * M_PI / s.nfp * 4.0 * M_PI * M_PI;

// TODO(jons): for lasym, need cos-part of bvec from educational_VMEC

// Fortran order along n in bvec: -nf, -nf+1, ..., -1, 0, 1, ..., nf-1,
// nf
EXPECT_TRUE(IsCloseRelAbs(vac1n_analyt["bvec"][m][nf + n],
Expand All @@ -243,6 +258,17 @@ TEST_P(AnalytTest, CheckAnalyt) {
EXPECT_TRUE(IsCloseRelAbs(vac1n_analyt["bvec"][m][nf - n],
scale_to_match_fortran * bvec_sin[idx_m_negn],
tolerance));

if (s.lasym) {
EXPECT_TRUE(IsCloseRelAbs(
vac1n_analyt["bvec_cos"][m][nf + n],
scale_to_match_fortran * bvec_cos[idx_m_posn], tolerance))
<< "m = " << m << ", n = " << n;
EXPECT_TRUE(IsCloseRelAbs(
vac1n_analyt["bvec_cos"][m][nf - n],
scale_to_match_fortran * bvec_cos[idx_m_negn], tolerance))
<< "m = " << m << ", n = " << n;
}
} // m
} // n
}
Expand All @@ -251,6 +277,10 @@ TEST_P(AnalytTest, CheckAnalyt) {
INSTANTIATE_TEST_SUITE_P(TestSingularIntegrals, AnalytTest,
Values(DataSource{.identifier = "cth_like_free_bdy",
.tolerance = 1.0e-9,
.iter2_to_test = {53, 54}}));
.iter2_to_test = {53, 54}},
DataSource{
.identifier = "cth_like_free_bdy_asym",
.tolerance = 1.0e-9,
.iter2_to_test = {53}}));

} // namespace vmecpp
6 changes: 6 additions & 0 deletions src/vmecpp/cpp/vmecpp_large_cpp_tests/test_data/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ filegroup(
] + glob(["cth_like_free_bdy/**/*.json"]),
)

filegroup(
name = "cth_like_free_bdy_asym",
visibility = ["//visibility:public"],
srcs = glob(["cth_like_free_bdy_asym/**/*.json"]),
)

filegroup(
name = "w7x",
visibility = ["//visibility:public"],
Expand Down
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Loading