From ba5288c5b8c278c3fa88981bad7a4a89ba7a0293 Mon Sep 17 00:00:00 2001 From: Ben Dudson Date: Wed, 16 Apr 2025 11:46:47 -0700 Subject: [PATCH 1/2] Fix Equilibrium.triangularityLower Was performing the same calculation as triangularityUpper. Thanks to Jeremy Lore for spotting! --- freegs/equilibrium.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/freegs/equilibrium.py b/freegs/equilibrium.py index 2584470..3159761 100644 --- a/freegs/equilibrium.py +++ b/freegs/equilibrium.py @@ -934,7 +934,7 @@ def triangularityUpper(self, npoints=360): return (R0 - R_P2) / a def triangularityLower(self, npoints=360): - """Calculates plasma upper triangularity, delta_u. + """Calculates plasma lower triangularity, delta_u. P4 is the point at the lower extent of the plasma. tri_l = (R0 - R(P4))/a @@ -945,14 +945,14 @@ def triangularityLower(self, npoints=360): Rlcfs = np.array([i[0] for i in separatrix]) Zlcfs = np.array([i[1] for i in separatrix]) - ind_P2 = np.argmax(Zlcfs) + ind_P4 = np.argmin(Zlcfs) - R_P2 = Rlcfs[ind_P2] + R_P4 = Rlcfs[ind_P4] R0 = self.Rgeometric(npoints=npoints) a = self.minorRadius(npoints=npoints) - return (R0 - R_P2) / a + return (R0 - R_P4) / a def triangularity(self, npoints=360): """Calculates plasma triangularity, delta. From 6e2449968b3651450bb2120b6891a85aa9484a4e Mon Sep 17 00:00:00 2001 From: Ben Dudson Date: Wed, 16 Apr 2025 11:53:57 -0700 Subject: [PATCH 2/2] test_optimiser: Remove unused global axis Failing flake8 test due to unused global variable. --- freegs/test_optimiser.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/freegs/test_optimiser.py b/freegs/test_optimiser.py index 3fd60d6..14fb0b8 100644 --- a/freegs/test_optimiser.py +++ b/freegs/test_optimiser.py @@ -48,8 +48,8 @@ def test_quadratic(): # Answer should be close to (1,2) expected_point = np.array((1, 2)) - start_distance = np.sqrt(np.sum((expected_point - start_values)**2)) - result_distance = np.sqrt(np.sum((expected_point - result)**2)) + start_distance = np.sqrt(np.sum((expected_point - start_values) ** 2)) + result_distance = np.sqrt(np.sum((expected_point - result) ** 2)) # It should always get _closer_, even if it doesn't get particularly close assert result_distance < start_distance assert np.isclose(result_distance, 0, atol=1e-1) @@ -130,7 +130,6 @@ def test_pick_excludes(): def monitor(generation, best, pop): global best_point global pop_points - global axis # Change the color of the previous points # to grey and light red