freegs-plasma / freegs

Free boundary Grad-Shafranov solver
http://freegs.readthedocs.io/en/latest/
GNU Lesser General Public License v3.0
91 stars 53 forks source link

MirroredCoil Incorrectly creating two coils at Z instead of one at Z and -Z #108

Open RoyZhenLongLim opened 7 months ago

RoyZhenLongLim commented 7 months ago

The current code for Mirrored Coil in machine.py is wrong. It creates two coils at Z (instead of one coil at +- Z) The code below fixes the issue (made coil L be at -Z instead of Z)

def MirroredCoil(
    R, Z, current=0.0, turns=1, control=True, area=AreaCurrentLimit(), symmetric=True
):
    """
    Create a pair of coils, at +/- Z
    If symmetric = True then current is in the same direction (in series);
    if symmetric = False then current is in the opposite direction
    """
    return Circuit(
        [
            (
                "U",
                Coil(R, Z, current=current, turns=turns, control=control, area=area),
                1.0,
            ),
            (
                "L",
                Coil(R, -Z, current=current, turns=turns, control=control, area=area),
                1.0 if symmetric else -1.0,
            ),
        ]
    )