Skip to content

GK checks on right handed coordinate system#933

Open
manauref wants to merge 16 commits intomainfrom
righthanded_checks
Open

GK checks on right handed coordinate system#933
manauref wants to merge 16 commits intomainfrom
righthanded_checks

Conversation

@manauref
Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@manauref
Copy link
Copy Markdown
Collaborator Author

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

Yes, any input file with mapc2p or with tokamak numerical geo.

@manauref manauref closed this Jan 29, 2026
akashukla and others added 2 commits January 28, 2026 22:30
…sed Fpol = B0*R_axis which is incorrect. It needs to be F_pol=R_axis*B_axis or F_pol = R0*B0. With this correction and a reduction of the error tolerance in the check_parallel function, the miller test finally passes. Updated the 2x d3d iwl test to have the correct mapping and bfield functions
… it consistent with literature and documentation.
…the choice of whether to use R0*B0 or Raxis*Baxis was made in too many places throughout the input files. Change IWL input files so this choice only appears in Bphi, and alpha and dPsidr call Bphi and write fpol=R*Bphi instead.
@manauref
Copy link
Copy Markdown
Collaborator Author

Re-opening:
The shift in twistshift BCs was wrong previously. With the correct shift there are issues due to production of high-k structures, but we need to do additional work to address that. For now, if someone wants to run as before, they can just decrease the shift (e.g. divide it by 2).

@manauref manauref reopened this Feb 25, 2026
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.

3 participants