Releases: PlasmaControl/DESC
v0.17.2
New Features
- Adds
desc.objectives.DeflationOperator, a new objective class which can be used to apply deflation techniques to equilibrium and optimization problems to find multiple local minima or multiple solutions from a single initial point, either by wrapping an existingdesc.objectives._Objectiveobject or by including as an additional penalty or constraint. Also adds a tutorial showing this functionality. - Sub-objectives of an
ObjectiveFunctioncan now have differentuse_jitvalues than theObjectiveFunction. These objectives have to be built before building theObjectiveFunction. - Adds
num_neighborsparameter toCoilSetMinDistancethat limits the pairwise distance computation to the nearest neighbors per coil, reducing memory useage for large coilsets. - Method to plot frequency spectrum of inverse stream map in field line coordinates
Bounce2D.plot_angle_spectrum. - Method to compute bounce integrals in batches is now added to the public API
Bounce2D.batch. - Initiated deprecation of
Bounce2D.compute_fieldline_lengthin favor ofeq.compute("V_psi"). - The quadrature resolution in
Bounce2D.compute_fieldline_lengthnow corresponds to the resolution over a single field period instead of the resolution over a toroidal transit. - Adds an optional attribute
ion_densityto theEquilibriumclass, to allow the ion density profile to be set independently of the electron density and effective atomic number. Also adds compute functions for"ni_rr"and"Zeff_rr". - Modernizes dependencies to use
nvidia-ml-pyin place ofnvgpu.
Important
If you are updating an existing software environment uninstall pynvml first and then reinstall the dependencies to correctly get nvidia-ml-py.
Bug Fixes
- Fixes SyntaxError thrown when loading hdf5 data from file-like objects.
- Fixes a bug in
OmnigenousField.change_resolutionwhen changingL_B. - Scaling a
ScaledProfileor taking power of aPowerProfilenow only updates thescale/powerattributes instead of nesting theScaledProfile/PowerProfiles. jax.Arrays in_static_attrswill be automatically converted tonp.ndarrayto prevent stalling code. In general, jax arrays should be omitted in_static_attrs.- Fixes a bug in
desc.magnetic_fields.fieldline_integratewhen calling with an integerbs_chunk_size.
Performance Improvements
- Reduces import time of
descmodules.- Now,
desc.compute._build_data_indexuses depth-first search algorithm to construct the dependency tree. - Some of the default value computations at import time are removed (i.e.
desc.integrals.bounce_integral.default_quad)
- Now,
- Significantly improves convergence of inverse stream maps (#1919).
- Check-pointing to bounce integrals to improve speed and reduce memory of reverse mode differentiation.
- Resolves a JAX memory regression in bounce integrals by avoiding materialization of a large tensor in memory. Previously, we had closed the issue by adding nuffts as a workaround. This update actually solves the issue for the case when a user specifies to not use nuffts as well.
ObjectiveFunction.print_valuecan now use the previously computedcompute_scaled_errorvalues to print. For bounded objectives, we fall back to computingcompute_unscaled. Additionally,compute_scaled_errorand array splitting are used in other parts of the code to prevent recompilation for one-time tasks, which makes initialization faster.
Deprecations
constantsargument ofcompute,jvp,jac,gradandhessmethods (including all of their variants) to all objective classes (includingObjectiveFunctionand wrappers) is deprecated and will be removed in a future release. This argument was not necessary, and the code will still work if user doesn't pass it. Users should update their custom objectives for this change. In addition,constantsproperty of theObjectiveFunctionand all sub-classes of_Objectiveis deprecated.
New Contributors
- @andycthea made their first contribution in #2123
- @TElder-thea made their first contribution in #2140
- @matthewfeickert made their first contribution in #2163
Full Changelog: v0.17.1...v0.17.2
v0.17.1
This patch release updates package dependencies to resolve critical incompatibilities between jax-related libraries. DESC versions 0.16.0 and 0.17.0 contain a known bug when used alongside jax-finufft v1.3.0, and we recommend that users upgrade to DESC version 0.17.1 to ensure environment stability.
If an immediate upgrade is not feasible, the issue can be mitigated by manually downgrading jax-finufft to version 1.2.0.
Minor Changes
- Fixes incorrect units in the documentation of some curvature variables.
Full Changelog: v0.17.0...v0.17.1
v0.17.0
New Features
- Adds particle tracing capabilities in
desc.particlesmodule.- Particle tracing is done via
desc.particles.trace_particlesfunction. - Particles can be initialized in couple different ways:
ManualParticleInitializerLab: Initializes particles at given positions in lab coordinates.ManualParticleInitializerFlux: Initializes particles at given positions in flux coordinates.CurveParticleInitializer: Initializes N particles on a given curve.SurfaceParticleInitializer: Initializes N particles on a given surface.
- Implemented particle trajectory models are:
VacuumGuidingCenterTrajectory: Integrates the particle motion by vacuum guiding center ODEs, conserving energy and mu.
- Particle trajectories can be plotted with
desc.plotting.plot_particle_trajectoriesfunction.
- Particle tracing is done via
- Adds new option for
loss_function,"sum", which changes an objective to target the sum of the values computed. - Adds utility functions
desc.external.paraview.export_surface_to_paraview,desc.external.paraview.export_volume_to_paraviewanddesc.external.paraview.export_coils_to_paraviewto export Paraview files for surfaces, volume and coils. These functions use an optional dependencypyvistawhich is not automatically installed. - The
x_scaleoption foreq.optimizeand related functions can now be given as a dictionary mapping individual parameter names to their relevant scales,
or if multiple things are being optimized,x_scalecan be a list of dict, one for each optimizable thing. - Adds new option
x_scale='ess'to use exponential spectral scaling from (Jang 2025) which has been shown to improve performance and robustness as an alternative to fourier continuation methods. - Adds
x_scale='ess'option for theOmigenousFieldclass. - Adds
"scipy-l-bfgs-b"optimizer option as a wrapper to scipy's"l-bfgs-b"method. - The
x_scaleparameter can now be used with stochastic gradient descent type optimizers. - Adds wrappers for
optaxoptimizers. They can be used by prepending'optax-'to the name of the optimizer (i.e.optax-adam). Additional arguments to the optimizer such aslearning_ratecan be pass viaoptions = {'optax-options': {'learning_rate': 0.01}}. Even a customoptaxoptimizer can be used by specifying the method as'optax-custom'and passing theoptaxoptimizer via the'update-rule'key ofoptax-optionsin theoptionsdictionary. See the docstring of theoptax-customfor details. - Adds
check_intersectionflag todesc.magnetic_fields.FourierCurrentPotentialField.to_Coilset, to allow the choice of checking the resulting coilset for intersections or not. - Changes the import paths for
desc.externalto require reference to the sub-modules. - Adds a differentiable utility for finding constant offset toroidal surfaces inside of optimizations. See PR for more details.
- Add support for Python 3.14
- Adds support for optimization targeting individual coils in a coilset.
- Coil objectives accept pytree inputs for
target,bounds, andweight. - Able to set weights to zero, excluding certain coils from the objective.
- Coil objectives accept pytree inputs for
Bug Fixes
- No longer uses the full Hessian to compute the scale when
x_scale="auto"and using a scipy optimizer that approximates the hessian (e.g. if using"scipy-bfgs", no longer attempts the Hessian computation to get the x_scale). SplineMagneticField.from_field()correctly uses theNFPinput when given. Also adds this as a similar input option toMagneticField.save_mgrid().- Fixes some bugs that hampered robustness of
desc.geometry.FourierRZToroidalSurface.constant_offset_surface, particularly when the given grid had stellarator symmetry or when NFP=1. - Fixes possible bug in computing normalizations when both kinetic and pressure profiles are assigned. Also adds warnings whenever an pressure is added to a kinetic-constrained equilibrium and vice-versa to alert user to ambiguous equilibrium setups.
- Adds error in
MercierStabilityto guard against situation where if a grid with a point atrho=0were used, NaN would be computed, asMercierStabilityis undefined on-axis.
Performance Improvements
ProximalProjection.graduses a single VJP on the objective instead of multiple JVP followed by a manual VJP. This should be more efficient for expensive objectives.
Deprecations
sgdoptimizer is deprecated in favor ofoptax-sgd, and will be removed in a future release. To achieve the same behavior withoptimizer = Optimizer('sgd')andoptions={'alpha': ..., 'beta': ...}when the optimizer is removed, one can useoptimizer = Optimizer('optax-sgd')andoptions={'optax-options': {'learning_rate': alpha, 'momentum': beta, 'nesterov': True}}.- Removes
FiniteDiffDerivativefrom the public API. This class was no longer actually usable with the current versions of DESC's optimization framework, as JAX is now required for running any equilibrium or optimization solves.
New Contributors
Full Changelog: v0.16.0...v0.17.0
v0.16.0
New Features
- New basis vector and metric elements derivatives in PEST coordinates and quantities useful for a global MHD stability solver.
- Adds
desc.external.TERPSICHOREobjective for computing linear ideal MHD stability growth rates. This objective subclasses fromExternalObjectiveand requires access to the TERPSICHORE code, which is not included with DESC or its dependencies. - Adds
docs/dev_guids/external_objectives.rstas a tutorial for how to use external objectives, with TERPSICHORE as an example using parallel processing. - Adds keyword argument
normalizeto plot_1d, plot_3d.normalizeis a string to use for normalization. - Adds new linear objective
ShareParameterswhich can enforce that the chosen parameters of two or more objects of the same type remain identical during an optimization. Potentially useful for flexible stellarator optimization, where one has two coilsets with the same geometry but differing currents, and attempts to optimize for two different stellarator equilibria. - Changes related to
field_line_integrate, see #1839:field_line_integratenow returnsdiffrax.diffeqsolve.statsanddiffrax.diffeqsolve.resultif the flagreturn_auxis set to True.- Renames
maxstepsargument offield_line_integratetomax_steps. Now the argument has a consistent meaning with thediffraxpackage and specifies the maximum number of steps allowed for whole integration. Previously, it was used as maximum number of iterations between integration steps. field_line_integratefunction doesn't accept additional keyword-arguments related todiffrax, if it is necessary, they must be given throughoptionsdictionary.poincare_plotandplot_field_linesfunctions can now plot partial results if the integration failed. Previously, user had to passthrow=Falseor change the integration parameters. Users can ignore the warnings that are caused by hitting the bounds (i.e.Terminating differential equation solve because an event occurred.).chunk_sizeargument is now used for chunking the number of field lines. For the chunking of Biot-Savart integration for the magnetic field, users can usebs_chunk_sizeinstead.
Bug Fixes
- Fixes straight field line equilibrium conversion, see #1880
desc.compat.rescalewill now returnScaledProfileinstances for most of its profiles, to fix a bug where improper scaling could occur for certain profile types.- Now always use
sym=Falsein the default grid forplot_fsato ensure correct averages - Fixes bug that could lead extra compilation of jit-compiled functions that include
field_line_integrate. - Fixes inaccurate normalizations scales that could be computed for certain equilibria which had m=1 n=0 R and m=-1 n=0 Z components much smaller than their actual average minor radius, see #1954
- Fix bug in
PlasmaCoilSetMinDistancethat occured using aFourierRZToroidalSurfaceobject without passing in an the evaluation grid, see #2013 - Equilibrium profile assignments are now guaranteed to be consistent with the equilibrium resolution—automatically increasing lower-resolution profiles to match the equilibrium (while keeping higher-resolution profiles untouched)—meaning users who relied on lower-resolution profiles to implicitly restrict optimization must now explicitly use the
FixParametersconstraint. - Allow
desc.vmec.VMECIO.loadto load wout files that lacklrfp__logical__, like those outputted by VMEC++. This change assumes that those output files don't have poloidal flux label. - Fixes a bug that had prevented passing the
legendkwarg todesc.plotting.plot_surfaces.
Backend
- When using any of the
"proximal-"optimization methods, the equilbrium is now always solved before beginning optimization to the specified tolerance (as determined, for example, byoptions={"solve_options":{"ftol"...}}passed to thedesc.optimize.Optimizer.optimizecall). This ensures the assumptions of the proximal projection method are enforced starting from the first step of the optimization. desc.continuation.solve_continuation_automaticnow falls back to performing shape perturbations first and then pressure if the default pressure-then-shaping path fails, increasing robustness in arriving at the final equilibrium. To go directly to the path of applying shaping then pressure, pass the flagshaping_first=True.desc.equilibrium.Equilibrium.set_initial_guessnow sets lambda to zero for most use cases, and the docstring has been updated to be more explicit on what is done in each case.- Minimum JAX version bumped up to
0.5.0
Performance Improvements
- Coordinate mapping uses partial summation, see #1826
- Non-uniform FFTs (NUFFTS) are now used by default for computing bounce integrals, see #1834. NUFFT functionality is added through
jax-finufftpackage. If the GPU installation fails, users can fall back to the older (much slower) implementation by settingnufft_eps=0in the computation of the related quantities.
New Contributors
- @singh-jaydeep made their first contribution in #1905
Full Changelog: v0.15.0...v0.16.0
v0.15.0
New Features
- Adds new
desc.geometry.FourierXYCurveanddesc.coils.FourierXYCoilclasses, which are a form of planar curve and coil class which describe the curve in terms of cartesian x and y in the plane (as opposed to using polar radius likeFourierPlanarCurveandFourierPlanarCoil), which can make describing certain shapes (such as ellipses) easier. See #1504 for more information. - Adds
desc.objectives.PlasmaCoilSetMaxDistanceobjective, which allows setting a maximum distance the coils are allowed to be from the equilibrium, useful, for example, when trying to balance the need for space for a blanket while also ensuring the cryostat is not too large. See #1722 - Add
meshgrid_flattenutility for flattening 3d data to a 1d array in the correct order, essentially the opposite of meshgrid_reshape. - Adds ability to get top k eigenfunctions the corresponding eigenvalues from the ideal ballooning solver.
- Adds
desc.plotting.plot_field_linesfunction which can take in an inputdesc.magnetic_fields.MagneticFieldobject and plot a field line trajectory starting from some initial point in cylindrical coordinates. - Adds
gamma_ccompute quantity which is the integrand ofGamma_c. User can also plotgamma_cusing thedesc.plotting.plot_gammacfunction. (Note this function uses more memory than expected due to a performance regression in an upstream library. This is resolved in the next release).
Performance Improvements
- Use integration on the boundary (as opposed to volume integration) for more quantities where this is applicable (through use of Stoke's theorem), see #1094
- Minor memory improvements from a slight refactoring of
desc.equilibrium.Equilibrium.from_near_axismethod - Improve performance of
desc.magnetic_fields.field_line_integratefor fields with large stored attributes (such asdesc.magnetic_fields.SplineMagneticField(#1830) - Performance improvements for
desc.objectives.BallooningStabilityobjective (#1763, #1826) - Performance improvements for objectives which rely on coordinate mapping #1826
Minor Changes
- Adds
source_gridkwarg tofrom_fieldforSplineMagneticField, to allow for specifying the grid used to discretize the magnetic field the splined field is being created from. - Change default constraints for eq.optimize to just be ForceBalance, so now no other constraints are included by default, see #1725
- Allows
safenormalizeto work on multiple vectors. - Updates to docs
- Notes on role of
eq.Psiin vacuum free boundary in free boundary tutorial and coil optimization tutorial - Updates
Adding new objective functionstutorial - Adds example uses of
GenericObjectiveandObjectiveFromUserto advanced optimization tutorial - updates installation docs for della and adds new
uvinstall method
- Notes on role of
Bug Fixes
- ensures surfaces only compute things that make sense for their parametrizations, see #1724
- fixes bugs in VMEC I/O
- bug in
desc.vmec.write_vmec_inputfor spline profiles (see #1740) - fixes error when reading VMEC input files with
PMASS_TYPEdefined which could result in converted DESC input files lacking a pressure profile
- bug in
- Ensures the stochastic optimizer
sgdprints an iteration even if the first step satisfies the termination criterion - Fix
nanin reverse mode gradient caused byrotation_matrix - Fix some outstanding bugs with
desc.io.write_asciifunction - Fixes bug in
desc.geometry.FourierRZCurve from_valueswhen a numpy array. See #1828 - Ensures user supplied linear constraint
x_scalepassed todesc.optimize.Optimizer.optimizeis not overwritten by the default dynamically updatedx_scale
Deprecations
desc.io.write_asciimethod for equilibrium I/O is deprecated and not recommended for use. Users are recommended instead to use the hdf5 files as the primary method of I/O with DESC objects.- Deprecates
norm_Fandnorm_namekwargs fromdesc.plottingfunctions (plot_fsa,plot_section,plot_2d) in favor of the new compute quantity|F|_normalized, which is the magnitude of the force error normalized by the volume-averaged magnetic pressure gradient. - renames
linecolortocolorin thedesc.plottingmodule functions
Breaking Changes
- Significant changes to how DESC handles static attributes during JIT compilation. Going forward if any class/object has attributes that should be treated as static by
jax.jit, these should be declared at the class level like_static_attrs = ["foo", "bar"]. Generally, non-arraylike attributes such as functions, strings etc should be marked static, as well as any attributes used for control flow. Previously this was done automatically, but in a way that caused a lot of performance bugs and unnecessary recompilation. These changes have been implemented for all classes in thedescrepository, but if you have custom objectives or other local objects that subclass fromdescyou may need to add this yourself. JAX error messages usually do a good job of alerting you to things that need to be static, and feel free to open an issue withdescif you have any questions.
New Contributors
- @gretahibbard made their first contribution in #1529
Full Changelog: v0.14.2...v0.15.0
v0.14.2
New Features
- Updates
Equilibriuminitial guess to use geometric center as the axis. This will allow non-convex cross-sections to be initialized without having to solve to achieve nested surfaces. - Adds new regularization options to
desc.objectives.SurfaceCurrentRegularization. - Adds a new utility function
desc.compat.contract_equilibriumwhich takes in anEquilibriumobject and an argumentinner_rho, and returns a newEquilibriumwith originalEquilibrium'sinner_rhoflux surface as its boundary.
Optionally can also contract the profiles of the originalEquilibriumso that the newEquilibrium's profiles match the original's in real space. - Adds second-order NAE constraints, accessible by passing
order=2todesc.objectives.get_NAE_constraints. resultdictionary returned byOptimizer.optimizeoreq.optimizenow includes sub-dictionary"Objective values"containing summary info of objective values before and after optimization, the same info that is printed to the terminal by default.- Adds error for incorrect grids in
desc.objectives.BootstrapRedlConsistencyand when computingcurrent Redland<J*B> Redlcompute quantities - Allows Redl compute quantities to use
SplineProfileand updates Redl bootstrap current consistency tutorial to include aSplineProfileoptimization - Adds automatically generated header file showing date the input file was created with
desc.vmec.VMECIO.write_vmec_input - Adds
source_gridargument todesc.magnetic_fields._MagneticField.save_mgrid functionto allow user to control the discretization of the magnetic field object being used to construct themgridoutput. - Allows
x_scaleto be passed tofactorize_linear_constraintsinOptimizer.optimizethrough the new"linear_constraint_options".
Performance Improvements
ProximalProjectionuses jvp's for the derivative of theForceBalancepart instead of manually taking the matrix products. This reduces the jacobian time on CPU.- Improves memory management to reduce the base memory used during optimization while using
lsq-exact,lsq-auglagandfmin-auglagoptimizers as well as theirproximal-versions.
Bug Fixes
- Fixes issue in
desc.geometry.curve.FourierPlanarCurve.from_valueswhere the orientation of the fitted curve can be the reverse of the original curve, which can be problematic for coils (the current is not negated, so the resulting fitted coil would have field opposite of the initial). - Fixes bug where
ObjectiveFunctionwas incorrectly usingderiv_mode="batched"and the heuristic-setjac_chunk_sizewhenjac_chunk_sizeis given to a sub-objective, where it should have instead defaulted toderiv_mode="blocked". See #1687 - Fixes bug where
ProximalProjectionwas using wrongjac_chunk_sizeinternally and using more memory than one would expect given thejac_chunk_size. This fix gives separateblockedandbatchedmethods toProximalProjection.
New Contributors
Full Changelog: v0.14.1...v0.14.2
v0.14.1
What's Changed
- Fixes bug in desc.vmec.VMECIO.write_vmec_input for current-constrained equilibria, where DESC was incorrectly writing the
$s^0$ mode, where VMEC actually assumes it is zero and starts at the$s^1$ (which is different than the usual convention VMEC uses for its current profile when it uses the current derivative, where it starts with the$s^0$ mode).
Full Changelog: v0.14.0...v0.14.1
v0.14.0
What's Changed
- Updates default parameters for partition support size in the singular surface integrals.
- Enables tracking multiple field lines in
Bounce2D. - Adds
desc.objectives.LinkingCurrentConsistencyfor ensuring that coils in a stage 2 or single stage optimization provide the required linking current for a given equilibrium. desc.objectives.Omnigenityis now vectorized and able to optimize multiple surfaces at the same time. Previously it was required to use a different objective for each surface.- Adds a new objective
desc.objectives.MirrorRatiofor targeting a particular mirror ratio on each flux surface, for either anEquilibriumorOmnigenousField. - Adds the output quantities
wbandwptoVMECIO.save. - Changes implementation of Dommaschk potentials to use recursive algorithm and symbolic integration, improving agreement of numerical results with the literature.
eq.solveandeq.perturbnow acceptLinearConstraintProjectionas objective. This option must be used without any constraints.- Allows non-proximal optimizers to handle optimizing more than one
Equilibriumobject simultaneously. - Renames compute quantity
sqrt(g)_Btosqrt(g)_Boozer_DESCto more accurately reflect what the quantiy is (the jacobian from (rho,theta_B,zeta_B) to (rho,theta,zeta)), and adds a new function to computesqrt(g)_Boozerwhich is the jacobian from (rho,theta_B,zeta_B) to (R,phi,Z). - DESC/JAX version and device info is no longer printed by default, but can be accessed with the function
desc.backend.print_backend_info().
New Features
-
Adds Bounce integral methods with
desc.integrals.Bounce2D. -
Adds Effective ripple
desc.objectives.EffectiveRippleand Gamma_cdesc.objectives.Gamma_coptimization objectives. -
Adds new compute quantities for partial derivatives in different coordinate systems.
-
Adds a new profile class
PowerProfilefor raising profiles to a power. -
Adds an option
scaled_termination(defaults to True) to all the desc optimizers to measure the norms forxtolandgtolin the scaled norm provided byx_scale(which defaults to using an adaptive scaling based on the Jacobian or Hessian). This should make things more robust when optimizing parameters with widely different magnitudes. The old behavior can be recovered by passingoptions={"scaled_termination": False}. -
Adds a new objective
desc.objectives.CoilIntegratedCurvaturefor targeting convex coils. -
Adds the example "reactor_QA", which is similar to "precise_QA" but with self-consistent bootstrap current at finite beta.
-
desc.objectives.CoilSetMinDistanceanddesc.objectives.PlasmaCoilSetMinDistancenow include the option to use a softmin which can give smoother gradients. -
Adds a new function
desc.coils.initialize_helical_coilsfor creating an initial guess for stage 2 helical coil optimization. -
Adds
desc.vmec_utils.make_boozmn_outputfor writing boozmn.nc style output files
for compatibility with other codes which expect such files from the Booz_Xform code. -
Adds a new objective
desc.objectives.ExternalObjectivefor wrapping external codes with finite differences. -
Allows specification of Nyquist spectrum maximum modenumbers when using
VMECIO.saveto save a DESC .h5 file as a VMEC-format wout file -
Adds an option to
VMECIO.saveto specify the grid resolution in real space. -
Performance Improvements
-
A number of minor improvements to basis function evaluation and spectral transforms to improve speed. These will also enable future improvements for larger gains.
-
proximal-optimizers use a singleLinearConstraintProjectionand this makes the optimization faster for high resolution cases where taking the SVD (for null-space and inverse) of constraint matrix takes significant time. -
Chunking/batching can now be used in more places. Note that this might change the default behavior and you might get OOM (out of memory) errors.
- Adds batching feature to parallelize singular integrals used in free boundary solves.
- Adds
chunk_sizeoption to compute magnetic field methods to increase performance. Users may need to update their scripts to pass inbs_chunk_size=20or some other reasonable number if out of memory occurs as the default attempts to perform the entire computation at once. desc.objectives.CoilSetMinDistanceanddesc.objectives.PlasmaCoilSetMinDistancenow have adist_chunk_sizeoption to break up the distance calculation into smaller pieces to save memory.- Changes hessian computation to use chunked
jacfwdandjacrev, allowingjac_chunk_sizeto now reduce hessian memory usage as well.
Bug Fixes
- Small bug fix to use the correct normalization length
ain the BallooningStability objective. - Fixes I/O bug when saving/loading
_Profileclasses that do not have a_paramsattribute. - Minor bugs described in #1323.
- Corrects basis vector computations made on surface objects #1175.
- Allows keyword arguments to be passed to
GenericObjectiveandObjectiveFromUser. - Fixes bug where
save_in_makegrid_formatfunction did not correctly account forCoilSetobjects with NFP>1 or sym=True attributes, and so would not save all the coils. - Fixes issue with interpolator for singular integrals #1522 and additional checks 1519.
- Fixes the coil currents in
desc.coils.initialize_modular_coilsto now give the correct expected linking current. desc.objectives.PlasmaVesselDistancenow correctly accounts for multiple field periods on both the equilibrium and the vessel surface. Previously it only considered distances within a single field period.- Sets
os.environ["JAX_PLATFORMS"] = "cpu"instead ofos.environ["JAX_PLATFORM_NAME"] = "cpu"when doingset_device("cpu"). - Fixes bug in
desc.input_reader.desc_output_to_inpututility function for asymmetric equilibria profiles, where the full profile resolution was not being saved. - Fixes bug when passing only
syminto.change_resolutionforFourierRZToroidalSurface,ZernikeRZToroidalSectionandFourierRZCurve. - Fixes bug that was setting
ObjectiveFunction._things_per_objective_idxincorrectly. Now each_Objectivecan define a unique order that it expects to use parameters for multiple "things". - Fixes bug that occurs when an NAE solution used with NAE constraints is asymmetric, but has a symmetric axis.
- Fixes bug in
FourierCurrentPotentialField.change_Phi_resolutionwhereN_Phiwould be changed toM_PhiifNis not explicitly passed into the method. - Fixes bug when setting current for a
MixedCoilSetwith an arbitrary tree structure. - Corrects Cholesky factorized least-squares solve for wide matrices used in root finding.
- Fixes bug in the formula for computing
"P_fusion".
Breaking Changes
- Adds support for Python 3.13 and removes support for 3.9 since new JAX versions require minimum Python 3.10.
Full Changelog: v0.13.0...v0.14.0
v0.13.0
New Features
- Adds function
solve_regularized_surface_currenttodesc.magnetic_fieldsmodule that implements the REGCOIL algorithm (Landreman, (2017)) for surface current normal field optimization, which can run on both CPUs and GPUs.- Can specify the tuple
current_helicity=(M_coil, N_coil)to determine if resulting contours correspond to helical topology (both(M_coil, N_coil)not equal to 0), modular (N_coilequal to 0 andM_coilnonzero) or windowpane/saddle (M_coilandN_coilboth zero) M_coilis the number of poloidal transits a coil makes before returning to itself, whileN_coilis the number of toroidal transits a coil makes before returning to itself (this is sort of like the QShelicity)- if multiple values of the regularization parameter are input, will return a family of surface current fields (as a list) corresponding to the solution at each regularization value
- Can specify the tuple
- Adds method
to_CoilSettoFourierCurrentPotentialFieldwhich implements a coil cutting algorithm to discretize the surface current into coils- works for both modular and helical coils
- Adds a new objective
SurfaceCurrentRegularization(which minimizesw*|K|, the regularization term from surface current in the REGCOIL algorithm, withwbeing the objective weight which act as the regularization parameter)- use of both this and the
QuadraticFluxobjective allows for REGCOIL solutions to be obtained through the optimization framework, and combined with other objectives as well.
- use of both this and the
- Adds a new tutorial showing how to use
REGCOILfeatures, as well as a new section in the stage two optimization notebook using REGCOIL to obtain an initial guess for filamentary coil optimization. - Adds
from_input_filemethod toEquilibriumclass to generate anEquilibriumobject with boundary, profiles, resolution and flux specified in a given DESC or VMEC input file - Adds
SurfaceQuadraticFluxobjective which minimizes the quadratic magnetic flux through aFourierRZToroidalSurfaceobject, allowing for optimizing for Quadratic flux minimizing (QFM) surfaces. - Allows
ToroidalFluxobjective to acceptFourierRZToroidalSurfaceso it can be used to specify the toroidal flux through a QFM surface. - Adds
eq_fixedflag toToroidalFluxto allow for the equilibrium/QFM surface to vary during optimization, useful for single-stage optimizations. - Adds tutorial notebook showcasing QFM surface capability.
- Adds
rotate_zetafunction todesc.compatto rotate anEquilibriumaround Z axis.
Minor Changes
- Changes local area weighting of Bn in
QuadraticFluxobjective to be the square root of the local area element (Note that any existing optimizations using this objective may need different weights to achieve the same result now.) - Adds an
NFPattribute toScalarPotentialField,VectorPotentialFieldandDommaschkPotentialField, to allowSplineMagneticField.from_fieldandMagneticField.save_mgridto efficiently take advantage of the discrete toroidal symmetry of these fields, if present. - Adds support for
numpyversion2.0.0 - Various improvements to optimization algorithms for improving performance of equilibrium solving and optimization, especially on GPUs.
Bug Fixes
- Fixes bug that occurs when taking the gradient of
rootandroot_scalarwith newer versions of JAX (>=0.4.34) and unpins the JAX version. - Changes
FixLambdaGaugeconstraint to now enforce zero flux surface average for lambda, instead of enforcing lambda(rho,0,0)=0 as it was incorrectly doing before. - Fixes bug in
softmin/softmaximplementation. - Fixes bug that occurred when using
ProximalProjectionwith a scalar optimization algorithm. - Fixes bug where
from desc.plotting import *would not importdesc.plotting.poincare_plot
Full Changelog: v0.12.3...v0.13.0
v0.12.3
What's Changed
- Add
jac_chunk_sizekeyword argument toObjectiveFunctionto reduce memory usage of forward mode Jacobian calculation , see docs for more details - Add objective using for Ideal-Ballooning Stability, see related paper for more details.
- Make naming of grids kwargs among free boundary objectives more uniform
- Add kwarg options to plot 3d without any axis visible
- Pin jax version temporarily to avoid JAX-related bug
Bug Fixes
- Fix error that can occur when
get_NAE_constraintsis called for only fixing the axis - bug fix for
most_rationalwith negative arguments - fix bug. in
FixOmniBMax
New Contributors
- @lisamessier made their first contribution in #1269
- @missing-user made their first contribution in #1274
- @felicia22 made their first contribution in #1284
Full Changelog: v0.12.2...v0.12.3