desc-v2 1.17.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. desc_v2-1.17.4/LICENSE +21 -0
  2. desc_v2-1.17.4/MANIFEST.in +6 -0
  3. desc_v2-1.17.4/PKG-INFO +190 -0
  4. desc_v2-1.17.4/README.rst +122 -0
  5. desc_v2-1.17.4/desc/__init__.py +191 -0
  6. desc_v2-1.17.4/desc/__main__.py +92 -0
  7. desc_v2-1.17.4/desc/_version.py +21 -0
  8. desc_v2-1.17.4/desc/backend.py +1029 -0
  9. desc_v2-1.17.4/desc/basis.py +2053 -0
  10. desc_v2-1.17.4/desc/batching.py +1000 -0
  11. desc_v2-1.17.4/desc/coils.py +3567 -0
  12. desc_v2-1.17.4/desc/compat.py +468 -0
  13. desc_v2-1.17.4/desc/compute/__init__.py +242 -0
  14. desc_v2-1.17.4/desc/compute/_basis_vectors.py +4351 -0
  15. desc_v2-1.17.4/desc/compute/_bootstrap.py +448 -0
  16. desc_v2-1.17.4/desc/compute/_core.py +3532 -0
  17. desc_v2-1.17.4/desc/compute/_curve.py +1239 -0
  18. desc_v2-1.17.4/desc/compute/_drift.py +138 -0
  19. desc_v2-1.17.4/desc/compute/_equil.py +1152 -0
  20. desc_v2-1.17.4/desc/compute/_fast_ion.py +536 -0
  21. desc_v2-1.17.4/desc/compute/_field.py +3839 -0
  22. desc_v2-1.17.4/desc/compute/_geometry.py +1227 -0
  23. desc_v2-1.17.4/desc/compute/_laplace.py +1145 -0
  24. desc_v2-1.17.4/desc/compute/_metric.py +2740 -0
  25. desc_v2-1.17.4/desc/compute/_neoclassical.py +150 -0
  26. desc_v2-1.17.4/desc/compute/_old.py +281 -0
  27. desc_v2-1.17.4/desc/compute/_omnigenity.py +952 -0
  28. desc_v2-1.17.4/desc/compute/_profiles.py +2045 -0
  29. desc_v2-1.17.4/desc/compute/_stability.py +581 -0
  30. desc_v2-1.17.4/desc/compute/_surface.py +215 -0
  31. desc_v2-1.17.4/desc/compute/_turbulence.py +288 -0
  32. desc_v2-1.17.4/desc/compute/data_index.py +332 -0
  33. desc_v2-1.17.4/desc/compute/utils.py +909 -0
  34. desc_v2-1.17.4/desc/continuation.py +894 -0
  35. desc_v2-1.17.4/desc/derivatives.py +571 -0
  36. desc_v2-1.17.4/desc/equilibrium/__init__.py +3 -0
  37. desc_v2-1.17.4/desc/equilibrium/coords.py +863 -0
  38. desc_v2-1.17.4/desc/equilibrium/equilibrium.py +2926 -0
  39. desc_v2-1.17.4/desc/equilibrium/initial_guess.py +375 -0
  40. desc_v2-1.17.4/desc/equilibrium/utils.py +187 -0
  41. desc_v2-1.17.4/desc/examples/ARIES-CS_output.h5 +0 -0
  42. desc_v2-1.17.4/desc/examples/ATF_output.h5 +0 -0
  43. desc_v2-1.17.4/desc/examples/DSHAPE_CURRENT_output.h5 +0 -0
  44. desc_v2-1.17.4/desc/examples/DSHAPE_output.h5 +0 -0
  45. desc_v2-1.17.4/desc/examples/ESTELL_output.h5 +0 -0
  46. desc_v2-1.17.4/desc/examples/HELIOTRON_output.h5 +0 -0
  47. desc_v2-1.17.4/desc/examples/HSX_output.h5 +0 -0
  48. desc_v2-1.17.4/desc/examples/NCSX_output.h5 +0 -0
  49. desc_v2-1.17.4/desc/examples/SOLOVEV_output.h5 +0 -0
  50. desc_v2-1.17.4/desc/examples/W7-X_output.h5 +0 -0
  51. desc_v2-1.17.4/desc/examples/WISTELL-A_output.h5 +0 -0
  52. desc_v2-1.17.4/desc/examples/__init__.py +72 -0
  53. desc_v2-1.17.4/desc/examples/precise_QA.py +117 -0
  54. desc_v2-1.17.4/desc/examples/precise_QA_output.h5 +0 -0
  55. desc_v2-1.17.4/desc/examples/precise_QH.py +91 -0
  56. desc_v2-1.17.4/desc/examples/precise_QH_output.h5 +0 -0
  57. desc_v2-1.17.4/desc/examples/reactor_QA.py +92 -0
  58. desc_v2-1.17.4/desc/examples/reactor_QA_output.h5 +0 -0
  59. desc_v2-1.17.4/desc/examples/regenerate_all_equilibria.py +73 -0
  60. desc_v2-1.17.4/desc/external/__init__.py +1 -0
  61. desc_v2-1.17.4/desc/external/neo.py +144 -0
  62. desc_v2-1.17.4/desc/external/paraview.py +220 -0
  63. desc_v2-1.17.4/desc/external/terpsichore.py +943 -0
  64. desc_v2-1.17.4/desc/geometry/__init__.py +11 -0
  65. desc_v2-1.17.4/desc/geometry/core.py +631 -0
  66. desc_v2-1.17.4/desc/geometry/curve.py +1690 -0
  67. desc_v2-1.17.4/desc/geometry/surface.py +1311 -0
  68. desc_v2-1.17.4/desc/grid.py +2150 -0
  69. desc_v2-1.17.4/desc/input_reader.py +1701 -0
  70. desc_v2-1.17.4/desc/integrals/__init__.py +24 -0
  71. desc_v2-1.17.4/desc/integrals/_ae_plot.py +596 -0
  72. desc_v2-1.17.4/desc/integrals/_bounce_utils.py +1151 -0
  73. desc_v2-1.17.4/desc/integrals/_interp_utils.py +578 -0
  74. desc_v2-1.17.4/desc/integrals/bounce_integral.py +2208 -0
  75. desc_v2-1.17.4/desc/integrals/quad_utils.py +775 -0
  76. desc_v2-1.17.4/desc/integrals/singularities.py +1073 -0
  77. desc_v2-1.17.4/desc/integrals/surface_integral.py +741 -0
  78. desc_v2-1.17.4/desc/interpolate.py +22 -0
  79. desc_v2-1.17.4/desc/io/__init__.py +14 -0
  80. desc_v2-1.17.4/desc/io/ascii_io.py +253 -0
  81. desc_v2-1.17.4/desc/io/core_io.py +101 -0
  82. desc_v2-1.17.4/desc/io/hdf5_io.py +428 -0
  83. desc_v2-1.17.4/desc/io/optimizable_io.py +381 -0
  84. desc_v2-1.17.4/desc/io/pickle_io.py +130 -0
  85. desc_v2-1.17.4/desc/magnetic_fields/__init__.py +26 -0
  86. desc_v2-1.17.4/desc/magnetic_fields/_core.py +3214 -0
  87. desc_v2-1.17.4/desc/magnetic_fields/_current_potential.py +2081 -0
  88. desc_v2-1.17.4/desc/magnetic_fields/_dommaschk.py +567 -0
  89. desc_v2-1.17.4/desc/magnetic_fields/_laplace.py +406 -0
  90. desc_v2-1.17.4/desc/nestor.py +1218 -0
  91. desc_v2-1.17.4/desc/objectives/__init__.py +109 -0
  92. desc_v2-1.17.4/desc/objectives/_bootstrap.py +300 -0
  93. desc_v2-1.17.4/desc/objectives/_coils.py +2850 -0
  94. desc_v2-1.17.4/desc/objectives/_equilibrium.py +865 -0
  95. desc_v2-1.17.4/desc/objectives/_fast_ion.py +365 -0
  96. desc_v2-1.17.4/desc/objectives/_free_boundary.py +1569 -0
  97. desc_v2-1.17.4/desc/objectives/_generic.py +1017 -0
  98. desc_v2-1.17.4/desc/objectives/_geometry.py +1506 -0
  99. desc_v2-1.17.4/desc/objectives/_neoclassical.py +158 -0
  100. desc_v2-1.17.4/desc/objectives/_omnigenity.py +973 -0
  101. desc_v2-1.17.4/desc/objectives/_power_balance.py +341 -0
  102. desc_v2-1.17.4/desc/objectives/_profiles.py +593 -0
  103. desc_v2-1.17.4/desc/objectives/_stability.py +585 -0
  104. desc_v2-1.17.4/desc/objectives/_turbulence.py +188 -0
  105. desc_v2-1.17.4/desc/objectives/getters.py +371 -0
  106. desc_v2-1.17.4/desc/objectives/linear_objectives.py +3845 -0
  107. desc_v2-1.17.4/desc/objectives/nae_utils.py +885 -0
  108. desc_v2-1.17.4/desc/objectives/normalization.py +111 -0
  109. desc_v2-1.17.4/desc/objectives/objective_funs.py +2011 -0
  110. desc_v2-1.17.4/desc/objectives/utils.py +495 -0
  111. desc_v2-1.17.4/desc/optimizable.py +290 -0
  112. desc_v2-1.17.4/desc/optimize/__init__.py +10 -0
  113. desc_v2-1.17.4/desc/optimize/_constraint_wrappers.py +1391 -0
  114. desc_v2-1.17.4/desc/optimize/_desc_wrappers.py +499 -0
  115. desc_v2-1.17.4/desc/optimize/_scipy_wrappers.py +840 -0
  116. desc_v2-1.17.4/desc/optimize/aug_lagrangian.py +693 -0
  117. desc_v2-1.17.4/desc/optimize/aug_lagrangian_ls.py +641 -0
  118. desc_v2-1.17.4/desc/optimize/bound_utils.py +433 -0
  119. desc_v2-1.17.4/desc/optimize/fmin_scalar.py +510 -0
  120. desc_v2-1.17.4/desc/optimize/least_squares.py +486 -0
  121. desc_v2-1.17.4/desc/optimize/optimizer.py +906 -0
  122. desc_v2-1.17.4/desc/optimize/stochastic.py +319 -0
  123. desc_v2-1.17.4/desc/optimize/tr_subproblems.py +549 -0
  124. desc_v2-1.17.4/desc/optimize/utils.py +553 -0
  125. desc_v2-1.17.4/desc/particles.py +1238 -0
  126. desc_v2-1.17.4/desc/perturbations.py +829 -0
  127. desc_v2-1.17.4/desc/plotting.py +4802 -0
  128. desc_v2-1.17.4/desc/profiles.py +1551 -0
  129. desc_v2-1.17.4/desc/random.py +197 -0
  130. desc_v2-1.17.4/desc/transform.py +759 -0
  131. desc_v2-1.17.4/desc/utils.py +1232 -0
  132. desc_v2-1.17.4/desc/vmec.py +2037 -0
  133. desc_v2-1.17.4/desc/vmec_utils.py +948 -0
  134. desc_v2-1.17.4/desc_v2.egg-info/PKG-INFO +190 -0
  135. desc_v2-1.17.4/desc_v2.egg-info/SOURCES.txt +180 -0
  136. desc_v2-1.17.4/desc_v2.egg-info/dependency_links.txt +1 -0
  137. desc_v2-1.17.4/desc_v2.egg-info/entry_points.txt +2 -0
  138. desc_v2-1.17.4/desc_v2.egg-info/requires.txt +24 -0
  139. desc_v2-1.17.4/desc_v2.egg-info/top_level.txt +1 -0
  140. desc_v2-1.17.4/pyproject.toml +5 -0
  141. desc_v2-1.17.4/requirements.txt +24 -0
  142. desc_v2-1.17.4/setup.cfg +82 -0
  143. desc_v2-1.17.4/setup.py +61 -0
  144. desc_v2-1.17.4/tests/test_available_energy.py +99 -0
  145. desc_v2-1.17.4/tests/test_axis_limits.py +431 -0
  146. desc_v2-1.17.4/tests/test_backend.py +278 -0
  147. desc_v2-1.17.4/tests/test_basis.py +463 -0
  148. desc_v2-1.17.4/tests/test_bootstrap.py +1651 -0
  149. desc_v2-1.17.4/tests/test_coils.py +1617 -0
  150. desc_v2-1.17.4/tests/test_compat.py +438 -0
  151. desc_v2-1.17.4/tests/test_compute_everything.py +397 -0
  152. desc_v2-1.17.4/tests/test_compute_funs.py +2091 -0
  153. desc_v2-1.17.4/tests/test_compute_utils.py +20 -0
  154. desc_v2-1.17.4/tests/test_configuration.py +609 -0
  155. desc_v2-1.17.4/tests/test_constrain_current.py +199 -0
  156. desc_v2-1.17.4/tests/test_curves.py +1272 -0
  157. desc_v2-1.17.4/tests/test_data_index.py +152 -0
  158. desc_v2-1.17.4/tests/test_derivatives.py +491 -0
  159. desc_v2-1.17.4/tests/test_equilibrium.py +495 -0
  160. desc_v2-1.17.4/tests/test_examples.py +2769 -0
  161. desc_v2-1.17.4/tests/test_geometry.py +38 -0
  162. desc_v2-1.17.4/tests/test_grid.py +960 -0
  163. desc_v2-1.17.4/tests/test_input_output.py +823 -0
  164. desc_v2-1.17.4/tests/test_integrals.py +2333 -0
  165. desc_v2-1.17.4/tests/test_interp_utils.py +361 -0
  166. desc_v2-1.17.4/tests/test_linear_objectives.py +1237 -0
  167. desc_v2-1.17.4/tests/test_magnetic_fields.py +1829 -0
  168. desc_v2-1.17.4/tests/test_objective_funs.py +5001 -0
  169. desc_v2-1.17.4/tests/test_optimizer.py +2037 -0
  170. desc_v2-1.17.4/tests/test_particles.py +469 -0
  171. desc_v2-1.17.4/tests/test_perturbations.py +245 -0
  172. desc_v2-1.17.4/tests/test_plotting.py +1221 -0
  173. desc_v2-1.17.4/tests/test_profiles.py +594 -0
  174. desc_v2-1.17.4/tests/test_quad_utils.py +253 -0
  175. desc_v2-1.17.4/tests/test_random.py +78 -0
  176. desc_v2-1.17.4/tests/test_stability_funs.py +856 -0
  177. desc_v2-1.17.4/tests/test_surfaces.py +586 -0
  178. desc_v2-1.17.4/tests/test_transform.py +663 -0
  179. desc_v2-1.17.4/tests/test_utils.py +262 -0
  180. desc_v2-1.17.4/tests/test_vmec.py +1699 -0
  181. desc_v2-1.17.4/versioneer.py +1880 -0
