Skip to content

Conversation

@manauref
Copy link
Collaborator

@manauref manauref commented Jan 13, 2026

Add check to ensure that the GK coordinate system is right handed.

Most importantly, this PR changes the definition of y from y=-alpha to y=alpha, and we change the signs in the definition of the binormal coordinate y (and the size of B_Z) in IWL mapc2p input files.

NOTE: the IWL input files don't pass the consistency checks. We've tried to investigate this some, even completely rewriting the mapc2p for those input files, but have not figured out why they fail. We leave it as failing at the moment, but at least now we know. It prints messages like

Running command: srun -u -n 4 ./gkeyll_20251111_180358 -g -M -c 1 -d 1 -e 4  -o max_run_time=21600
Creating app object ...
calc_metric.c: B and mapc2p are inconsistent (hat{b} and e_3 are not parallel).

Unfortunately, because we need every part of the domain to perform these checks and alert us if they fail, every MPI process is printing this warning, so the log file will have a lot of these at t=0.

Below we do a comparison of a TCV IWL 3x2v simulation ran with this branch vs. one ran in main.

IWL test

Here we compare a TCV IWL 3x2v with fixed source ran in main vs in this righthanded_checks branch. Up to nearly 0.5 ms the moments look basically the same.

Screenshot 2026-01-14 at 10 01 02 AM Screenshot 2026-01-14 at 10 04 22 AM Screenshot 2026-01-14 at 10 06 11 AM Screenshot 2026-01-14 at 10 07 44 AM

akashukla and others added 6 commits November 13, 2025 17:47
… rather than y=-alpha for tokamak geometry. Update the d3d IWL test so that it is right handed. One more check I will need to implement is whether the bfield_func provided by the user is actually consistent with mapc2p : the provided mapc2p's e_3 and B vector must be parallel. For tokamaks, I needed to change R_psiZ to provide dR and dZ rather than just dR/dZ because we take arctan(dR/dZ) to get some of the tangent vectors and this can give the wrong quadrant - dR and dZ are needed for atan2 which give the correct quadrant. This wasn't affecting things because of the way J is being calculated. I need to bring the cubic R_psiZ functions up to date so that they provide dR and dZ separately.
@manauref manauref requested review from Antoinehoff, akashukla, ammarhakim and tnbernard and removed request for akashukla January 14, 2026 17:12
@manauref manauref marked this pull request as ready for review January 14, 2026 17:15
@tnbernard
Copy link
Collaborator

When is this check called? For any input file with mapc2p?

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.

4 participants