BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

Coordinates: Replacing sqrt(g_22) with JB

Open bendudson opened this issue 1 year ago • 7 comments

Aiming to consistently handle left-handed coordinate systems, where J is negative. These happen in the standard BOUT++ field-aligned coordinates when the poloidal field is negative.

Implemented on top of refactor-coordinates #2873

bendudson avatar Nov 16 '24 00:11 bendudson

Ah, this currently doesn't work because we've not added the overload for Bxy(x, y, z)

ZedThree avatar Nov 18 '24 15:11 ZedThree

Does this fix things for FCI where JB is not equal to sqrt(g22)? I wanted to discuss this with Ben on Wednesday.

dschwoerer avatar Nov 18 '24 15:11 dschwoerer

Does this fix things for FCI where JB is not equal to sqrt(g22)? I wanted to discuss this with Ben on Wednesday.

Hey @dschwoerer I hope this will help with FCI too: I'm trying to remove all use of sqrt(g_22) from the code, and assumptions that J is positive. B is always positive (as it's the magnitude of B), but J can be positive or negative. In the tokamak case J < 0 when Bp < 0.

I haven't yet looked at the boundary conditions, or how to handle parallel components of vector quantities: When J < 0 it means that the y coordinate is in the opposite direction to B. Hence the 'y' component of a vector v is in the opposite direction to b dot v. It'll take some time to work out the implications for the operators e.g. Grad_par() takes a scalar argument, whereas Div_par() takes a vector component (b dot v).

bendudson avatar Nov 18 '24 21:11 bendudson

We also have some checks that J is positive that I guess need to be loosened?

ZedThree avatar Nov 20 '24 14:11 ZedThree

We also have some checks that J is positive that I guess need to be loosened?

Ah yes. I think we should check that all elements of J have the same sign: All positive or all negative.

bendudson avatar Nov 20 '24 16:11 bendudson

It seems some of the cases are (still) only valid for Clebsch. I have not looked in too much detail, so if you disagree I can look in more detail ...

@dschwoerer I agree: The identity sqrt(g_22) = JB is only for Clebsch coordinates. In general how should the 'parallel' direction be defined? Perhaps we use sign(J) * sqrt(g_22) as the parallel metric, which would be consistent with the Clebsch case but I think more general. That would mean that if J > 0 then b is in the same direction as e_y, but if J < 0 then they are in opposite directions.

bendudson avatar Nov 21 '24 16:11 bendudson

Note: Mesh checks that J > 0. Change to check that J has the same sign (+ or -) in all cells.

bendudson avatar Jan 29 '25 20:01 bendudson