Recent Releases of desc-opt
desc-opt - 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 https://github.com/PlasmaControl/DESC/pull/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 https://github.com/PlasmaControl/DESC/pull/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 https://github.com/PlasmaControl/DESC/pull/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(https://github.com/PlasmaControl/DESC/pull/1830) - Performance improvements for
desc.objectives.BallooningStabilityobjective (https://github.com/PlasmaControl/DESC/pull/1763, https://github.com/PlasmaControl/DESC/pull/1826) - Performance improvements for objectives which rely on coordinate mapping https://github.com/PlasmaControl/DESC/pull/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 https://github.com/PlasmaControl/DESC/pull/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 https://github.com/PlasmaControl/DESC/pull/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 https://github.com/PlasmaControl/DESC/pull/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
New Contributors
- @gretahibbard made their first contribution in https://github.com/PlasmaControl/DESC/pull/1529
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.14.2...v0.15.0
- Python
Published by dpanici 6 months ago
desc-opt - 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
- @cfe316 made their first contribution in https://github.com/PlasmaControl/DESC/pull/1674
- @ryanwu4 made their first contribution in https://github.com/PlasmaControl/DESC/pull/1708
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.14.1...v0.14.2
- Python
Published by YigitElma 9 months ago
desc-opt - v0.14.1
What's Changed
- Fixes bug in desc.vmec.VMECIO.writevmecinput 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: https://github.com/PlasmaControl/DESC/compare/v0.14.0...v0.14.1
- Python
Published by dpanici 11 months ago
desc-opt - 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,thetaB,zetaB) to (rho,theta,zeta)), and adds a new function to computesqrt(g)_Boozerwhich is the jacobian from (rho,thetaB,zetaB) 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 Gammac ``desc.objectives.Gammac`` optimization 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 "reactorQA", which is similar to "preciseQA" 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: https://github.com/PlasmaControl/DESC/compare/v0.13.0...v0.14.0
- Python
Published by dpanici 11 months ago
desc-opt - 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: https://github.com/PlasmaControl/DESC/compare/v0.12.3...v0.13.0
- Python
Published by dpanici about 1 year ago
desc-opt - 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 https://github.com/PlasmaControl/DESC/pull/1269
- @missing-user made their first contribution in https://github.com/PlasmaControl/DESC/pull/1274
- @felicia22 made their first contribution in https://github.com/PlasmaControl/DESC/pull/1284
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.12.2...v0.12.3
- Python
Published by dpanici over 1 year ago
desc-opt - v0.12.2
What's Changed
- Add Vector Potential Calculation to
Coilclasses and MostMagneticFieldClasses - Add automatic intersection checking to
CoilSetobjects, and a methodis_self_intersectingwhich check if the coils in theCoilSetintersect one another. - Add
flip_thetacompatibility function to switch the zero-point of the poloidal angle between the inboard/outboard side of the plasma. - Change field line integration to use
diffraxpackage instead of the deprecatedjax.experimental.odeintfunction, allowing for specifying the integration method, the step-size used, and more. See the documentation offield_line_integrateanddiffraxfor more details. - Add
use_signed_distancekeyword toPlasmaVesselDistanceobjective to allow for specifying the desired relative position of the plasma and surface. - Vectorize Boozer transform over multiple surfaces, to allow for calculation of Boozer-related quantities on grids that contain multiple radial surfaces.
- Optimizer now automatically scales linearly-constrained optimization parameters to be of roughly the same magnitude, to improve optimization when parameter values range many orders of magnitude
- Add
HermiteSplineProfileclass, which allows for profile derivative information to be specified along with profile value information. - Add installation instructions for RAVEN cluster at IPP to the docs
- Change optimizer printed output to be easier to read
- Add
HeatingPowerandFusionPowerobjectives - Reduce
QuadratureGridnumber of radial points to match its intended functionality - Fix some plotting issues that arose when NFP differs from 1 for objects, or when passed-in phi exceeds 2pi/nfp
- Update
VMECIOto allow specification of Nyquist spectrum and fix some bugs with asymmetric wout files - The code no longer mods non-periodic angles (such as the field line label $\alpha$) by $2\pi$, as in field-line-following contexts, functions may not be periodic in these angles.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.12.1...v0.12.2
- Python
Published by dpanici over 1 year ago
desc-opt - v0.12.1
What's Changed
- Optimizers now default to use QR factorization for least squares which is much faster especially on GPU.
- Fix bug when reading VMEC input ZAXIS as ZAXIS_CS
- Some fixes/improvements for computing quantities along a fieldline.
- Adds compute quantities for PEST coordinate system basis vectors
- Many init methods now default to running on CPU, even when GPU is enabled, as CPU was found to be much faster for these cases.
- New objectives
desc.objectives.FixNearAxis{R,Z,Lambda}for fixing near axis behavior. - Adds
from_valuesmethod that was present inFourierRZCurvebut missing inFourierRZCoil - Adds new
from_valuesmethod forFourierPlanarCurveandFourierPlanarCoil
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.12.0...v0.12.1
- Python
Published by f0uriest over 1 year ago
desc-opt - v0.12.0
New Features
- Coil optimization is now possible in DESC using various filamentary coils. This includes
a number of new objectives:
desc.objectives.QuadraticFluxdesc.objectives.ToroidalFluxdesc.objectives.CoilLengthdesc.objectives.CoilCurvaturedesc.objectives.CoilTorsiondesc.objectives.CoilCurrentLengthdesc.objectives.CoilSetMinDistancedesc.objectives.PlasmaCoilSetMinDistancedesc.objectives.FixCoilCurrentdesc.objectives.FixSumCoilCurrent
- Add Normal Field Error
"B*n"as a plot quantity todesc.plotting.{plot_2d, plot_3d}. - New function
desc.plotting.poincare_plotfor creating Poincare plots by tracing field lines from coils or other external fields. - New profile type
desc.profiles.TwoPowerProfile. - Add
desc.geometry.FourierRZCurve.from_valuesmethod to fit curve with data. - Add
desc.geometry.FourierRZToroidalSurface.from_shape_parametersmethod for generating a surface with specified elongation, triangularity, squareness, etc. - New class
desc.magnetic_fields.MagneticFieldFromUserfor user defined B(R,phi,Z). - All vector variables are now computed in toroidal (R,phi,Z) coordinates by default.
Cartesian (X,Y,Z) coordinates can be requested with the compute keyword
basis='xyz'. - Add method
desc.coils.CoilSet.is_self_intersecting, which checks if any coils intersect each other in the coilset.
Minor changes
- Improved heuristic initial guess for
Equilibrium.map_coordinates. - Add documentation for default grid and target/bounds for objectives.
- Add documentation for compute function keyword arguments.
- Loading a coilset from a MAKEGRID file will now return a nested
MixedCoilSetif there are coil groups present in the MAKEGRID file. - Users must now pass in spacing/weights to custom
Grids (the previous defaults were often wrong, leading to incorrect results) - The
normalandcenterparameters of aFourierPlanarCurvecan now be specified in either cartesian or cylindrical coordinates, as determined by thebasisparameter. - Misc small changes to reduce compile time and memory consumption (more coming soon!)
- Linear constraint factorization has been refactored to improve efficiency and reduce floating point error.
desc.objectives.{GenericObjective, ObjectiveFromUser}can now work with other objects besides anEquilibrium(such as surfaces, curves, etc.)- Improve warning for missing attributes when loading desc objects.
Bug Fixes
- Several small fixes to ensure things that should be
ints areints - Fix incorrect toroidal components of surface basis vectors.
- Fix a regression in performance in evaluating Zernike polynomials.
- Fix errors in
Equilibrium.map_coordinatesfor prescribed current equilibria. - Fix definition of
b0in VMEC output. - Fix a bug where calling
Equilibrium.compute(..., data=data)would lead to excessive recalculation and potentially wrong results. - Fixes a bug causing NaN in reverse mode AD for
Omnigenityobjective. - Fix a bug where
"A(z)"would be zero if the grid doesn't contain nodes at rho=1.
New Contributors * @tmqian made their first contribution in https://github.com/PlasmaControl/DESC/pull/1041
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.11.1...v0.12.0
- Python
Published by f0uriest over 1 year ago
desc-opt - v0.11.1
What's Changed
- Change default symmetry to
"sin"for current potential fields created with thefrom_surfacemethod when the surface is stellarator symmetric - Add objectives for coil length, curvature and torsion
- Improve Dommaschk potential magnetic field fitting by adding NFP option to only use potentials with the desired periodicity
- Fix incorrect Jacobian when bounds constraints are used by adding explicit Jacobian of
compute_scaled_error - Fix bug in Dommaschk potentials that arose when evaluating the potential at Z=0
- Fix bug in Dommaschk potential fitting when symmetry is set to true
- Bump black version from 22.10.0 to 24.3.0
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.11.0...v0.11.1
- Python
Published by dpanici almost 2 years ago
desc-opt - v0.11.0
New Features
- Adds functionality to optimize for omnigenity. This includes the
OmnigenousFieldmagnetic field class, theOmnigenityobjective function, and an accompanying tutorial. - Adds new objectives for free boundary equilibria:
BoundaryErrorandVacuumBoundaryError, along with a new tutorial notebook demonstrating their usage. - Objectives
Volume,AspectRatio,Elongationnow work forFourierRZToroidalSurfaceobjects as well asEquilibrium. MagneticFieldobjects now have a methodsave_mgridfor saving field data in the MAKEGRID format for use with other codes.SplineMagneticField.from_mgridnow defaults to usingextcurfrom the mgrid file.- When converting a near axis solution from QSC/QIC to a desc
Equilibrium, the least squares fit is now weighted inversely with the distance from the axis to improve the accuracy for low aspect ratio. - Adds a bounding box to the
field_line_integratedefined bybounds_Randbounds_Zkeyword arguments, which form a hollow cylindrical bounding box. If the field line trajectory exits these bounds, the RHS will be multiplied by an exponentially decaying function of the distance to the box to stop the trajectory and prevent tracing the field line out to infinity, which is both costly and unnecessary when making a Poincare plot, the principle purpose of the function. - Adds a new class
DommaschkPotentialFieldwhich allows creation of magnetic fields based off of the vacuum potentials detailed in Representations for Vacuum Potentials in Stellarators https://doi.org/10.1016/0010-4655(86)90109-8.
Speed Improvements
CoilSetis now more efficient when stellarator or field period symmetry is used.- Improves the efficiency of
proximaloptimizers by reducing the number of objective derivative evaluations. Optimization steps should now be 2-5x faster. - Improved performance of Zernike polynomial evaluation.
- Adds a bounding box to the
field_line_integratedefined bybounds_Randbounds_Zkeyword arguments, which form a hollow cylindrical bounding box. If the field line trajectory exits these bounds, the RHS will be multiplied by an exponentially decaying function of the distance to the box to stop the trajectory and prevent tracing the field line out to infinity, which is both costly and unnecessary when making a Poincare plot, the principle purpose of the function.
Bug Fixes
- Fix bug causing NaN in
ForceBalanceobjective when the grid contained nodes at the magnetic axis. - When saving VMEC output,
bucoandbvcoare now correctly saved on the half mesh. Previously they were saved on the full mesh. - Fixed a bug where hdf5 files were not properly closed after reading.
- Fixed bugs relating to
Curveobjects not being optimizable. - Fixed incorrect rotation matrix for
FourierPlanarCurve. - Fixed bug where
plot_boundarieswith a singlephivalue would return an empty plot.
Breaking Changes
- Renames the method for comparing equivalence between DESC objects from
eqtoequivto avoid confusion with the common shorthand forEquilibrium. - Minimum Python version is now 3.9
- Python
Published by f0uriest almost 2 years ago
desc-opt - v0.10.4
Equilibrium.map_coordinatesis now differentiable.- Removes method
Equilibrium.compute_flux_coordinatesas it is now redundant with the more generalEquilibrium.map_coordinates. - Allows certain objectives to target
FourierRZToroidalSurfaceobjects as well asEquilibriumobjects, such asMeanCurvature,PrincipalCurvature, andVolume. - Allow optimizations where the only object being optimized is not an
Equilibriumobject e.g. optimizing only aFourierRZToroidalSurfaceobject to have a certainVolume. - Many functions from
desc.plottingnow also work for plotting quantities fromCurveandSurfaceclasses. - Adds method
FourierRZToroidalSurface.constant_offset_surfacewhich creates a surface with a specified constant offset from the base surface. - Adds method
FourierRZToroidalSurface.from_valuesto create a surface by fitting (R,phi,Z) points, along with a user-defined poloidal angle theta which sets the poloidal angle for the created surface - Adds new objective
LinearObjectiveFromUserfor custom linear constraints. elongationis now computed as a function of zeta rather than a single global scalar.- Adds
beta_volandbetaxisto VMEC output. - Reorder steps in
solve_continuation_automaticto avoid finite pressure tokamak with zero current. - Fix error in lambda o(rho) constraint for near axis behavior.
- Fix bug when optimizing with only a single constraint.
- Fix some bugs causing NaN in reverse mode AD for some objectives.
- Fix incompatible array shapes when user supplies initial guess for lagrange multipliers for augmented lagrangian optimizers.
- Fix a bug caused when optimizing multiple objects at the same time and the order of the objects gets mixed up.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.10.3...v0.10.4
- Python
Published by f0uriest about 2 years ago
desc-opt - v0.10.3
What's Changed
- Adds
deriv_modekeyword argument to allObjectives for specifying whether to use forward or reverse mode automatic differentiation. - Adds
desc.compat.rescalefor rescaling equilibria to a specified size and field strength.- Adds new keyword
surface_fixedtoPlasmaVesselDistanceobjective which says whether or not the surface comparing the distance from the plasma to is fixed or not. If True, then the surface coordinates can be precomputed, saving on computation during optimization. Set to False by default.
- Adds new keyword
- Adds objective function
desc.objectives.GoodCoordinatesfor finding "good" (ie, non-singular, non-degenerate) coordinate mappings for initial guesses. This is applied automatically when creating a newEquilibriumif the default initial guess of scaling the boundary surface produces self-intersecting surfaces. This can be disabled by passingensure_nested=Falsewhen constructing theEquilibrum. - Adds
loss_functionargument to allObjectives for applying one of min/max/mean to objective function values (for targeting the average value of a profile, etc). Equilibrium.get_profilenow allows user to choose a profile type (power series, spline, etc)- Fixes a bug preventing linear objectives like
FixPressurefrom being used as bounds. - Updates to tutorials and example scripts
desc.interpolatemodule has been deprecated in favor of theinterpaxpackage.- Utility functions like
desc.objectives.get_fixed_boundary_constraintsnow no longer require the user to specify which profiles the equilibrium has, they will instead be inferred from the equilibrium argument.
New Contributors
- @kianorr made their first contribution in https://github.com/PlasmaControl/DESC/pull/648
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.10.2...v0.10.3
- Python
Published by f0uriest about 2 years ago
desc-opt - v0.10.2
What's Changed
- Updates
desc.examples:NCSXnow has a fixed current profile. Previously it used a fixed iota based on a fit, but this was somewhat inaccurate.QAShas been removed as it is now redundant withNCSX.ARIES-CShas been scaled to the correct size and field strength.WISTELL-Ais now a true vacuum solution, previously it approximated the vacuum solution with fixed rotational transform.- Flips sign of iota for
W7-XandATFto account for positive jacobian. - new example for
HSX.
- Adds new compute quantities
"iota current"and"iota vacuum"to compute the rotational transform contributions from the toroidal current and background field. - Adds ability to compute equilibria with anisotropic pressure. This includes a new
profile,
Equilibrium.anisotropy, new compute quantityF_anisotropic, and a new objectiveForceBalanceAnisotropic. plot_3dandplot_coilshave been updated to use Plotly as a backend instead of Matplotlib, since Matplotlib isn't great for 3d plots, especially ones with multiple overlapping objects in the scene. Main API differences:- Plotly doesn't have "axes" like Matplotlib does, just figures. So the
axargument has been replaced byfigforplot_3dandplot_coils, and they no longer returnax. - Names of colormaps, line patterns, etc are different, so use caution when
specifying those using
kwargs. Thankfully the error messages Plotly generates are usually pretty informative and list the available options.
- Plotly doesn't have "axes" like Matplotlib does, just figures. So the
- Adds zeroth and first order NAE constraints on the poloidal stream function lambda,
accessible by passing in
fix_lambda=Trueto theget_NAE_constraintgetter function. - Implements
CurrentPotentialFieldandFourierCurrentPotentialFieldclasses, which allow for computation of the magnetic field from a surface current density given byK = n x grad(Phi)wherePhiis a surface current potential.CurrentPotentialFieldallows for an arbitrary current potential functionPhiFourierCurrentPotentialFieldassumes the current potential function to be of the form of a periodic potential (represented by aDoubleFourierSeries) and two secular terms, one each linear in the poloidal and in the toroidal angle.
- Small fixes to make VMEC IO stuff more robust against different profile types, input file formatting etc.
- Improve Biot-Savart discretization, add new methods for converting between coil types
New Contributors
- @YigitElma made their first contribution in https://github.com/PlasmaControl/DESC/pull/718
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.10.1...v0.10.2
- Python
Published by f0uriest over 2 years ago
desc-opt - v0.10.1
Improvements
- Adds second derivatives of contravariant basis vectors to the list of quantities we can compute.
- Refactors most of the optimizer subproblems to use JAX control flow, allowing them to run more efficiently on the GPU.
- Adds
'shear'as a compute quantity andShearas an objective function. - Adds a new objective
Pressureto target a pressure profile as a function of rho instead of spectral coefficients likeFixPressure. Can also be used when optimizing kinetic equilibria. - Allows all profile objectives to have callable bounds and targets.
- All objective function values should now be approximately independent of the grid
resolution. Previously this was only true when objectives had
normalize=True Objective.print_valueNow prints max/min/avg for most objectives, and it should be clear whether it is printing the actual value of the quantity or the error between the objective and its target.- Adds new options to
plot_boozer_modesto plot only symmetry breaking modes (when helicity is supplied) or only the pointwise maximum of the symmetry breaking modes. - Changes default
Gridsorting to False, to avoid unintentional sorting of passed-in nodes. Must explicitly specifysort=TruetoGridobject to sort now.
Breaking Changes
- Removes
gridattribute fromProfileclasses,gridshould now be passed in when callingProfile.compute.
Bug Fixes
- Fixes bug where running DESC through the command line interface with the
-gflag failed to properly utilize the GPU
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.10.0...v0.10.1
- Python
Published by dpanici over 2 years ago
desc-opt - v0.10.0
Major Changes
- Removes the various
compute_*methods fromSurfaceandCurveclasses in favor of a unifiedcomputemethod, similar toEquilibrium.compute. The method takes as arguments strings containing the desired data. A full list of available options is at https://desc-docs.readthedocs.io/en/stable/variables.html - Analytic limits at the magnetic axis of all quantities have now been implemented.
- New functions
desc.random.random_surfaceanddesc.random.random_pressurefor generating pseudo-random toroidal surfaces and monotonic profiles. - Adds new curve parameterization
desc.geometry.SplineXYZCurveand corresponding coildesc.coils.SplineXYZCoilthat use a local spline of points in real space. - New methods
CoilSet.from_makegrid_coilfileandCoilSet.save_in_makegrid_formatfor creating aCoilSetofSplineXYZCoilfrom a MAKEGRID style text file or saving coil data in the format expected by MAKEGRID. - New function
desc.magnetic_fields.read_BNORM_filefor reading the Bnormal distribution on a surface from a BNORM code output file. - New methods
compute_Bnormalandsave_BNORM_filefor all magnetic field classes to compute the normal component of the field on a given surface and save the data in the same format as the BNORM code.
Minor Changes
- Increases default radial resolution for stability objectives to be consistent with other objectives.
- Creating
Equilibriumobjects or callingchange_resolutionon objects that have it should now be significantly faster. GridandTransformobjects can now be created within the context ofjit, by passingjitable=Trueto the constructor.- Added support for newer JAX versions, up to v0.4.14. Newer versions likely work as well but are not automatically tested.
- Adds ability to compute curvatures of constant theta and constant zeta surfaces.
- Fixes definition of derivatives of co- and contra-variant basis vectors to properly account for the chain rule derivatives of the cylindrical basis vectors as well.
- Adds calculation of
A(r), the approximate cross sectional area as a function of rho. - Adds method
desc.io.InputReader.descout_to_inputto create a text input file for DESC from a saved hdf5 output.
Bug Fixes
- Fixes bug in saving nested dicts/lists.
- Removes default node at rho=1 for
BootstrapRedlConsistencyobjective to avoid dividing by zero where profiles may be zero. - Fixes bug causing
QuasisymmetryBoozerto fail when compiling due to JAX issues. - Fixes incorrect implementation of derivatives of contravariant metric tensor elements (these were unused at present so shouldn't have caused any issues.)
- Fixes bug where bounds for profile objectives were not scaled correctly when used as an inequality constraint.
- Fixes a bug where calculating elongation would return NaN for near-circular cross sections.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.9.2...v0.10.0
- Python
Published by f0uriest over 2 years ago
desc-opt - v0.9.2
Improvements
- Improves robustness and speed of
map_coordinates. - Adds axis parameters
Ra_nandZa_nas optimizable DoF when using standard constrained optimization methods (ie, notProximalProjection). - Adds method to convert
FourierRZCurvetoFourierXYZCurve. - Makes DESC classes compatible with JAX pytrees.
- Adds Chebyshev polynomials as basis function (for future use).
Breaking changes
- Renames
theta_sfltotheta_PESTin compute functions to avoid confusion with other straight field line coordinate systems. - Makes plotting kwargs a bit more uniform.
zeta,nzeta,nphihave all been superceded byphiwhich can be an integer for equally spaced angles or a float or array of float to specify angles manually.
Bug fixes
- Avoids accidentally overwriting equilibria during automatic continuation method.
New Contributors
- @rahulgaur104 made their first contribution in https://github.com/PlasmaControl/DESC/pull/576
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.9.1...v0.9.2
- Python
Published by f0uriest over 2 years ago
desc-opt - v0.9.1
Deprecations
- Creating an
Objectivewithout specifying theEquilibriumor other object to be optimized is deprecated, and in the future will raise an error.- Passing in an
Equilibriumwhen creating anObjectiveno longer builds the objective immediately. Objective.buildcan now be called without arguments, assuming the object to be optimized was specified when the objective was created.
- Passing in an
- Removes
Equilibrium.solvedattribute as it was generally unused and occasionally caused issues when saving to VMEC format.
New Features
- Adds
deriv_mode="looped"option todesc.objectives.ObjectiveFunctionfor computing derivative matrices. This is slightly slower but much more memory efficient than the default"batched"option. - Adds BFGS option for augmented Lagrangian optimizers.
- Adds utility functions for computing line integrals, vector valued integrals, and
integral transforms in
desc.compute.utils. - Adds
method="monotonic-0"todesc.interpolate.interp1d, which enforces monotonicity and zero slope at the endpoints. - Adds
rhoargument todesc.plotting.plot_boozer_surfaceto specify the desired surface, rather than having to create custom grids. Also adds afieldlinesargument for overlaying magnetic field lines on the Boozer strength plot. - DESC objects with a
change_resolutionmethod now allow changing symmetry type.
Minor Changes
- Augmented Lagrangian methods now use a default starting Lagrange multiplier of 0, rather
than the least squares estimate which can be a bad approximation if the starting point
is far from optimal. The old behavior can be recovered by passing
"initial_multipliers": "least_squares"as part ofoptionswhen callingoptimize. - Enforces periodicity convention for
alphaandtheta_sfl- They are both now defined to be between 0 and 2pi.
Bug Fixes
- Flips sign of current loading/saving VMEC data to account for negative Jacobian.
- Increases default resolution for computing magnetic field harmonics in
desc.plotting.plot_qs_errorto avoid aliasing. - Ensures that
Basis.L,Basis.M,Basis.Nare all integers. - Removes duplicated entries in the
data_index - Fixes a bug in the normalization of the radial unit vector.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.9.0...v0.9.1
- Python
Published by f0uriest over 2 years ago
desc-opt - v0.9.0
New Features
- Implements a new limit API to correctly evaluate a number of quantities at the
coordinate singularity at $\rho=0$ rather than returning NaN. Currently only quantities
related to rotational transform and magnetic field strength are implemented, though in
the future all quantities should evaluate correctly at the magnetic axis. Note that
evaluating quantities at the axis generally requires higher order derivatives and so
can be much more expensive than evaluating at nonsingular points, so during optimization
it is not recommended to include a grid point at the axis. Generally a small finite value
such as
rho = 1e-6will avoid the singuarlity with a negligible loss in accuracy for analytic quantities. - Adds new optimizers
fmin-auglagandlsq-auglagfor performing constrained optimization using the augmented Lagrangian method. These generally perform much better than constrained algorithms from scipy. - Adds interfaces to
trust-constrandSLSQPmethods ofscipy.optimize.minimize. These methods can handle general nonlinear constraints, though their performance on badly scaled problems like those encountered in stellarator optimization isn't great. - Adds calculation of the PEST straight field line coordinate jacobian, which is now
used to check for nestedness in
Equilibrium.is_nested. Previously the non-straight field line jacobian was used, which would not detect if SFL theta contours overlapped. - Introduces a new function/method
Equilibrium.map_coordinateswhich generalizes the existing methodscompute_theta_coordinatesandcompute_flux_coordinates, but allows mapping between arbitrary coordinates. - Adds calculation of $\nabla \mathbf{B}$ tensor and corresponding $L_{\nabla B}$ metric
- Adds objective
BScaleLengthfor penalizing strong magnetic field curvature. - Adds objective
ObjectiveFromUserfor wrapping an arbitary user defined function. - Adds utilities
desc.grid.find_least_rational_surfacesanddesc.grid.find_most_rational_surfacesfor finding the least/most rational surfaces for a given rotational transform profile.
Breaking changes
ObjectiveandObjectiveFunctioncompute methods have now been separated intocompute_unscaledwhich returns the raw physics value of the objective,compute_scaled, which returns the normalized value, andcompute_scaled_errorwhich returns the normalized difference between the physics value and the target/bounds. Similarly,jac_scaledandjac_unscaledare the relevant derivatives (note thatjac_scaledis equivalent tojac_scaled_erroras the constant target drops out).gradandhessmethods still correspond tocompute_scalarwhich returns the sum of squares ofcompute_scaled_error- renames
zeta->phiin many places indesc.plottingto be consistent with when we mean the computational coordinate $\zeta$ vs the physical coordinate $\phi$ - Replaces
nfevwithmaxiterin many places in the code. For most optimizers in scipy and all DESC optimizers, one iteration means one accepted step, which may require more than 1 function evaluation due to line searches or trust region subproblems. However, derivatives are generally only evaluated once per iteration, and are usually the most significant cost, so the iteration count is generally a better proxy for wall time than number of function evaluations.
Minor changes
- Minor updates to work with newer versions of JAX. Minimum
jaxversion is now0.3.2, as some functions used in the constrained optimizers aren't present in previous versions. Maximumjaxversion is now0.4.11, the latest as of 6/13/23. - Adds new
ObjectiveFunctionattributestarget_scaledandbounds_scaledwhich return vectors of the scaled values from each sub-objective. - Adds automatic scaling of variables for
scipy.optimize.minimizemethods, using the hessian at the initial point. - Ensures objectives don't have both bounds and target set at the same time. This occasionally caused issues if one of them had a default value without the user realizing.
- Adds documentation on how to interface with new optimizers.
- Adds a documentation notebook with a simple example of using constrained optimizers
- Adds a table of optimizer info to docs
- Adds capability of
InputReaderto read VMEC files that have inputs spanning multiple lines - Reduces default initial trust region radius for most optimizers to be more conservative.
- Adds a "softmin" option to
PlasmaVesselDistanceobjective which is smoother and usually provides a better optimization landscape compared to the standard hard min.
Bug Fixes
- Fixes orientation of theta in VMEC output. (Previously we flipped theta for the base quantities such as $R$, $Z$, and $\lambda$, but not derived quantities such as $B$ and $J$).
- Fixes VMEC utility bug that would cause
xn,xmto be empty if the Fourier modes given had only sine symmetry. - Fixes bug when VMEC input file has duplicated lines, DESC now will just use the last duplicated line (which is what VMEC does)
New Contributors
- \@pkim1818 made their first contribution in https://github.com/PlasmaControl/DESC/pull/503
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.8.2...v0.9.0
- Python
Published by f0uriest over 2 years ago
desc-opt - v0.8.2
New Features
- New compute functions for derivatives of contravariant metric tensor elements, eg, for Laplace's equation.
- New objective
Isodynamicfor penalizing local radial drifts, not just the bounce average as in QI solve_continuation_automaticnow uses adaptive step sizing for perturbations in the event of a solution becoming unnested.
Minor changes
- Now uses
jnpfor perturbations rather thannpwhich should be significantly faster, especially on GPU - The
fixed_boundaryflag has been removed fromFixBoundaryRandFixBoundaryZconstraints. It is now detected automatically based on the objective and optimizer. - Plotting normalized force error now always uses the gradient of magnetic pressure to normalize, even at finite beta. The old behavior can be recovered by passing
norm_name="<|grad(p)|>_vol"to the relevant plotting function.
Bug Fixes
- Fixed minor bug with symmetric grids that caused end points to be double counted
- Fixed bug causing
NFPof curves to not be updated correctly when the equilibrium changed - Fixed issue when converting
pyQICsolutions toDESCequilibria related to offset toroidal grid
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.8.1...v0.8.2
- Python
Published by f0uriest almost 3 years ago
desc-opt - v0.8.1
Minor Changes
- Include near-axis verification checks in NAE-constrained equilibrium example notebook
Bug Fixes
- Fix read-the-docs build error
- Add missing classes to API docs
- fix error in fix axis util function
- Add missing attributes to new classes added in
v0.8.0
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.8.0...v0.8.1
- Python
Published by dpanici almost 3 years ago
desc-opt - v0.8.0
New Features
- Add profiles for kinetic quantities to
Equilibrium - Add compute functions and objectives for the bootstrap current for stellarators near quasisymmetry.
- Added ability to solve equilibria with the axis held fixed, or by constraining the O(rho) behavior from a near axis expansion.
- New objective for penalizing plasma-vessel distance
- All objectives now have a
boundsargument, and the loss will be zero if within bounds. - Added compute functions for field line quantities such as field line label
alpha, unit vectorb, field line curvaturekappaetc. - Add compute functions for covariant components of current.
Equilibrium.computewill now automatically use the correct grids for surface and volume averages.- Added a number of fields to VMEC output from DESC equilibria.
Minor Changes
- Improved handling of indefinite hessian matrices in
fmintr
Bug Fixes
- Fix issue with composite profiles parsing parameters incorrectly
- Loading an equilibrium from VMEC now uses spline profiles to ensure consistency, as VMEC does not always save the input profile
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.7.2...v0.8.0
- Python
Published by f0uriest almost 3 years ago
desc-opt - v0.7.2
What's Changed
- Fix bug in QS Boozer metric where non-symmetric modes were sometimes counted as symmetric due to different Fourier series conventions.
- Improve speed of functions for converting between VMEC and DESC Fourier representations.
- Add objectives for penalizing strong shaping.
MeanCurvaturetargets values for the mean curvature of the flux surfaces (average of principal curvatures)PrincipalCurvaturepenalizes the largest magnitude of the principal curvatures
- Improve default tolerances when converting input file from VMEC to DESC
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.7.1...v0.7.2
- Python
Published by f0uriest about 3 years ago
desc-opt - v0.7.1
What's Changed
- Allow targets for
RotationalTransformandToroidalCurrentobjectives to be Profile objects rather than just arrays. - Document how to add new compute functions and objectives.
- Add objective for targeting elongation.
- Fix bug in plotqserror causing the same value to be plotted for each value of rho.
- Fix bug sometimes causing the wrong equilibrium to be returned after optimization.
- Improve numerical stability of perturbations and optimization.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.7.0...v0.7.1
- Python
Published by f0uriest about 3 years ago
desc-opt - v0.7.0
New Features
- Add implementation of
Surface.compute_curvature. - Add
return_dataflag to plotting functions to return dictionary of plotted data. - Add computation of beta, average B, surface curvature, magnetic field derivatives, and others. Full list at https://desc-docs.readthedocs.io/en/stable/variables.html
- Modify
Surfaceclasses to always orient surfaces correctly to give the equilibrium a positive Jacobian. This means DESC will always use a right handed coordinate system in both cylindrical and flux coordinates. Previously the orientation of the flux coordinate system would depend on the boundary parameterization. - New utility function
desc.compat.ensure_positive_jacobianfor converting previously saved equilibria to a right handed coordinate system.
Major Changes
- Refactored backend
computefunctions to calculate dependencies recursively. This should make it much easier to add new quantities, and reduces compilation times by 50-70%
Minor Changes
- Refactor wrapping of scipy optimizers.
- Add check for incompatible constraints in optimization.
- Improvements to
plot_1dto correctly plot flux surface average quantities. - Speed up calculation of Boozer transform.
- Have stability objectives print their max, min and average value at end of solve.
Bug Fixes
- Fix issue where if fixing specific boundary modes, the indices used to index the target do not match up with the indices of the A matrix.
- Fix weighting of duplicate nodes for periodic domains.
- Ensure transforms build correctly even with empty grid.
- Ensure transforms always have 0,0,0 derivative.
- Change normalization for poloidal field to avoid having a 0 normalization factor.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.6.4...v0.7.0
- Python
Published by f0uriest about 3 years ago
desc-opt - v0.6.4
Major Changes
- All objectives now have a
normalizeargument that when true will nondimensionalize the physics value and scale to be approximately ~O(1) in magnitude. This should make it easier to tune weights when doing multiobjective optimization. - New objective
RotationalTransformfor targeting a particular iota profile in real space. - New function
plot_boundariesto plot comparisons between boundary shapes.
Minor Changes
- Maximum JAX version is now
0.4.1(latest version as of release date). Minimum version is still0.2.11but this will likely change in the future.
Bug fixes
- Fix indexing bug in biot-savart for coils that caused the output to have the wrong shape
- Fix a bug occasionally preventing the optimizer from restarting correctly after trying a bad step
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.6.3...v0.6.4
- Python
Published by f0uriest about 3 years ago
desc-opt - v0.6.3
Major Changes
- Adds new function desc.continuation.solve_continuation which is a functional interface to the EquilibriaFamily.solve_continuation method
- Adds new function desc.continuation.solve_continuation_automatic which uses conservative default settings in a continuation method for solving complicated equilibria.
- Adds method Objective.xs(eq) for getting needed arguments for an objective. For example, objective.compute(*objective.xs(eq)).
- Adds utility desc.perturbations.get_deltas for finding the differences between surfaces and profiles for perturbations.
Minor Changes
- EquilibriaFamily can now be created with one or more Equilibrium objects, or no arguments to create an empty family
- SplineMagneticField can now interpolate axisymmetric fields more efficiently.
Bug Fixes
- Fix bug preventing lsqtr from terminating when maxiter is zero.
- Fix bug when converting profiles to FourierZernikeProfile.
- Fix bug where a FixBoundary constraint with only 1 mode constrained would throw an error during objective.build
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.6.2...v0.6.3
- Python
Published by f0uriest about 3 years ago
desc-opt - v0.6.2
Minor Changes:
- Remove
parentandchildrenfromEquilibrium- this was generally unused and caused memory leaks in long optimization runs. - Allow targeting current on multiple surfaces with
ToroidalCurrentobjective. - Refactored optimizer backends to get rid of unused code and use more standard BFGS implementation.
- Added
sgdoptimizer for performing fixed step gradient descent, with or without momentum. In the future this will be upgraded to include other step size rules and line searches. - Allow selecting profile when loading VMEC equilibrium, as previously fixed iota was always assumed.
- Ensure equilibrium and surface have same symmetry.
Bug fixes:
- Fix floating point comparison when recovering solution after optimization, occasionally leading to the wrong iteration being returned as "optimal"
- Fix plotting iota of a current-constrained with
plot_1dfunction - Fix bug where having iota specified in an input file along with vacuum objective lead to error. Now specifying vacuum objective will ignore all profile inputs
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.6.1...v0.6.2
- Python
Published by f0uriest over 3 years ago
desc-opt - v0.6.1
New Features
plot_boundaryfunction to plot boundary surfaces and multiple toroidal angles together in a single plot. This is a popular plot format in stellarator optimization papers when comparing boundary shapes. ## Bug Fixes- Fix bugs for vacuum solve
- Allow for constraining arguments that aren't used in the objective (i.e pressure when minimizing current density)
- fix bug in
CurrentDensitywhere only jacobi grid was being used
- Fixes to wrapped objective and jit compiling
- optimizer with wrapped objective would sometimes return the equilibrium after the final attempted step, even if that step was rejected for not lowering the objective, resulting in incorrect "optimal" result
- Fixes a bug where the
use_jitarg passed toobjective.buildwould override any previously set value foruse_jit(such as in the class constructor)
- Grid spacing bugs fixed
- fixed a bug where setting nodes with a linear spaced array versus asking for
Nlinearly spaced nodes would result in different weights despite being the same nodes
- fixed a bug where setting nodes with a linear spaced array versus asking for
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.6.0...v0.6.1
- Python
Published by dpanici over 3 years ago
desc-opt - v0.6.0
Major changes
- Can now solve equilibria with fixed toroidal current, as opposed to fixed rotational transform.
- input file now accepts
cparameter for toroidal current profile (in Amps - note it should be an even polynomial and 0 on axis) Equilibriumnow has attributecurrentwhich can be set to anyProfiletype (orNoneif using rotational transform)- Default
Equilibriumis now fixed zero current rather than zero rotational transform. - For equilibria with both
iotaandcurrentassigned, which to fix should be specified manually by using eitherFixIotaorFixCurrentconstraints - Note that computing
iotafrom fixed current requires flux surface averages, so more oversampling in real space may be required to get correct values.
- input file now accepts
- Near axis interface:
Equilibrium.from_near_axisallows users to load in a solution frompyQSCorpyQIC.FourierRZToroidalSurface.from_near_axisallows users to create boundary surfaces that are approximately QP/QI based on an unpublished analytic model shared by Matt Landreman.
Minor changes
- Plotting:
- Document kwargs, according to matplotlib-style documentation
- Add kwargs to plotting functions missing sensible/useful kwargs
- Add check for unused kwargs to most plotting functions
- Add
norm_Foption toplot_fsa
- Transform:
- Modifies
Transform.fitto use the inverse of the forward method transform method (ie,direct1,direct2,fft) rather than always the full matrix inverse as indirect1 - Removes weighting from
transform.fit, to ensure that the inverse transform is the actual inverse of the forward transform.
- Modifies
- Profiles:
- Add methods and classes for adding, subtracting, multiplying, scaling profiles
- Add class for anisotropic profiles using Fourier-Zernike basis (though the compute functions don't make use of the anisotropy yet)
- Input/Output:
- VMEC input conversion now allows for:
- comma-separated lists of numbers, such as:
AC = 1.0, 0.5, 0.2 - non-stellarator symmetric axis initial guesses using the inputs
RAXIS_CSandZAXIS_CC
- comma-separated lists of numbers, such as:
- Add the Boozer currents
IandGand the Mercier stability fields to VMEC outputs. - Make DESC input file reader agnostic to the case of the input options (i.e.
spectral_indexing=ANSIin the input file will work now and register asansiinternally)
- VMEC input conversion now allows for:
- Misc:
- Allow applying boundary conditions on interior surfaces: Adds a
surface_labelarg toFixBoundaryRandFixBoundaryZ, defaulting to the label of the given surface. That surface is fixed, instead of always the rho=1 surface. - Remove
use_jitfromDerivativeclass in favor ofjiting attributes ofObjectiveFunction - Add
jittoObjectiveFunction.jvp, to hopefully speed up perturbations a bit - Enforce odd number of theta nodes for
ConcentricGrid, to ensure correct flux surface averages - Remove
ConcentricGridrotationoption, as this was generally unused and caused some issues with surface averages.
- Allow applying boundary conditions on interior surfaces: Adds a
Bug fixes
- Fix bug in derivative of abs(
sqrt(g)) (thanks to Matt Landreman for reporting). Affected quantities areV_rr(r),D_well,D_Mercier,magnetic well - Fix a bug with using
Transform.fit()for double Fourier series on multiple surfaces simultaneously. Performing the fit one surface at a time corrects this, but there could be room for speed improvements. - Rescale the Jacobian saved as
gmnc&gmnswhen saving a VMEC output to reflect the VMEC radial coordinate convention ofs = rho^2.
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.5.2...v0.6.0
- Python
Published by f0uriest over 3 years ago
desc-opt - v0.5.2
Major Changes
- New objectives for
MercierStabilityandMagneticWell Change
LinearGridAPI to be more consistent with otherGridclasses:- L, M, N now correspond to the grid spectral resolution, rather than the number of grid points
- rho, theta, zeta can be passed as integers to specify the number of grid points (functionality that used to belong to L, M, N)
- rho, theta, zeta still retain their functionality of specifying coordinate values if they are not integers
- Other code that depends on
LinearGridwas updated accordingly to use the new syntax
Poloidal grid points are now shifted when
sym=Trueto give correct averages over a flux surface.Added default continuation steps to converted VMEC input files
Minor Changes
- add option to
plot_comparisonandplot_surfacesto not plot vartheta contours - Add better warnings for gpu and jax issues
- add volume avg force and pressure gradient to the compute functions
- change
is_nestedfunction to use jacobian sign instead of looking for intersections between surfaces - Allow alternate computation of multi-objective derivatives, computing individual jacobians and blocking together rather than computing all at once.
Bug Fixes
- Fix nfev=1 and Some scalar solver Issues
- Fix some formula errors in second derivatives of certain magnetic field components, caused by some hanging expressions.
- fix bug where node pattern is always jacobi when force is used as objective
- Allow hdf5 to store None attributes correctly
- Fix profile parity and Z axis coefficients in
VMECIO.save - Ensure axis coefficients are updated correctly after solving equilibrium
New Contributors
- @unalmis made their first contribution in https://github.com/PlasmaControl/DESC/pull/247
Full Changelog: https://github.com/PlasmaControl/DESC/compare/v0.5.1...v0.5.2
- Python
Published by f0uriest over 3 years ago
desc-opt - v0.5.1
v0.5.1
Major Changes
- Add ability to change NFP after creation for equilibria, curves, and surfaces.
- Fix rounding errors when building high resolution grids.
- Rename
LambdaGaugeconstraint toFixLambdaGaugefor consistency. - Documentation updates to hdf5 output, VMEC conversion, plotting, etc.
- Change default spectral indexing to "ansi".
- Adds
desc.examples.getto load boundaries, profiles, and full solutions from a number of example equilibria. - Default grid resolution is now 2x spectral resolution.
- New surface method
FourierRZToroidalSurface.from_input_fileto create a surface from boundary coefficients in a DESC or VMEC input file. - Adds new tutorial notebooks demonstrating VMEC io, continuation, plotting, perturbations, optimization etc.
- New documentation on perturbation theory and evaluating Zernike polynomials.
- Fix bug preventing vacuum solutions from solving properly.
- Python
Published by f0uriest over 3 years ago
desc-opt - v0.5.0
v0.5.0
Major Changes
- New API for building objectives and solving/optimizing equilibria. A brief explainer can be found in the documentation
- The
Equilibriumclass no longer "owns" anOptimizerorObjective, and does not build its ownTransforms. - The
ObjectiveFunctionclass is a "super-objective" that combines multiple "sub-objectives" which follow the ABC_Objectiveclass. - Each sub-objective function can be used as either an "objective" (minimized during optimization) or a "constraint" (enforced exactly).
- Each sub-objective function takes unique inputs that can be specified by a grid/surface/etc. or use default values from an
Equilibrium. - Each sub-objective is responsible for building its own transforms or other constant matrices, and is also responsible for computing its own derivatives.
- The super-objective dynamically builds the state vector with the independent variables from each sub-objective, and also combines the function values and derivatives by combining the outputs from each sub-objective.
- The super-objective only takes a single argument (the state vector x or y). Perturbations are now performed wrt the full state vector y, which contains all of the individual parameters.
- Adds ability to optimize physics quantities under equilibrium constraint using wide array of scipy and custom optimizers.
- New objective for solving vacuum equilibria
- Python
Published by f0uriest over 3 years ago
desc-opt - v0.4.13
Major Changes
- Updates JAX dependencies to take advantage of new functionality and faster compile times:
- Minimum
jaxversion is now 0.2.11 - Minimum
jaxlibversion is now 0.1.69 - Pressure and Iota perturbations now weight mode numbers by
L**2 + M**2to avoid high frequency noise. - Custom weighting also allowed by passing
weightsarray toperturbfunctions - Refactor
basis.get_idxto use a lookup table rather thannp.where. This means it works under JIT and AD, but only allows scalar inputs. To get multiple indices, call the method multiple times ConcentricGridnow accepts a rotation argument to rotate the grid for either'sin'or'cos'symmetry, orFalsefor no symmetry. This is independent of thesymargument, which eliminates nodes with theta > pi.- Derivative operators for spline based profile and magnetic field classes are now precomputed, giving roughly 30-40% speedup in evaluation.
Bug Fixes
- Fixed a bug where some properties were not copied correctly when doing
obj.copy(deepcopy=True) - Fixed sign convention on poloidal quantities when saving to VMEC format
- Fixed bugs in
CurveandSurfacethat would fail when setting coefficients in JAX arrays
Testing
- Add tests for Heliotron example
- Adds timing benchmarks for standard equilibrium solves
Examples
- Fix sign convention issue with Heliotron boundary modes to be consistent with VMEC
- Add example for Simsopt QA stellarator from A. Bader et al. 2021
Miscellaneous
- renamed
opsindextoIndexfor consistency with JAX - Move
signfunction fromutilstobackend, as it now needs JAX - lots of minor formatting changes in docstrings
Github Commits <https://github.com/PlasmaControl/DESC/compare/v0.4.12...v0.4.13>_
- Python
Published by f0uriest almost 4 years ago
desc-opt - v0.4.12
New Features:
- New function
plot_comparisonto plot comparison between multiple DESC equilibria plot_surfacesnow has a more intuitive API - instead of specifying grids, the user specifies the specific rho/theta contours to plotequil.is_nestednow checks more toroidal planes for non-axisymmetric equilibria by defaultUpdates
Equilibriumto make creating them more straightforward.- Instead of a dictionary of arrays and values, init method now takes individual arguments. These can either be objects of the correct type (ie
Surfaceobjects for boundary condiitons,Profilefor pressure and iota etc,) or ndarrays which will get parsed into objects of the correct type (for backwards compatibility) - Also introduces more options for generating initial guesses, and a new dedicated method
equilibrium.set_initial_guess(). The default is to scale the boundary surface that is assigned to the equilibrium, but another surface (and axis) can be supplied as an argument to the function to use that surface instead for the initial guess. It also accepts anotherEquilibriuminstance, or a path to a saved DESC or VMEC equilibrium which will be loaded and its flux surfaces will be used as the initial guess. - Command line interface updated to allow for initial guesses from DESC or VMEC solutions using
--guess=path(this also replaces the old--vmecflag)
- Instead of a dictionary of arrays and values, init method now takes individual arguments. These can either be objects of the correct type (ie
Adds classes for representing various types of magnetic fields
- Base class for all magnetic field types defining the
compute_magnetic_fieldAPI and methods for combining fields SplineMagneticFieldfor dealing with mgrid files and splining expensive to compute fieldsScalarPotentialFieldfor vacuum fields that can be written as B=grad(Phi)- basic field types for testing, such as toroidal, poloidal, vertical
- field line integration function for tracing field lines in R,phi,Z, using JAX for differentiability
- Base class for all magnetic field types defining the
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.11
Bug fixes:
- Transforms used in the profile class weren't built by default, causing them to be built when first called which is under jit, meaning they would be recomputed every time instead of caching the transform as expected. Updated to now build transforms by default.
New Features:
- DESC version number is now saved in hdf5 output files as version field.
- Added straight field line method for plotting field line traces from a solved equilibrium.
- A new method has been implemented that uses identities for the zernike polynomials in terms of jacobi polynomials, and a stable iterative evaluation for the jacobi polynomials and binomial coefficients. Accuracy seems on par or better than the old method using extended precision, at least for a given amount of computation time. There is some overhead from JIT compilation, but seems to pay off well for high resolution
- Added new "unique" option for basis.evaluate to first reduce the work by finding unique combos of nodes/modes. Previously this was done inside each basis function evaluation, but doing it on the outside should be more efficient and makes the underlying functions differentiable.
- Refactored fourier series evaluation to shift the arguments for evaluating derivatives rather than using recursion and conditionals.
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.10
Bug Fixes:
- Reordered import statements to ensure user requests to use GPU are handled correctly
New Features:
- Adds several new classes to represent different types/parameterizations of curves and surfaces, for plasma boundaries, coordinate surfaces, coils, magnetic axis etc
- New classes also have several new methods that will be made into objectives in the future, such as area, length, curvature, etc.
- Surfaces can be used as boundary conditions via surface.get_constraint method
- Added new plot method to trace field lines and plot them in real space (R, phi, Z)
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.9
Bug Fixes:
- Fix a major bug in the least squares routine that set the initial regularization parameter to np.nan, meaning that the optimizer would stall as soon as it can no longer take full newton steps.
New Features:
- Adds a Cholesky factorization option for solving the least squares trust region problem. This can be faster, but less numerically stable due to squaring the condition number of the Jacobian. Often still produces good results since the trust region itself regularizes the solution enough to overcome the poor conditioning.
- Methods that take Grid objects now also accept an ndarray of nodes or an integer specifying the number of nodes in each direction.
- Added repr methods for string representations of more objects.
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.8
Bug fixes:
- Fixed array comparison in eq method to return False for differently sized arrays rather than throwing an error
- Misc errors fixed in VMECIO.save()
- Fixed indexing issue with m=0, n=0 modes when transforming FourierSeries basis
- Fixed sign error in computations of MHD energy
Changes: - 2nd-order optimal perturbation capability added - Quasi-symmetry objective functions have been validated against STELLOPT benchmarks - Additional data added to the VMEC-like NetCDF output generated by VMECIO.save() for compatibility with other legacy codes - Added equilibrium methods for calculating cross sectional area, aspect ratio, major and minor radii - Grid weights are now scaled to always sum to 4pi^2 even for symmetric grids so that volume and area will be calculated correctly for symmetric equilibria
Tests:
- Added tests for VMECIO.save()
- Added tests for FourierSeries transform bug
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.7
Bug fixes: - Fixes the magnetic axis initial guess error raised in Issue #92
Tests: - Added a test to check the magnetic axis guess is used properly - Updated the "Dummy Stellarator" parameters, which gets used for several of the tests
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.6
Bug fixes: - Plots of straight field line vartheta contours are now actually of straight field line vartheta, previously they were only approximations.
Backend:
- New method equil.compute_theta_coords finds the geometric angle theta that maps to a given straight field line angle vartheta
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.5
Bug fixes: - Fix bug in pickle IO that prevented objects with jitted attributes from being saved, pickling now only saves essential information.
Changes:
- Added generic load function for loading objects without knowing what class they are
- Removed usage of "==" operator between DESC objects in favor of obj1.eq(obj2). Equivalence is defined as "if saved and loaded, the two objects would be the same," so it ignores equality in trivially recomputeable attributes and focuses on the actual physics of the objects being compared.
- Concentric grids are now up-down symmetric when symmetry is not enforced
Backend:
- Remove objectlib_ from io, instead, now use built in dynamic importing to import the correct classes at runtime
- Avoids needing to import classes in lots of files just so they can be in the objectlib_, makes adding new stuff a lot easier.
- Changed name in io stuff to class to avoid conflicts with actual name attributes
- Python
Published by f0uriest over 4 years ago
desc-opt - v0.4.4
Bug Fixes: -Fixed key error in hdf5io that prevented some solutions from being loaded properly -Updated requirements with correct version of flatbuffers to work with JAX
Documentation -Updated installation instructions -Updated hands on example and other notebooks with recent changes -Fixed bug where docs wouldn't build on RTD
New functionality -Added new method equilibrium.computefluxcoords to find the flux coordinates (rho, theta, zeta) corresponding to a set of real space coordinates (R,phi,Z), useful for computing synthetic diagnostics.
Backend -Added wrappers for more control flow operators, which will be needed for future development -Added interpolation module with 1d, 2d, and 3d interpolation using linear or various cubic splines. These will primarily be needed for planned work on equilibrium reconstruction.
- Python
Published by f0uriest over 4 years ago