DESC
DESC copied to clipboard
Adding a piecewise omnigenity objective
This PR add the piecewise omnigenity objective as described by Velasco during the Simons meeting.
This will allows us to do much faster an memory efficient optimizations while maintaining approximate omnigenity and maybe use reverse-mode differentiation.
The expression for the magnetic field is given in a screenshot of Velasco's Simons slide.
resolves #949
| benchmark_name | dt(%) | dt(s) | t_new(s) | t_old(s) |
| -------------------------------------- | ---------------------- | ---------------------- | ---------------------- | ---------------------- |
test_build_transform_fft_lowres | +8.15 +/- 6.20 | +4.30e-02 +/- 3.27e-02 | 5.71e-01 +/- 3.1e-02 | 5.28e-01 +/- 1.1e-02 |
test_equilibrium_init_medres | +6.28 +/- 9.77 | +2.43e-01 +/- 3.78e-01 | 4.11e+00 +/- 3.4e-01 | 3.87e+00 +/- 1.7e-01 |
test_equilibrium_init_highres | +0.78 +/- 5.99 | +3.89e-02 +/- 2.98e-01 | 5.01e+00 +/- 2.6e-01 | 4.97e+00 +/- 1.5e-01 |
test_objective_compile_dshape_current | +0.76 +/- 7.63 | +2.35e-02 +/- 2.36e-01 | 3.12e+00 +/- 2.0e-01 | 3.10e+00 +/- 1.3e-01 |
test_objective_compute_dshape_current | +2.82 +/- 2.30 | +9.96e-05 +/- 8.11e-05 | 3.63e-03 +/- 6.9e-05 | 3.53e-03 +/- 4.3e-05 |
test_objective_jac_dshape_current | +2.12 +/- 5.95 | +8.27e-04 +/- 2.32e-03 | 3.99e-02 +/- 1.5e-03 | 3.90e-02 +/- 1.7e-03 |
test_perturb_2 | +4.00 +/- 3.75 | +6.01e-01 +/- 5.62e-01 | 1.56e+01 +/- 4.7e-01 | 1.50e+01 +/- 3.1e-01 |
test_proximal_jac_atf_with_eq_update | +0.87 +/- 1.51 | +1.50e-01 +/- 2.61e-01 | 1.74e+01 +/- 2.0e-01 | 1.73e+01 +/- 1.7e-01 |
test_proximal_freeb_jac | +0.75 +/- 1.16 | +4.36e-02 +/- 6.76e-02 | 5.87e+00 +/- 5.5e-02 | 5.82e+00 +/- 3.9e-02 |
test_solve_fixed_iter_compiled | +0.42 +/- 3.19 | +7.68e-02 +/- 5.81e-01 | 1.83e+01 +/- 3.4e-01 | 1.82e+01 +/- 4.7e-01 |
test_LinearConstraintProjection_build | -5.41 +/- 3.62 | -4.67e-01 +/- 3.13e-01 | 8.18e+00 +/- 1.7e-01 | 8.64e+00 +/- 2.6e-01 |
test_objective_compute_ripple_spline | -2.49 +/- 5.29 | -8.09e-03 +/- 1.71e-02 | 3.16e-01 +/- 1.3e-02 | 3.24e-01 +/- 1.2e-02 |
test_objective_grad_ripple_spline | -2.28 +/- 2.88 | -3.39e-02 +/- 4.28e-02 | 1.45e+00 +/- 1.9e-02 | 1.48e+00 +/- 3.8e-02 |
test_build_transform_fft_midres | +0.43 +/- 2.77 | +2.39e-03 +/- 1.52e-02 | 5.52e-01 +/- 1.1e-02 | 5.49e-01 +/- 1.0e-02 |
test_build_transform_fft_highres | +0.03 +/- 3.48 | +2.86e-04 +/- 2.90e-02 | 8.33e-01 +/- 2.8e-02 | 8.33e-01 +/- 6.1e-03 |
test_equilibrium_init_lowres | +0.66 +/- 1.62 | +2.36e-02 +/- 5.79e-02 | 3.61e+00 +/- 4.3e-02 | 3.58e+00 +/- 3.9e-02 |
test_objective_compile_atf | -0.08 +/- 2.45 | -5.18e-03 +/- 1.51e-01 | 6.16e+00 +/- 5.6e-02 | 6.16e+00 +/- 1.4e-01 |
test_objective_compute_atf | +1.48 +/- 2.87 | +1.34e-04 +/- 2.60e-04 | 9.19e-03 +/- 1.9e-04 | 9.05e-03 +/- 1.8e-04 |
test_objective_jac_atf | +0.36 +/- 2.26 | +6.64e-03 +/- 4.10e-02 | 1.83e+00 +/- 2.8e-02 | 1.82e+00 +/- 3.0e-02 |
test_perturb_1 | +1.03 +/- 1.28 | +1.25e-01 +/- 1.55e-01 | 1.23e+01 +/- 1.4e-01 | 1.21e+01 +/- 7.5e-02 |
test_proximal_jac_atf | +0.01 +/- 1.00 | +4.88e-04 +/- 7.93e-02 | 7.95e+00 +/- 4.9e-02 | 7.95e+00 +/- 6.2e-02 |
test_proximal_freeb_compute | +2.46 +/- 3.86 | +3.93e-03 +/- 6.17e-03 | 1.64e-01 +/- 4.8e-03 | 1.60e-01 +/- 3.9e-03 |
test_solve_fixed_iter | +2.36 +/- 2.81 | +6.49e-01 +/- 7.72e-01 | 2.82e+01 +/- 4.8e-01 | 2.75e+01 +/- 6.1e-01 |
test_objective_compute_ripple | -0.25 +/- 1.23 | -6.95e-03 +/- 3.46e-02 | 2.81e+00 +/- 1.6e-02 | 2.82e+00 +/- 3.1e-02 |
test_objective_grad_ripple | -0.07 +/- 1.26 | -5.38e-03 +/- 9.22e-02 | 7.33e+00 +/- 5.4e-02 | 7.34e+00 +/- 7.5e-02 |
When I try to import the PiecewiseOmnigenity objective, I get the following error:
DESC version 0.11.1+555.g6474d1e7b,using JAX backend, jax version=0.4.24, jaxlib version=0.4.24, dtype=float64
Using device: CPU, with 23.07 GB available memory
Traceback (most recent call last):
File "/home/rgaur/pwO_import_test.py", line 2, in <module>
from desc.objectives import PiecewiseOmnigenity
File "/home/rgaur/DESC/desc/objectives/__init__.py", line 3, in <module>
from ._bootstrap import BootstrapRedlConsistency
File "/home/rgaur/DESC/desc/objectives/_bootstrap.py", line 6, in <module>
from desc.compute import get_profiles, get_transforms
File "/home/rgaur/DESC/desc/compute/__init__.py", line 31, in <module>
from . import (
File "/home/rgaur/DESC/desc/compute/_omnigenity.py", line 507, in <module>
def _B_piecewise_omni(params, transforms, profiles, data, **kwargs):
File "/home/rgaur/DESC/desc/compute/data_index.py", line 170, in _decorator
raise ValueError(
ValueError: Can't register function with unknown parameterization: desc.magnetic_fields._core.PiecewiseOmnigenousField
When I try to import the PiecewiseOmnigenity objective, I get the following error:
DESC version 0.11.1+555.g6474d1e7b,using JAX backend, jax version=0.4.24, jaxlib version=0.4.24, dtype=float64 Using device: CPU, with 23.07 GB available memory Traceback (most recent call last): File "/home/rgaur/pwO_import_test.py", line 2, in <module> from desc.objectives import PiecewiseOmnigenity File "/home/rgaur/DESC/desc/objectives/__init__.py", line 3, in <module> from ._bootstrap import BootstrapRedlConsistency File "/home/rgaur/DESC/desc/objectives/_bootstrap.py", line 6, in <module> from desc.compute import get_profiles, get_transforms File "/home/rgaur/DESC/desc/compute/__init__.py", line 31, in <module> from . import ( File "/home/rgaur/DESC/desc/compute/_omnigenity.py", line 507, in <module> def _B_piecewise_omni(params, transforms, profiles, data, **kwargs): File "/home/rgaur/DESC/desc/compute/data_index.py", line 170, in _decorator raise ValueError( ValueError: Can't register function with unknown parameterization: desc.magnetic_fields._core.PiecewiseOmnigenousField
You need to add the new class to desc.compute.data_index._class_inheritance
Check out this pull request on ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB