Skip to content

Bug Report: Incorrect Calculation of Lower Triangularity in triangularityLower() #128

@renyihui18

Description

@renyihui18

Hi,

I’ve found a bug in the triangularityLower() method when installing FreeGS via pip install --user freegs.

The triangularityLower() method in Equilibrium class currently calculates the upper triangularity instead of the lower triangularity due to using the same code with triangularityUpper().

This is the code from the installed freegs package :

    def triangularityLower(self, npoints=360):
        """Calculates plasma upper triangularity, delta_u.
        P4 is the point at the lower extent of the plasma.

        tri_l = (R0 - R(P4))/a
        """

        # Get points along the LCFS
        separatrix = self.separatrix(npoints=npoints)  # Array [:,2]
        Rlcfs = np.array([i[0] for i in separatrix])
        Zlcfs = np.array([i[1] for i in separatrix])

        ind_P2 = np.argmax(Zlcfs)

        R_P2 = Rlcfs[ind_P2]

        R0 = self.Rgeometric(npoints=npoints)
        a = self.minorRadius(npoints=npoints)

        return (R0 - R_P2) / a

This is the correct implementation (the code on GitHub is correct):

def triangularityLower(self, npoints=360):
        """Calculates plasma lower triangularity, delta_u.
        P4 is the point at the lower extent of the plasma.

        tri_l = (R0 - R(P4))/a
        """

        # Get points along the LCFS
        separatrix = self.separatrix(npoints=npoints)  # Array [:,2]
        Rlcfs = np.array([i[0] for i in separatrix])
        Zlcfs = np.array([i[1] for i in separatrix])

        ind_P4 = np.argmin(Zlcfs)

        R_P4 = Rlcfs[ind_P4]

        R0 = self.Rgeometric(npoints=npoints)
        a = self.minorRadius(npoints=npoints)

        return (R0 - R_P4) / a

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions