Skip to content
16 changes: 14 additions & 2 deletions freegs4e/critical.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,11 @@ def scan_for_crit(R, Z, psi):
) # + 0.5*(fRR*delta_R**2 + fZZ*delta_Z**2 + fRZ*delta_R*delta_Z)
crpoint = (R0 + delta_R, Z0 + delta_Z, est_psi)
if det > 0.0:
opoint = [crpoint] + opoint
# opoint = [crpoint] + opoint
opoint.append(crpoint)
else:
xpoint = [crpoint] + xpoint
# xpoint = [crpoint] + xpoint
xpoint.append(crpoint)

xpoint = np.array(xpoint)
opoint = np.array(opoint)
Expand Down Expand Up @@ -859,6 +861,16 @@ def inside_mask(
if use_geom:
# cure flooding
mask = mask * geom_inside_mask(R, Z, opoint, xpoint)
# apply geometric masking criterion to second Xpoint if close to double null
if len(xpoint > 1):
if (
np.abs(
(xpoint[0, 2] - xpoint[1, 2])
/ (opoint[0, 2] - xpoint[0, 2])
)
< 0.1
):
mask = mask * geom_inside_mask(R, Z, opoint, xpoint[1:])
return mask


Expand Down
4 changes: 2 additions & 2 deletions freegs4e/equilibrium.py
Original file line number Diff line number Diff line change
Expand Up @@ -2272,7 +2272,7 @@ def normalised_total_Beta(self):
"""
Calculates the total beta from the following definition:

normalised_total_Beta = ( (1 / poloidalBeta2) + (1/toroidalBeta) )^(-1).
normalised_total_Beta = ( (1 / poloidalBeta1) + (1/toroidalBeta1) )^(-1).

Parameters
----------
Expand All @@ -2285,7 +2285,7 @@ def normalised_total_Beta(self):
"""

return 1.0 / (
(1.0 / self.poloidalBeta()) + (1.0 / self.toroidalBeta())
(1.0 / self.poloidalBeta1()) + (1.0 / self.toroidalBeta1())
)

def strikepoints(
Expand Down
2 changes: 2 additions & 0 deletions freegs4e/jtor.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ def Jtor_part2(self, R, Z, psi, psi_axis, psi_bndry, mask):
IR = (
np.sum(jtorshape * R / self.Raxis) * dR * dZ
) # romb(romb(jtorshape * R / self.Raxis)) * dR * dZ
if IR == 0:
raise ValueError("No core mask!")
I_R = (
np.sum(jtorshape * self.Raxis / R) * dR * dZ
) # romb(romb(jtorshape * self.Raxis / R)) * dR * dZ
Expand Down