Skip to content

B.n free boundary solver (only valid in vacuum)#437

Draft
jurasic-pf wants to merge 1 commit intomainfrom
bdotn-freeboundary
Draft

B.n free boundary solver (only valid in vacuum)#437
jurasic-pf wants to merge 1 commit intomainfrom
bdotn-freeboundary

Conversation

@jurasic-pf
Copy link
Copy Markdown
Collaborator

@jurasic-pf jurasic-pf commented Mar 12, 2026

TL;DR

Added a new free boundary method ONLY_COILS_BDOTN that uses B_coils·n = 0 boundary condition instead of pressure continuity for vacuum calculations.

Copy link
Copy Markdown
Collaborator Author

jurasic-pf commented Mar 12, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

// use the Boundary Integral Equation Solver for Toroidal systems
// for the free-boundary force contribution
BIEST
BIEST,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for enum constant 'BIEST' [readability-identifier-naming]

Suggested change
BIEST,
kBiest,


// use just the coils field with B_coils . n = 0 boundary condition
// instead of pressure continuity
ONLY_COILS_BDOTN
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for enum constant 'ONLY_COILS_BDOTN' [readability-identifier-naming]

Suggested change
ONLY_COILS_BDOTN
kOnlyCoilsBdotn

// Original pressure continuity boundary condition.
// MUST NOT BREAK TRI-DIAGONAL RADIAL COUPLING: OFFENDS
// PRECONDITIONER!
double edgePressure =
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for variable 'edgePressure' [readability-identifier-naming]

Suggested change
double edgePressure =
double edge_pressure =

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:1061:

-           if (edgePressure != 0.0) {
-             edgePressure = m_p_.evalMassProfile(1.0) / edgePressure *
+           if (edge_pressure != 0.0) {
+             edge_pressure = m_p_.evalMassProfile(1.0) / edge_pressure *

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:1082:

-                 m_h_.vacuum_magnetic_pressure[idx_lk] + edgePressure;
+                 m_h_.vacuum_magnetic_pressure[idx_lk] + edge_pressure;

const int k = kl / s_.nThetaEff;
const int l = kl % s_.nThetaEff;
const int idx_lk = l * s_.nZeta + k;
double outsideEdgePressure =
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for variable 'outsideEdgePressure' [readability-identifier-naming]

Suggested change
double outsideEdgePressure =
double outside_edge_pressure =

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:1086:

-             rBSq[kl] = outsideEdgePressure * (r1_e[idx_kl] + r1_o[idx_kl]) /
+             rBSq[kl] = outside_edge_pressure * (r1_e[idx_kl] + r1_o[idx_kl]) /

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:1090:

-             delBSq[kl] = fabs(outsideEdgePressure - insideTotalPressure[kl]);
+             delBSq[kl] = fabs(outside_edge_pressure - insideTotalPressure[kl]);

}

double IdealMhdModel::get_delbn() const {
double delBnAvg = 0.0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for variable 'delBnAvg' [readability-identifier-naming]

Suggested change
double delBnAvg = 0.0;
double del_bn_avg = 0.0;

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:3630:

-       delBnAvg += delBn[kl] * s_.wInt[l];
+       del_bn_avg += delBn[kl] * s_.wInt[l];

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:3633:

-     delBnAvg /= delBnNorm;
+     del_bn_avg /= delBnNorm;

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:3635:

-   return delBnAvg;
+   return del_bn_avg;

double delBnAvg = 0.0;
if (m_fc_.lfreeb &&
m_vacuum_pressure_state_ == VacuumPressureState::kActive) {
double delBnNorm = 0.0;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: invalid case style for variable 'delBnNorm' [readability-identifier-naming]

Suggested change
double delBnNorm = 0.0;
double del_bn_norm = 0.0;

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:3631:

-       delBnNorm += insideTotalPressure[kl] * s_.wInt[l];
+       del_bn_norm += insideTotalPressure[kl] * s_.wInt[l];

src/vmecpp/cpp/vmecpp/vmec/ideal_mhd_model/ideal_mhd_model.cc:3633:

-     delBnAvg /= delBnNorm;
+     delBnAvg /= del_bn_norm;

@jurasic-pf jurasic-pf marked this pull request as ready for review March 12, 2026 13:04
@graphite-app graphite-app bot changed the base branch from jurasic-vmec-from-indata to graphite-base/437 March 18, 2026 15:08
@graphite-app graphite-app bot force-pushed the graphite-base/437 branch from bcc2392 to 5593167 Compare March 18, 2026 15:10
@graphite-app graphite-app bot force-pushed the bdotn-freeboundary branch from b6253dc to 534e821 Compare March 18, 2026 15:10
@graphite-app graphite-app bot changed the base branch from graphite-base/437 to jurasic-vmec-from-indata March 18, 2026 15:11
@graphite-app graphite-app bot force-pushed the bdotn-freeboundary branch from 534e821 to 0ed610f Compare March 18, 2026 15:11
@jurasic-pf jurasic-pf changed the base branch from jurasic-vmec-from-indata to graphite-base/437 March 18, 2026 15:43
Copy link
Copy Markdown
Collaborator

jons-pf commented Mar 26, 2026

@jurasic-pf This one currently segfaults in CI - sure that I should review this already?

@jurasic-pf jurasic-pf marked this pull request as draft March 26, 2026 17:57
Copy link
Copy Markdown
Collaborator Author

right, these ones are definitely drafts

@jurasic-pf jurasic-pf force-pushed the bdotn-freeboundary branch 2 times, most recently from 8c27a5f to 21297d8 Compare March 27, 2026 00:04
@graphite-app graphite-app bot force-pushed the bdotn-freeboundary branch from 21297d8 to b02ff54 Compare March 27, 2026 00:38
@graphite-app graphite-app bot force-pushed the graphite-base/437 branch from 128f815 to 69142e7 Compare March 27, 2026 00:38
@graphite-app graphite-app bot changed the base branch from graphite-base/437 to main March 27, 2026 00:39
@graphite-app graphite-app bot force-pushed the bdotn-freeboundary branch from b02ff54 to 7c80e22 Compare March 27, 2026 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants