diff --git a/CHANGELOG.md b/CHANGELOG.md index d957533bbb..9995d53d3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Performance Improvements Bug Fixes - Fixes bug in ``auglag`` optimizers which prevented them from accepting solver hyperparameters. +- Adjusts the `quad_weights` of coil objectives of type `_broadcast_input = "node"` to ensure their outputs are roughly independent of grid resolution. - Fixes bug in modified Cholesky factorization used by the trust-region subproblems when the Gershgorin lower bound of the Hessian was exactly zero (e.g. a Hessian with an all-zero row), producing NaN steps in ``fmintr`` and diff --git a/desc/objectives/_coils.py b/desc/objectives/_coils.py index eaafe93a65..5e5d566984 100644 --- a/desc/objectives/_coils.py +++ b/desc/objectives/_coils.py @@ -220,9 +220,11 @@ def expand(t, idx=0): ) _build_coilset_tree() - quad_weights = np.concatenate([g.spacing[:, 2] for g in grid])[ - self._coilset_tree["objective_mask"] - ] + quad_weights = np.sqrt( + np.concatenate([g.spacing[:, 2] for g in grid])[ + self._coilset_tree["objective_mask"] + ] + ) if self._broadcast_input.lower() == "node": grid_nodes_unmasked = [ diff --git a/docs/notebooks/tutorials/coil_stage_two_optimization.ipynb b/docs/notebooks/tutorials/coil_stage_two_optimization.ipynb index 26d15d0afb..44730962bf 100644 --- a/docs/notebooks/tutorials/coil_stage_two_optimization.ipynb +++ b/docs/notebooks/tutorials/coil_stage_two_optimization.ipynb @@ -15,7 +15,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -28,7 +28,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": { "tags": [] }, @@ -49,7 +49,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": {}, "outputs": [], "source": [ @@ -62,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "ExecuteTime": { "end_time": "2025-12-14T22:50:12.851411Z", @@ -75,9 +75,9 @@ "name": "stdout", "output_type": "stream", "text": [ - "DESC version=0.16.0+72.g14d4554c4.dirty.\n", - "Using JAX backend: jax version=0.6.2, jaxlib version=0.6.2, dtype=float64.\n", - "Using device: NVIDIA GeForce RTX 4080 Laptop GPU (id=0), with 11.60 GB available memory.\n" + "DESC version=0.17.3+10.g8b5a93604.dirty.\n", + "Using JAX backend: jax version=0.9.2, jaxlib version=0.9.2, dtype=float64.\n", + "Using device: CPU, with 11.45 GB available memory.\n" ] } ], @@ -147,7 +147,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2025-12-14T22:50:23.090375Z", @@ -214,7 +214,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2025-12-14T22:50:26.030722Z", @@ -238,7 +238,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2025-12-14T22:50:31.719399Z", @@ -247,30 +247,16 @@ "tags": [] }, "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/CODES/DESC/desc/utils.py:572: UserWarning:\n", - "\n", - "Unequal number of field periods for grid 1 and basis 2.\n", - "\n", - "/CODES/DESC/desc/utils.py:572: UserWarning:\n", - "\n", - "Unequal number of field periods for grid 1 and basis 2.\n", - "\n" - ] - }, { "data": { "text/html": [ - " \n", "