From debd62a761325e2b373d6f44efd6e73bb3473fe2 Mon Sep 17 00:00:00 2001 From: kianorr Date: Tue, 23 Jul 2024 16:16:57 -0400 Subject: [PATCH 1/8] add error --- desc/objectives/_coils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/desc/objectives/_coils.py b/desc/objectives/_coils.py index ea5a287f31..cf99d8a38e 100644 --- a/desc/objectives/_coils.py +++ b/desc/objectives/_coils.py @@ -124,6 +124,11 @@ def _prune_coilset_tree(coilset): # get individual coils from coilset coils, structure = tree_flatten(coil, is_leaf=_is_single_coil) + errorif( + not all([isinstance(c, _Coil) for c in coils]), + ValueError, + "CoilSet must contain only Coil objects.", + ) self._num_coils = len(coils) # map grid to list of length coils From 31e3014c800d05747f40735df0180a35a9e4bf3e Mon Sep 17 00:00:00 2001 From: kianorr Date: Fri, 16 Aug 2024 15:56:50 -0700 Subject: [PATCH 2/8] add rorys suggestion --- .vscode/settings.json | 22 ++++++++++++++++++++++ desc/objectives/_coils.py | 11 ++++++----- 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..e5d6a73080 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,22 @@ +{ + "workbench.colorCustomizations": { + "activityBar.activeBackground": "#15c8f8", + "activityBar.background": "#15c8f8", + "activityBar.foreground": "#15202b", + "activityBar.inactiveForeground": "#15202b99", + "activityBarBadge.background": "#d906ac", + "activityBarBadge.foreground": "#e7e7e7", + "commandCenter.border": "#e7e7e799", + "sash.hoverBorder": "#15c8f8", + "statusBar.background": "#06a8d4", + "statusBar.foreground": "#e7e7e7", + "statusBarItem.hoverBackground": "#15c8f8", + "statusBarItem.remoteBackground": "#06a8d4", + "statusBarItem.remoteForeground": "#e7e7e7", + "titleBar.activeBackground": "#06a8d4", + "titleBar.activeForeground": "#e7e7e7", + "titleBar.inactiveBackground": "#06a8d499", + "titleBar.inactiveForeground": "#e7e7e799" + }, + "peacock.color": "#06a8d4" +} diff --git a/desc/objectives/_coils.py b/desc/objectives/_coils.py index cf99d8a38e..a85bb7e092 100644 --- a/desc/objectives/_coils.py +++ b/desc/objectives/_coils.py @@ -124,11 +124,12 @@ def _prune_coilset_tree(coilset): # get individual coils from coilset coils, structure = tree_flatten(coil, is_leaf=_is_single_coil) - errorif( - not all([isinstance(c, _Coil) for c in coils]), - ValueError, - "CoilSet must contain only Coil objects.", - ) + for coil in coils: + errorif( + not isinstance(coil, _Coil), + TypeError, + f"Expected object of type Coil, got {type(coil)}", + ) self._num_coils = len(coils) # map grid to list of length coils From aa44be82a5074d5b06ca270deba16d0eedefd060 Mon Sep 17 00:00:00 2001 From: kianorr Date: Mon, 19 Aug 2024 13:55:48 -0700 Subject: [PATCH 3/8] remove file I added on accident --- .vscode/settings.json | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index e5d6a73080..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "workbench.colorCustomizations": { - "activityBar.activeBackground": "#15c8f8", - "activityBar.background": "#15c8f8", - "activityBar.foreground": "#15202b", - "activityBar.inactiveForeground": "#15202b99", - "activityBarBadge.background": "#d906ac", - "activityBarBadge.foreground": "#e7e7e7", - "commandCenter.border": "#e7e7e799", - "sash.hoverBorder": "#15c8f8", - "statusBar.background": "#06a8d4", - "statusBar.foreground": "#e7e7e7", - "statusBarItem.hoverBackground": "#15c8f8", - "statusBarItem.remoteBackground": "#06a8d4", - "statusBarItem.remoteForeground": "#e7e7e7", - "titleBar.activeBackground": "#06a8d4", - "titleBar.activeForeground": "#e7e7e7", - "titleBar.inactiveBackground": "#06a8d499", - "titleBar.inactiveForeground": "#e7e7e799" - }, - "peacock.color": "#06a8d4" -} From fecbf9bc61effddf306371f890e3eea83519f121 Mon Sep 17 00:00:00 2001 From: kianorr Date: Mon, 19 Aug 2024 14:13:40 -0700 Subject: [PATCH 4/8] rename coil to c --- desc/objectives/_coils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/desc/objectives/_coils.py b/desc/objectives/_coils.py index 5207e13803..ad22f52810 100644 --- a/desc/objectives/_coils.py +++ b/desc/objectives/_coils.py @@ -124,11 +124,11 @@ def _prune_coilset_tree(coilset): # get individual coils from coilset coils, structure = tree_flatten(coil, is_leaf=_is_single_coil) - for coil in coils: + for c in coils: errorif( - not isinstance(coil, _Coil), + not isinstance(c, _Coil), TypeError, - f"Expected object of type Coil, got {type(coil)}", + f"Expected object of type Coil, got {type(c)}", ) self._num_coils = len(coils) From 0950263d8b2cde55db75d8544762c3924ed9e619 Mon Sep 17 00:00:00 2001 From: kianorr Date: Tue, 20 Aug 2024 15:30:23 -0700 Subject: [PATCH 5/8] add test --- tests/test_objective_funs.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_objective_funs.py b/tests/test_objective_funs.py index d6f67a5ffc..3fd5f68739 100644 --- a/tests/test_objective_funs.py +++ b/tests/test_objective_funs.py @@ -24,7 +24,7 @@ from desc.compute import get_transforms from desc.equilibrium import Equilibrium from desc.examples import get -from desc.geometry import FourierRZToroidalSurface, FourierXYZCurve +from desc.geometry import FourierPlanarCurve, FourierRZToroidalSurface, FourierXYZCurve from desc.grid import ConcentricGrid, LinearGrid, QuadratureGrid from desc.io import load from desc.magnetic_fields import ( @@ -865,6 +865,13 @@ def test(coil, grid=None): test(mixed_coils) test(nested_coils, grid=grid) + def test_coil_type_error(self, DummyCoilSet): + """Tests error when objective is not passed a coil.""" + curve = FourierPlanarCurve(r_n=2, basis="rpz") + obj = CoilLength(curve) + with pytest.raises(TypeError): + obj.build() + @pytest.mark.unit def test_coil_min_distance(self): """Tests minimum distance between coils in a coilset.""" From f1d4122438cf516b46409e1c3a0c346eb67c28c7 Mon Sep 17 00:00:00 2001 From: kianorr Date: Tue, 20 Aug 2024 15:32:13 -0700 Subject: [PATCH 6/8] delete unused coils --- tests/test_objective_funs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_objective_funs.py b/tests/test_objective_funs.py index 3fd5f68739..df3e8e9c79 100644 --- a/tests/test_objective_funs.py +++ b/tests/test_objective_funs.py @@ -865,7 +865,7 @@ def test(coil, grid=None): test(mixed_coils) test(nested_coils, grid=grid) - def test_coil_type_error(self, DummyCoilSet): + def test_coil_type_error(self): """Tests error when objective is not passed a coil.""" curve = FourierPlanarCurve(r_n=2, basis="rpz") obj = CoilLength(curve) From c7837ae3a2ad63433cfda2e08e183dc35ad178dd Mon Sep 17 00:00:00 2001 From: YigitElma Date: Wed, 28 Aug 2024 14:17:19 -0400 Subject: [PATCH 7/8] fix _print_value_fmt for some objectives --- desc/objectives/_equilibrium.py | 2 +- desc/objectives/_power_balance.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/desc/objectives/_equilibrium.py b/desc/objectives/_equilibrium.py index 624fd99023..dc2f4bbb22 100644 --- a/desc/objectives/_equilibrium.py +++ b/desc/objectives/_equilibrium.py @@ -557,7 +557,7 @@ class HelicalForceBalance(_Objective): _equilibrium = True _coordinates = "rtz" _units = "(N)" - _print_value_fmt = "Helical force error: {:10.3e}, " + _print_value_fmt = "Helical force error: " def __init__( self, diff --git a/desc/objectives/_power_balance.py b/desc/objectives/_power_balance.py index 74b679ee2a..299b248358 100644 --- a/desc/objectives/_power_balance.py +++ b/desc/objectives/_power_balance.py @@ -61,7 +61,7 @@ class FusionPower(_Objective): _scalar = True _units = "(W)" - _print_value_fmt = "Fusion power: {:10.3e} " + _print_value_fmt = "Fusion power: " def __init__( self, @@ -246,7 +246,7 @@ class HeatingPowerISS04(_Objective): _scalar = True _units = "(W)" - _print_value_fmt = "Heating power: {:10.3e} " + _print_value_fmt = "Heating power: " def __init__( self, From b348886241086edb7d71bccec534cb472a39eadc Mon Sep 17 00:00:00 2001 From: unalmis Date: Wed, 28 Aug 2024 14:50:06 -0400 Subject: [PATCH 8/8] Fix latex labels of F_anisotropic, B_phi|r,t and Bat axis --- desc/compute/_equil.py | 2 +- desc/compute/_field.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/desc/compute/_equil.py b/desc/compute/_equil.py index 44975de7ac..93b2c5232b 100644 --- a/desc/compute/_equil.py +++ b/desc/compute/_equil.py @@ -625,7 +625,7 @@ def _e_sup_helical_times_sqrt_g_mag(params, transforms, profiles, data, **kwargs @register_compute_fun( name="F_anisotropic", - label="F_{anisotropic}", + label="F_{\\mathrm{anisotropic}}", units="N \\cdot m^{-3}", units_long="Newtons / cubic meter", description="Anisotropic force balance error", diff --git a/desc/compute/_field.py b/desc/compute/_field.py index 1ca0adb1fb..37732b1cdf 100644 --- a/desc/compute/_field.py +++ b/desc/compute/_field.py @@ -1644,7 +1644,7 @@ def _B_sub_zeta(params, transforms, profiles, data, **kwargs): @register_compute_fun( name="B_phi|r,t", - label="B_{\\phi} = B \\dot \\mathbf{e}_{\\phi} |_{\\rho, \\theta}", + label="B_{\\phi} = B \\cdot \\mathbf{e}_{\\phi} |_{\\rho, \\theta}", units="T \\cdot m", units_long="Tesla * meters", description="Covariant toroidal component of magnetic field in (ρ,θ,ϕ) " @@ -2269,7 +2269,7 @@ def _B_sub_zeta_rz(params, transforms, profiles, data, **kwargs): @register_compute_fun( name="<|B|>_axis", - label="\\lange |\\mathbf{B}| \\rangle_{axis}", + label="\\langle |\\mathbf{B}| \\rangle_{axis}", units="T", units_long="Tesla", description="Average magnitude of magnetic field on the magnetic axis",