Skip to content

Commit dd8701e

Browse files
authored
Merge pull request #127 from freegs-plasma/fix-triangularity
Fix Equilibrium.triangularityLower
2 parents 931a0b9 + 6e24499 commit dd8701e

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

freegs/equilibrium.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ def triangularityUpper(self, npoints=360):
934934
return (R0 - R_P2) / a
935935

936936
def triangularityLower(self, npoints=360):
937-
"""Calculates plasma upper triangularity, delta_u.
937+
"""Calculates plasma lower triangularity, delta_u.
938938
P4 is the point at the lower extent of the plasma.
939939
940940
tri_l = (R0 - R(P4))/a
@@ -945,14 +945,14 @@ def triangularityLower(self, npoints=360):
945945
Rlcfs = np.array([i[0] for i in separatrix])
946946
Zlcfs = np.array([i[1] for i in separatrix])
947947

948-
ind_P2 = np.argmax(Zlcfs)
948+
ind_P4 = np.argmin(Zlcfs)
949949

950-
R_P2 = Rlcfs[ind_P2]
950+
R_P4 = Rlcfs[ind_P4]
951951

952952
R0 = self.Rgeometric(npoints=npoints)
953953
a = self.minorRadius(npoints=npoints)
954954

955-
return (R0 - R_P2) / a
955+
return (R0 - R_P4) / a
956956

957957
def triangularity(self, npoints=360):
958958
"""Calculates plasma triangularity, delta.

freegs/test_optimiser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def test_quadratic():
4848

4949
# Answer should be close to (1,2)
5050
expected_point = np.array((1, 2))
51-
start_distance = np.sqrt(np.sum((expected_point - start_values)**2))
52-
result_distance = np.sqrt(np.sum((expected_point - result)**2))
51+
start_distance = np.sqrt(np.sum((expected_point - start_values) ** 2))
52+
result_distance = np.sqrt(np.sum((expected_point - result) ** 2))
5353
# It should always get _closer_, even if it doesn't get particularly close
5454
assert result_distance < start_distance
5555
assert np.isclose(result_distance, 0, atol=1e-1)

0 commit comments

Comments
 (0)