Repository navigation
FDTD: E_z on the axis of a closed cylinder counted one alpha current twice - #248
Open
MrHighVoltage wants to merge 1 commit into
Open
MrHighVoltage wants to merge 1 commit into
MrHighVoltage wants to merge 1 commit into
Conversation
MrHighVoltage
force-pushed
the
cylinder-axis-currents
branch
from
November 5, 2026 15:29
8646ee2 to
34783ca
Compare
On a closed alpha mesh including r=0, E_z on the axis is updated from the alpha currents on the ring around it. The alpha lines numLines-2 and numLines-1 are copies of the lines 0 and 1 past the seam, but the sum ran up to numLines-2, so the current of line 0 entered twice, while the capacitance of vi_R0 counts every line once. A field odd under a rotation by pi, without E_z on the axis, put 0.26 % (32 alpha cells) to 0.5 % (16) of its source voltage there. The same sum is in the host extension (Engine_Ext_Cylinder::BoxImpl(), which the basic, multithreaded, CPU and gpu-reference engines run) and in the HIP and Metal kernels. python/Tests/Cylindrical_Axis.py checks the axis voltage of such a field with the default engine, or the one of run_testsuite.py --engine; Engine_Compare.py compares every engine with the basic one on a closed mesh including r=0. Generated-by: Claude Opus 5.5 (Claude Code) Signed-off-by: Georg Zachl <it@zachlge.org>
MrHighVoltage
force-pushed
the
cylinder-axis-currents
branch
from
November 9, 2026 22:40
34783ca to
8954284
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a closed cylindrical mesh that includes r=0, the E_z update on the axis adds the alpha current of alpha line 0 twice. Its loop runs over one alpha line too many, and that line is a copy of line 0 past the seam. The capacitance of the same update counts every line once. The loop is in the host extension, which the basic, multithreaded, CPU and gpu-reference engines run, and in the HIP and Metal kernels.
Where it happens (links to master 1d710c2):
A closed alpha mesh gets two extra lines past the seam, in
Operator_Cylinder::SetupCSXGrid()(operator_cylinder.cpp#L524-L526): the last line is set to α0+2π, and a line at α1+2π is added. SonumLines[1]is the number of distinct alpha lines plus 2. For 17 lines from -π to π:Engine_Ext_Cylinder::BoxImpl()closes the seam by copying fields (after the voltage update, after the current update): E_r and E_z of linelast_A_Line=numLines[1]-2go to line 0, and H_r and H_z of line 0 go to linelast_A_Line. H_alpha lies on its alpha line and depends only on E_r and E_z of that line, so linelast_A_Lineholds the same alpha current as line 0.E_z on the axis is updated from the alpha currents on the ring around it (C dV/dt = sum of I_alpha):
pos[1] < GetNumberOfLines(1,true)-2, each line once (operator_ext_cylinder.cpp#L78);pos[1] < numLines[1]-1, which includes linelast_A_Line, that is line 0 a second time (engine_ext_cylinder.cpp#L73). HIP and Metal have the same loop asa < N.ny-1(hip_ext_cylinder.hip#L38, metal_ext_cylinder.mm#L37).The fix is the limit
last_A_Line(N.ny-2in the kernels).Effect:
Test: the new python/Tests/Cylindrical_Axis.py drives two opposite z-directed sources at r=3 mm on a closed 16-cell mesh, and checks that E_z on the axis stays below 1e-5 of the source voltage. Like the other simulation tests, it runs the default engine, or the one of
run_testsuite.py --engine. I ran it on the default (multithreaded), basic, cpu, gpu-reference and HIP (RX 6800) engines: each fails on master (5.1e-3) and passes with the fix (6e-8 to 8e-8). Engine_Compare.py, which compares the engines with basic on a closed mesh including r=0 (cylinder_closed) and on the multi-grid cases, passes with--engine=cpuand--engine=gpu; so do Cylindrical_Cavity.py and the C++ unit tests. Metal has the same one-line change but was not compiled (no Mac).Note for the gpu-cellmodel branch: the branch writes the device extensions once, and
Op_Cylindermode 0 in kernels/ext_ops.h#L186 (fc20a33) copies the loop for the reference, HIP and Metal backends. The HIP and Metal hunks here become:Its Engine_Compare.py compares gpu-reference with the CPU engine bit for bit, so both sides have to change together: with only ext_ops.h fixed,
cylinder_closedfails (et, et_axis, ht); with both, Engine_Compare.py--engine=gpuand Cylindrical_Axis.py on gpu and gpu-reference pass. I have the commit on a local branch on fc20a33.