desc_v2-1.17.4/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Daniel Dudt, Rory Conlin, Dario Panici, Kaya Unalmis, Yigit Gunsur Elmacioglu, Rahul Gaur, Patrick Kim, Egemen Kolemen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ include versioneer.py
2
+ include desc/_version.py
3
+ include desc/examples/*.h5
4
+
5
+ include LICENSE README.rst pyproject.toml setup.py setup.cfg requirements.txt
6
+ global-exclude __pycache__ *.py[cod] .venv
@@ -0,0 +1,190 @@
1
+ Metadata-Version: 2.4
2
+ Name: desc-v2
3
+ Version: 1.17.4
4
+ Summary: Computes, analyzes and optimizes 3D MHD equilibria for stellarators and tokamaks
5
+ Home-page: https://github.com/unalmis/DESC/
6
+ Author: Kaya Unalmis
7
+ Author-email: kunalmis@stanford.edu
8
+ License: MIT
9
+ Project-URL: Issues Tracker, https://github.com/unalmis/DESC/issues
10
+ Project-URL: Contributing, https://github.com/unalmis/DESC/blob/master/CONTRIBUTING.rst
11
+ Project-URL: Source Code, https://github.com/unalmis/DESC
12
+ Project-URL: Documentation, https://unalmis.github.io/DESC/
13
+ Keywords: stellarator tokamak equilibrium perturbation mhd magnetohydrodynamics stability confinement plasma physics optimization design fusion
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Natural Language :: English
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
24
+ Classifier: Topic :: Scientific/Engineering
25
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
26
+ Classifier: Topic :: Scientific/Engineering :: Physics
27
+ Classifier: Topic :: Scientific/Engineering :: Visualization
28
+ Requires-Python: >=3.10
29
+ Description-Content-Type: text/x-rst
30
+ License-File: LICENSE
31
+ Requires-Dist: jax!=0.7.1,<0.10.0,>=0.6.2
32
+ Requires-Dist: colorama<=0.4.6
33
+ Requires-Dist: diffrax<=0.7.2,>=0.6.0
34
+ Requires-Dist: equinox<=0.13.8,>=0.11.10
35
+ Requires-Dist: h5py<=3.16.0,>=3.0.0
36
+ Requires-Dist: interpax<0.4,>=0.3.3
37
+ Requires-Dist: interpax_fft<=0.0.9,>=0.0.9
38
+ Requires-Dist: lineax
39
+ Requires-Dist: jax-finufft<=1.3.1,>=1.1.0
40
+ Requires-Dist: matplotlib<=3.10.8,>=3.7.3
41
+ Requires-Dist: mpmath<=1.4.1,>=1.0.0
42
+ Requires-Dist: netcdf4!=1.7.4,<=1.7.5,>=1.5.4
43
+ Requires-Dist: numpy<=2.5,>=1.20.0
44
+ Requires-Dist: nvidia-ml-py>=12.535.77
45
+ Requires-Dist: optax<0.3
46
+ Requires-Dist: orthax<0.3,>=0.2.7
47
+ Requires-Dist: plotly<=6.7.0,>=5.16
48
+ Requires-Dist: psutil<=7.2.2
49
+ Requires-Dist: pylatexenc<=2.10,>=2.0
50
+ Requires-Dist: quadax<0.3,>=0.2.2
51
+ Requires-Dist: scikit-image<=0.26.0
52
+ Requires-Dist: scipy<=1.17.1,>=1.7.0
53
+ Requires-Dist: sympy
54
+ Requires-Dist: termcolor<=3.3.0
55
+ Dynamic: author
56
+ Dynamic: author-email
57
+ Dynamic: classifier
58
+ Dynamic: description
59
+ Dynamic: description-content-type
60
+ Dynamic: home-page
61
+ Dynamic: keywords
62
+ Dynamic: license
63
+ Dynamic: license-file
64
+ Dynamic: project-url
65
+ Dynamic: requires-dist
66
+ Dynamic: requires-python
67
+ Dynamic: summary
68
+
69
+ .. image:: https://raw.githubusercontent.com/unalmis/DESC/master/docs/_static/images/logo_med_clear.png
70
+
71
+ .. inclusion-marker-do-not-remove
72
+
73
+ ################################
74
+ Stellarator Optimization Package
75
+ ################################
76
+ |License| |DOI| |Issues| |Pypi|
77
+
78
+ |Docs| |UnitTests| |RegressionTests|
79
+
80
+ Improvements
81
+ ============
82
+ Like the original package, but with bounce integrals as well as all the improvements
83
+ in `this fork <https://github.com/unalmis/DESC>`__.
84
+
85
+ A list of papers which feature DESC can be found here_.
86
+
87
+ .. _Theory: https://unalmis.github.io/DESC/theory_general.html
88
+ .. _here: https://unalmis.github.io/DESC/pubs_list.html
89
+
90
+
91
+ Quick Start
92
+ ===========
93
+
94
+ The easiest way to install DESC is from PyPI: ``pip install desc-v2``
95
+
96
+ For more detailed instructions on installing DESC and its dependencies, see Installation_.
97
+
98
+ The best place to start learning about DESC is our tutorials:
99
+
100
+ - `Basic fixed boundary equilibrium`_: running from a VMEC input, creating an equilibrium from scratch
101
+ - `Advanced equilibrium`_: continuation and perturbation methods.
102
+ - `Free boundary equilibrium`_: vacuum and or finite beta with external field.
103
+ - `Using DESC outputs`_: analysis, plotting, saving to VMEC format.
104
+ - `Basic optimization`_: specifying objectives, fixing degrees of freedom.
105
+ - `Advanced optimization`_: advanced constraints, precise quasi-symmetry, constrained optimization.
106
+ - `Near axis constraints`_: loading solutions from QSC/QIC and fixing near axis expansion.
107
+ - `Coil optimization`_: "second stage" optimization of magnetic coils.
108
+
109
+ For details on the various objectives, constraints, optimizable objects and more, see
110
+ the full `api documentation`_.
111
+
112
+ If all you need is an equilibrium solution, the simplest method is through the command
113
+ line by giving an input file specifying the equilibrium and solver options, this
114
+ way can also can also accept VMEC input files.
115
+
116
+ The code is run using the syntax ``desc <path/to/inputfile>`` and the full list
117
+ of command line options are given in `Command Line Interface`_. (Note that you may have
118
+ to prepend the command with ``python -m``)
119
+
120
+ Refer to `Inputs`_ for documentation on how to format the input file.
121
+
122
+ The equilibrium solution is output in a HDF5 binary file, whose format is detailed in `Outputs`_.
123
+
124
+ .. _Installation: https://unalmis.github.io/DESC/installation.html
125
+ .. _Command Line Interface: https://unalmis.github.io/DESC/command_line.html
126
+ .. _Inputs: https://unalmis.github.io/DESC/input.html
127
+ .. _Outputs: https://unalmis.github.io/DESC/output.html
128
+ .. _Basic fixed boundary equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/basic_equilibrium.html
129
+ .. _Advanced equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/advanced_equilibrium_continuation.html
130
+ .. _Free boundary equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/free_boundary_equilibrium.html
131
+ .. _Using DESC outputs: https://unalmis.github.io/DESC/notebooks/tutorials/use_outputs.html
132
+ .. _Basic optimization: https://unalmis.github.io/DESC/notebooks/tutorials/basic_optimization.html
133
+ .. _Advanced optimization: https://unalmis.github.io/DESC/notebooks/tutorials/advanced_optimization.html
134
+ .. _Near axis constraints: https://unalmis.github.io/DESC/notebooks/tutorials/nae_constraint.html
135
+ .. _Coil optimization: https://unalmis.github.io/DESC/notebooks/tutorials/coil_stage_two_optimization.html
136
+ .. _api documentation: https://unalmis.github.io/DESC/api.html
137
+
138
+ Repository Contents
139
+ ===================
140
+
141
+ - desc_ contains the source code including the main script and supplemental files. Refer to the API_ documentation for details on all of the available functions and classes.
142
+ - docs_ contains the documentation files.
143
+ - tests_ contains routines for automatic testing.
144
+ - publications_ contains PDFs of publications by the DESC group, as well as scripts and data to reproduce the results of these papers.
145
+
146
+ .. _desc: https://github.com/unalmis/DESC/tree/master/desc
147
+ .. _docs: https://github.com/unalmis/DESC/tree/master/docs
148
+ .. _tests: https://github.com/unalmis/DESC/tree/master/tests
149
+ .. _publications: https://github.com/unalmis/DESC/tree/master/publications
150
+ .. _API: https://unalmis.github.io/DESC/api.html
151
+
152
+ Contribute
153
+ ==========
154
+
155
+ - `Contributing guidelines <https://github.com/unalmis/DESC/blob/master/CONTRIBUTING.rst>`_
156
+ - `Issue Tracker <https://github.com/unalmis/DESC/issues>`_
157
+ - `Source Code <https://github.com/unalmis/DESC/>`_
158
+ - `Documentation <https://unalmis.github.io/DESC/>`_
159
+
160
+ .. |License| image:: https://img.shields.io/github/license/unalmis/DESC?color=blue&logo=open-source-initiative&logoColor=white
161
+ :target: https://github.com/unalmis/DESC/blob/master/LICENSE
162
+ :alt: License
163
+
164
+ .. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4876504.svg
165
+ :target: https://doi.org/10.5281/zenodo.4876504
166
+ :alt: DOI
167
+
168
+ .. |Docs| image:: https://github.com/unalmis/DESC/actions/workflows/docs.yml/badge.svg
169
+ :target: https://unalmis.github.io/DESC/
170
+ :alt: Documentation
171
+
172
+ .. |UnitTests| image:: https://github.com/unalmis/DESC/actions/workflows/unit_tests.yml/badge.svg
173
+ :target: https://github.com/unalmis/DESC/actions/workflows/unit_tests.yml
174
+ :alt: UnitTests
175
+
176
+ .. |RegressionTests| image:: https://github.com/unalmis/DESC/actions/workflows/regression_tests.yml/badge.svg
177
+ :target: https://github.com/unalmis/DESC/actions/workflows/regression_tests.yml
178
+ :alt: RegressionTests
179
+
180
+ .. |Codecov| image:: https://codecov.io/gh/unalmis/DESC/branch/master/graph/badge.svg
181
+ :target: https://codecov.io/gh/unalmis/DESC
182
+ :alt: Coverage
183
+
184
+ .. |Issues| image:: https://img.shields.io/github/issues/unalmis/DESC
185
+ :target: https://github.com/unalmis/DESC/issues
186
+ :alt: GitHub issues
187
+
188
+ .. |Pypi| image:: https://img.shields.io/pypi/v/desc-v2
189
+ :target: https://pypi.org/project/desc-v2/
190
+ :alt: Pypi
@@ -0,0 +1,122 @@
1
+ .. image:: https://raw.githubusercontent.com/unalmis/DESC/master/docs/_static/images/logo_med_clear.png
2
+
3
+ .. inclusion-marker-do-not-remove
4
+
5
+ ################################
6
+ Stellarator Optimization Package
7
+ ################################
8
+ |License| |DOI| |Issues| |Pypi|
9
+
10
+ |Docs| |UnitTests| |RegressionTests|
11
+
12
+ Improvements
13
+ ============
14
+ Like the original package, but with bounce integrals as well as all the improvements
15
+ in `this fork <https://github.com/unalmis/DESC>`__.
16
+
17
+ A list of papers which feature DESC can be found here_.
18
+
19
+ .. _Theory: https://unalmis.github.io/DESC/theory_general.html
20
+ .. _here: https://unalmis.github.io/DESC/pubs_list.html
21
+
22
+
23
+ Quick Start
24
+ ===========
25
+
26
+ The easiest way to install DESC is from PyPI: ``pip install desc-v2``
27
+
28
+ For more detailed instructions on installing DESC and its dependencies, see Installation_.
29
+
30
+ The best place to start learning about DESC is our tutorials:
31
+
32
+ - `Basic fixed boundary equilibrium`_: running from a VMEC input, creating an equilibrium from scratch
33
+ - `Advanced equilibrium`_: continuation and perturbation methods.
34
+ - `Free boundary equilibrium`_: vacuum and or finite beta with external field.
35
+ - `Using DESC outputs`_: analysis, plotting, saving to VMEC format.
36
+ - `Basic optimization`_: specifying objectives, fixing degrees of freedom.
37
+ - `Advanced optimization`_: advanced constraints, precise quasi-symmetry, constrained optimization.
38
+ - `Near axis constraints`_: loading solutions from QSC/QIC and fixing near axis expansion.
39
+ - `Coil optimization`_: "second stage" optimization of magnetic coils.
40
+
41
+ For details on the various objectives, constraints, optimizable objects and more, see
42
+ the full `api documentation`_.
43
+
44
+ If all you need is an equilibrium solution, the simplest method is through the command
45
+ line by giving an input file specifying the equilibrium and solver options, this
46
+ way can also can also accept VMEC input files.
47
+
48
+ The code is run using the syntax ``desc <path/to/inputfile>`` and the full list
49
+ of command line options are given in `Command Line Interface`_. (Note that you may have
50
+ to prepend the command with ``python -m``)
51
+
52
+ Refer to `Inputs`_ for documentation on how to format the input file.
53
+
54
+ The equilibrium solution is output in a HDF5 binary file, whose format is detailed in `Outputs`_.
55
+
56
+ .. _Installation: https://unalmis.github.io/DESC/installation.html
57
+ .. _Command Line Interface: https://unalmis.github.io/DESC/command_line.html
58
+ .. _Inputs: https://unalmis.github.io/DESC/input.html
59
+ .. _Outputs: https://unalmis.github.io/DESC/output.html
60
+ .. _Basic fixed boundary equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/basic_equilibrium.html
61
+ .. _Advanced equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/advanced_equilibrium_continuation.html
62
+ .. _Free boundary equilibrium: https://unalmis.github.io/DESC/notebooks/tutorials/free_boundary_equilibrium.html
63
+ .. _Using DESC outputs: https://unalmis.github.io/DESC/notebooks/tutorials/use_outputs.html
64
+ .. _Basic optimization: https://unalmis.github.io/DESC/notebooks/tutorials/basic_optimization.html
65
+ .. _Advanced optimization: https://unalmis.github.io/DESC/notebooks/tutorials/advanced_optimization.html
66
+ .. _Near axis constraints: https://unalmis.github.io/DESC/notebooks/tutorials/nae_constraint.html
67
+ .. _Coil optimization: https://unalmis.github.io/DESC/notebooks/tutorials/coil_stage_two_optimization.html
68
+ .. _api documentation: https://unalmis.github.io/DESC/api.html
69
+
70
+ Repository Contents
71
+ ===================
72
+
73
+ - desc_ contains the source code including the main script and supplemental files. Refer to the API_ documentation for details on all of the available functions and classes.
74
+ - docs_ contains the documentation files.
75
+ - tests_ contains routines for automatic testing.
76
+ - publications_ contains PDFs of publications by the DESC group, as well as scripts and data to reproduce the results of these papers.
77
+
78
+ .. _desc: https://github.com/unalmis/DESC/tree/master/desc
79
+ .. _docs: https://github.com/unalmis/DESC/tree/master/docs
80
+ .. _tests: https://github.com/unalmis/DESC/tree/master/tests
81
+ .. _publications: https://github.com/unalmis/DESC/tree/master/publications
82
+ .. _API: https://unalmis.github.io/DESC/api.html
83
+
84
+ Contribute
85
+ ==========
86
+
87
+ - `Contributing guidelines <https://github.com/unalmis/DESC/blob/master/CONTRIBUTING.rst>`_
88
+ - `Issue Tracker <https://github.com/unalmis/DESC/issues>`_
89
+ - `Source Code <https://github.com/unalmis/DESC/>`_
90
+ - `Documentation <https://unalmis.github.io/DESC/>`_
91
+
92
+ .. |License| image:: https://img.shields.io/github/license/unalmis/DESC?color=blue&logo=open-source-initiative&logoColor=white
93
+ :target: https://github.com/unalmis/DESC/blob/master/LICENSE
94
+ :alt: License
95
+
96
+ .. |DOI| image:: https://zenodo.org/badge/DOI/10.5281/zenodo.4876504.svg
97
+ :target: https://doi.org/10.5281/zenodo.4876504
98
+ :alt: DOI
99
+
100
+ .. |Docs| image:: https://github.com/unalmis/DESC/actions/workflows/docs.yml/badge.svg
101
+ :target: https://unalmis.github.io/DESC/
102
+ :alt: Documentation
103
+
104
+ .. |UnitTests| image:: https://github.com/unalmis/DESC/actions/workflows/unit_tests.yml/badge.svg
105
+ :target: https://github.com/unalmis/DESC/actions/workflows/unit_tests.yml
106
+ :alt: UnitTests
107
+
108
+ .. |RegressionTests| image:: https://github.com/unalmis/DESC/actions/workflows/regression_tests.yml/badge.svg
109
+ :target: https://github.com/unalmis/DESC/actions/workflows/regression_tests.yml
110
+ :alt: RegressionTests
111
+
112
+ .. |Codecov| image:: https://codecov.io/gh/unalmis/DESC/branch/master/graph/badge.svg
113
+ :target: https://codecov.io/gh/unalmis/DESC
114
+ :alt: Coverage
115
+
116
+ .. |Issues| image:: https://img.shields.io/github/issues/unalmis/DESC
117
+ :target: https://github.com/unalmis/DESC/issues
118
+ :alt: GitHub issues
119
+
120
+ .. |Pypi| image:: https://img.shields.io/pypi/v/desc-v2
121
+ :target: https://pypi.org/project/desc-v2/
122
+ :alt: Pypi
@@ -0,0 +1,191 @@
1
+ """DESC: a 3D MHD equilibrium solver and stellarator optimization suite."""
2
+
3
+ import importlib
4
+ import os
5
+ import re
6
+ import warnings
7
+
8
+ import colorama
9
+ from termcolor import colored
10
+
11
+ from ._version import get_versions
12
+
13
+ __version__ = get_versions()["version"]
14
+ del get_versions
15
+
16
+ colorama.init()
17
+
18
+
19
+ __all__ = [
20
+ "basis",
21
+ "coils",
22
+ "compute",
23
+ "continuation",
24
+ "derivatives",
25
+ "equilibrium",
26
+ "examples",
27
+ "geometry",
28
+ "grid",
29
+ "io",
30
+ "magnetic_fields",
31
+ "objectives",
32
+ "optimize",
33
+ "particles",
34
+ "perturbations",
35
+ "plotting",
36
+ "profiles",
37
+ "random",
38
+ "transform",
39
+ "vmec",
40
+ ]
41
+
42
+
43
+ def __getattr__(name):
44
+ if name in __all__:
45
+ return importlib.import_module("." + name, __name__)
46
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
47
+
48
+
49
+ _BANNER = r"""
50
+ ____ ____ _____ ___
51
+ | _ \| ___|/ ___|/ ___|
52
+ | | \ | |_ | (__ | |
53
+ | | | | _| \___ \| |
54
+ | |_/ | |__ ___) | |___
55
+ |____/|____||____/ \____|
56
+
57
+ """
58
+
59
+ BANNER = colored(_BANNER, "magenta")
60
+
61
+
62
+ config = {"device": None, "avail_mem": None, "kind": None}
63
+
64
+
65
+ def set_device(kind="cpu", gpuid=None):
66
+ """Sets the device to use for computation.
67
+
68
+ If kind==``'gpu'`` and a gpuid is specified, uses the specified GPU. If
69
+ gpuid==``None`` or a wrong GPU id is given, checks available GPUs and selects the
70
+ one with the most available memory.
71
+ Respects environment variable CUDA_VISIBLE_DEVICES for selecting from multiple
72
+ available GPUs
73
+
74
+ Parameters
75
+ ----------
76
+ kind : {``'cpu'``, ``'gpu'``}
77
+ whether to use CPU or GPU.
78
+
79
+ """
80
+ config["kind"] = kind
81
+ if kind == "cpu":
82
+ os.environ["JAX_PLATFORMS"] = "cpu"
83
+ os.environ["CUDA_VISIBLE_DEVICES"] = ""
84
+ import psutil
85
+
86
+ cpu_mem = psutil.virtual_memory().available / 1024**3 # RAM in GB
87
+ config["device"] = "CPU"
88
+ config["avail_mem"] = cpu_mem
89
+
90
+ if kind == "gpu":
91
+ # Set CUDA_DEVICE_ORDER so the IDs assigned by CUDA match those from nvidia-smi
92
+ os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
93
+ # pynvml namespace is exposed through nvidia-ml-py
94
+ from pynvml import (
95
+ nvmlDeviceGetCount,
96
+ nvmlDeviceGetHandleByIndex,
97
+ nvmlDeviceGetMemoryInfo,
98
+ nvmlDeviceGetName,
99
+ nvmlDeviceGetUUID,
100
+ nvmlInit,
101
+ nvmlMemory_v2,
102
+ nvmlShutdown,
103
+ )
104
+
105
+ def _gpu_info():
106
+ """Equivalent to nvgpu.gpu_info() using nvidia-ml-py."""
107
+ nvmlInit()
108
+ try:
109
+ info = []
110
+ for device_idx in range(nvmlDeviceGetCount()):
111
+ handle = nvmlDeviceGetHandleByIndex(device_idx)
112
+ # Use nvmlMemory_v2 to account for system-reserved memory
113
+ mem = nvmlDeviceGetMemoryInfo(handle, version=nvmlMemory_v2)
114
+ _bytes_to_mib = 1024 * 1024
115
+ mem_used = mem.used // _bytes_to_mib
116
+ mem_total = mem.total // _bytes_to_mib
117
+ info.append(
118
+ {
119
+ "index": str(device_idx),
120
+ "type": nvmlDeviceGetName(handle),
121
+ "uuid": nvmlDeviceGetUUID(handle),
122
+ "mem_used": mem_used,
123
+ "mem_total": mem_total,
124
+ "mem_used_percent": 100.0 * mem_used / mem_total,
125
+ }
126
+ )
127
+ return info
128
+ finally:
129
+ nvmlShutdown()
130
+
131
+ try:
132
+ devices = _gpu_info()
133
+ except FileNotFoundError:
134
+ devices = []
135
+ if len(devices) == 0:
136
+ warnings.warn(colored("No GPU found, falling back to CPU", "yellow"))
137
+ set_device(kind="cpu")
138
+ return
139
+
140
+ maxmem = 0
141
+ selected_gpu = None
142
+ gpu_ids = [dev["index"] for dev in devices]
143
+ if "CUDA_VISIBLE_DEVICES" in os.environ:
144
+ cuda_ids = [
145
+ s for s in re.findall(r"\b\d+\b", os.environ["CUDA_VISIBLE_DEVICES"])
146
+ ]
147
+ # check that the visible devices actually exist and are gpus
148
+ gpu_ids = [i for i in cuda_ids if i in gpu_ids]
149
+ if len(gpu_ids) == 0:
150
+ # cuda visible devices = '' -> don't use any gpu
151
+ warnings.warn(
152
+ colored(
153
+ (
154
+ "CUDA_VISIBLE_DEVICES={} ".format(
155
+ os.environ["CUDA_VISIBLE_DEVICES"]
156
+ )
157
+ + "did not match any physical GPU "
158
+ + "(id={}), falling back to CPU".format(
159
+ [dev["index"] for dev in devices]
160
+ )
161
+ ),
162
+ "yellow",
163
+ )
164
+ )
165
+ set_device(kind="cpu")
166
+ return
167
+ devices = [dev for dev in devices if dev["index"] in gpu_ids]
168
+
169
+ if gpuid is not None and (str(gpuid) in gpu_ids):
170
+ selected_gpu = [dev for dev in devices if dev["index"] == str(gpuid)][0]
171
+ else:
172
+ for dev in devices:
173
+ mem = dev["mem_total"] - dev["mem_used"]
174
+ if mem > maxmem:
175
+ maxmem = mem
176
+ selected_gpu = dev
177
+ config["device"] = selected_gpu["type"] + " (id={})".format(
178
+ selected_gpu["index"]
179
+ )
180
+ if gpuid is not None and not (str(gpuid) in gpu_ids):
181
+ warnings.warn(
182
+ colored(
183
+ "Specified gpuid {} not found, falling back to ".format(str(gpuid))
184
+ + config["device"],
185
+ "yellow",
186
+ )
187
+ )
188
+ config["avail_mem"] = (
189
+ selected_gpu["mem_total"] - selected_gpu["mem_used"]
190
+ ) / 1024 # in GB
191
+ os.environ["CUDA_VISIBLE_DEVICES"] = str(selected_gpu["index"])
@@ -0,0 +1,92 @@
1
+ """Main command line interface to DESC for solving fixed boundary equilibria."""
2
+
3
+ import sys
4
+
5
+ from desc.input_reader import InputReader
6
+
7
+
8
+ def main(cl_args=sys.argv[1:]):
9
+ """Run the main DESC code from the command line.
10
+
11
+ Reads and parses user input from command line, runs the code,
12
+ and prints and plots the resulting equilibrium.
13
+
14
+ """
15
+ ir = InputReader(cl_args=cl_args)
16
+
17
+ if ir.args.version:
18
+ return
19
+
20
+ import desc
21
+
22
+ if ir.args.verbose:
23
+ print(desc.BANNER)
24
+
25
+ import matplotlib.pyplot as plt
26
+
27
+ from desc.backend import print_backend_info
28
+ from desc.equilibrium import EquilibriaFamily, Equilibrium
29
+ from desc.plotting import plot_section, plot_surfaces
30
+
31
+ if ir.args.verbose:
32
+ print_backend_info()
33
+ print("Reading input from {}".format(ir.input_path))
34
+ print("Outputs will be written to {}".format(ir.output_path))
35
+
36
+ inputs = ir.inputs
37
+ if (
38
+ len(inputs) == 1
39
+ and (inputs[-1]["pres_ratio"] is None)
40
+ and (inputs[-1]["bdry_ratio"] is None)
41
+ ):
42
+ eq = Equilibrium(**inputs[-1], check_kwargs=False, ensure_nested=False)
43
+ equil_fam = EquilibriaFamily.solve_continuation_automatic(
44
+ eq,
45
+ objective=inputs[-1]["objective"],
46
+ optimizer=inputs[-1]["optimizer"],
47
+ pert_order=inputs[-1]["pert_order"],
48
+ ftol=inputs[-1]["ftol"],
49
+ xtol=inputs[-1]["xtol"],
50
+ gtol=inputs[-1]["gtol"],
51
+ maxiter=inputs[-1]["maxiter"],
52
+ verbose=ir.args.verbose,
53
+ checkpoint_path=ir.output_path,
54
+ )
55
+ else:
56
+ # initialize
57
+ equil_fam = EquilibriaFamily(inputs)
58
+ # check vmec path input
59
+ if ir.args.guess is not None:
60
+ if ir.args.verbose:
61
+ print("Initial guess from {}".format(ir.args.guess))
62
+ equil_fam[0].set_initial_guess(ir.args.guess)
63
+ # solve equilibrium
64
+ equil_fam.solve_continuation(
65
+ objective=inputs[0]["objective"],
66
+ optimizer=inputs[0]["optimizer"],
67
+ pert_order=[inp["pert_order"] for inp in inputs],
68
+ ftol=[inp["ftol"] for inp in inputs],
69
+ xtol=[inp["xtol"] for inp in inputs],
70
+ gtol=[inp["gtol"] for inp in inputs],
71
+ maxiter=[inp["maxiter"] for inp in inputs],
72
+ verbose=ir.args.verbose,
73
+ checkpoint_path=ir.output_path,
74
+ )
75
+
76
+ if ir.args.plot > 1:
77
+ for i, eq in enumerate(equil_fam[:-1]):
78
+ print("Plotting solution at step {}".format(i + 1))
79
+ _ = plot_surfaces(eq)
80
+ plt.show()
81
+ _ = plot_section(eq, "|F|_normalized", log=True)
82
+ plt.show()
83
+ if ir.args.plot > 0:
84
+ print("Plotting final solution")
85
+ _ = plot_surfaces(equil_fam[-1])
86
+ plt.show()
87
+ _ = plot_section(equil_fam[-1], "|F|_normalized", log=True)
88
+ plt.show()
89
+
90
+
91
+ if __name__ == "__main__": # pragma: no cover
92
+ main(sys.argv[1:])
@@ -0,0 +1,21 @@
1
+
2
+ # This file was generated by 'versioneer.py' (0.19) from
3
+ # revision-control system data, or from the parent directory name of an
4
+ # unpacked source archive. Distribution tarballs contain a pre-generated copy
5
+ # of this file.
6
+
7
+ import json
8
+
9
+ version_json = '''
10
+ {
11
+ "date": "2026-06-21T16:37:47-0700",
12
+ "dirty": false,
13
+ "error": null,
14
+ "full-revisionid": "49cf9484f963b2bdbddd63e3cd7a5bf5735394ee",
15
+ "version": "1.17.4"
16
+ }
17
+ ''' # END VERSION_JSON
18
+
19
+
20
+ def get_versions():
21
+ return json.loads(version_json)