Coordinates: Replacing sqrt(g_22) with JB#3027
Coordinates: Replacing sqrt(g_22) with JB#3027bendudson wants to merge 2 commits intorefactor-coordinatesfrom
Conversation
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.
|
Ah, this currently doesn't work because we've not added the overload for |
|
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 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 |
|
We also have some checks that |
Ah yes. I think we should check that all elements of J have the same sign: All positive or all negative. |
dschwoerer
left a comment
There was a problem hiding this comment.
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 ...
|
|
||
| if (!f.hasParallelSlices()) { | ||
| return metric->Bxy() * FDDY(v, f / Bxy_floc, outloc, method) / sqrt(metric->g_22()); | ||
| return FDDY(v, f / Bxy_floc, outloc, method) / metric->J(); |
There was a problem hiding this comment.
Should it really be Bxy_floc? I thought this term comes from the curvi-linear geometry, and thus should be independent of B (for non clebsch)
| f_B.yup() = f.yup() / Bxy_floc; | ||
| f_B.ydown() = f.ydown() / Bxy_floc; | ||
| return metric->Bxy() * FDDY(v, f_B, outloc, method) / sqrt(metric->g_22()); | ||
| return FDDY(v, f_B, outloc, method) / metric->J(); |
| result /= SQ(metric->J()) | ||
| * metric->Bxy(); // J^2 B same sign for left & right handed coordinates |
There was a problem hiding this comment.
move comment above to avoid strange formatting?
| Field3D result = VDDX(vx, A, outloc) + VDDY(vy, A, outloc) + VDDZ(vz, A, outloc); | ||
|
|
||
| result /= (metric->J() * sqrt(metric->g_22())); | ||
| result /= SQ(metric->J()) * metric->Bxy(); // J^2 B |
There was a problem hiding this comment.
Is that not only true for Clebsch?
| BoutReal by = 1. / sqrt(metric->g_22(x, y, z)); | ||
|
|
||
| // Note: by is negative in a left-handed coordinate system | ||
| BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z)); |
There was a problem hiding this comment.
| BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z)); | |
| BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy()(x, y, z)); |
| BoutReal const fluxRight = | ||
| fR * vR * (coord->J(i, j, k) + coord->J(i, j + 1, k)) | ||
| / (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j + 1, k))); | ||
| fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k)); |
There was a problem hiding this comment.
| fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k)); | |
| fR * vR * 2 / (coord->Bxy()(i, j, k) + coord->Bxy()(i, j + 1, k)); |
| BoutReal const fluxLeft = | ||
| fL * vL * (coord->J(i, j, k) + coord->J(i, j - 1, k)) | ||
| / (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j - 1, k))); | ||
| fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k)); |
There was a problem hiding this comment.
| fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k)); | |
| fL * vL * 2 / (coord->Bxy()(i, j, k) + coord->Bxy()(i, j - 1, k)); |
@dschwoerer I agree: The identity |
|
Note: Mesh checks that |
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