Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve documentation #1304

Merged
merged 49 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c0b72a3
add notebook to explain how we solve equilibrium
YigitElma Oct 15, 2024
5d0c628
add more details to the notebook
YigitElma Oct 16, 2024
0fffd60
make adjustments to grid guide mentioned in #1227
YigitElma Oct 16, 2024
dbdc6be
Merge branch 'master' into yge/docs
YigitElma Oct 16, 2024
6b227df
fix typo
YigitElma Oct 16, 2024
9552909
update 3D plots
YigitElma Oct 16, 2024
fc10946
trying to understand why 3D plots are not visible on docs
YigitElma Oct 16, 2024
4e6a40c
ok found the solution from another notebook we have
YigitElma Oct 16, 2024
0ad73b3
fix the 3D plots
YigitElma Oct 16, 2024
ebb6174
Merge branch 'master' into yge/docs
YigitElma Oct 16, 2024
fe4603b
fix typo 1
YigitElma Oct 16, 2024
1250c9e
fix typo 2
YigitElma Oct 16, 2024
1899e79
fix unrendered equation
YigitElma Oct 16, 2024
0c4ae9e
change some formatting
YigitElma Oct 16, 2024
e0ef490
change headers
YigitElma Oct 16, 2024
e9586dd
Merge branch 'master' into yge/docs
YigitElma Oct 30, 2024
49931f4
Merge branch 'master' into yge/docs
YigitElma Nov 4, 2024
deebc68
update trust region part
YigitElma Nov 4, 2024
60d9c68
address some comments on eq-solve notebook
YigitElma Nov 7, 2024
bc8ad07
fix the typo in basic_equilibrium
YigitElma Nov 7, 2024
b06b8b1
fix bolding
YigitElma Nov 7, 2024
54c3b9b
address more comments
YigitElma Nov 7, 2024
66b7217
fix formatting
YigitElma Nov 7, 2024
aa63161
fix the unavailable link in grid notebook, add link to stell sym section
YigitElma Nov 7, 2024
e5a092b
add extra space
YigitElma Nov 7, 2024
001cfa3
fix concentric linear grid mistake from earlier
YigitElma Nov 7, 2024
2e9f026
change last plot to use concentricgrid for collocation points, it is …
YigitElma Nov 7, 2024
c1acb0d
address dario's comments on stell symmetry
YigitElma Nov 11, 2024
2ded4bd
Merge branch 'master' into yge/docs
YigitElma Nov 11, 2024
a0e1f35
add wsl instructions
YigitElma Nov 11, 2024
91b8c90
add compute func with additional kwarg
YigitElma Nov 11, 2024
dfce935
Merge branch 'master' into yge/docs
YigitElma Nov 12, 2024
9550b4a
Merge branch 'master' into yge/docs
YigitElma Nov 12, 2024
8c45c57
make clarification
YigitElma Nov 12, 2024
c173a26
fix some typos, add some options
YigitElma Nov 12, 2024
d15b3ff
explain compute_fun
YigitElma Nov 13, 2024
ae75e41
fix some notation issues
YigitElma Nov 13, 2024
1c69df7
don't use inverse symbol at all
YigitElma Nov 13, 2024
e9158f4
Update docs/installation.rst
YigitElma Nov 13, 2024
1b75f61
Update docs/adding_compute_funs.rst
YigitElma Nov 13, 2024
5f415e7
add eq.compute example
YigitElma Nov 13, 2024
2b43799
Merge branch 'yge/docs' of github.com:PlasmaControl/DESC into yge/docs
YigitElma Nov 13, 2024
fe8f026
Merge branch 'master' into yge/docs
YigitElma Nov 13, 2024
f0e6d29
Merge branch 'master' into yge/docs
YigitElma Nov 15, 2024
ca66d7f
Merge branch 'master' into yge/docs
dpanici Nov 18, 2024
04a34c5
Merge branch 'master' into yge/docs
dpanici Nov 18, 2024
b95b591
Update docs/installation.rst
YigitElma Nov 18, 2024
544ac29
Merge branch 'master' into yge/docs
YigitElma Nov 19, 2024
a575b69
Merge branch 'master' into yge/docs
YigitElma Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/_static/images/trust-region.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions docs/adding_compute_funs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,61 @@ This test is a regression test to ensure that compute quantities in each new upd
from previous versions of DESC.
Since the new quantity did not exist in previous versions of DESC, one must run this test
and commit the outputted ``tests/inputs/master_compute_data.pkl`` file which is updated automatically when a new quantity is detected.

Compute function may take additional ``**kwargs`` arguments to provide more information to the function which cannot be get from other input arguments or dependencies in ``data``. One example of this kind of compute function is ``P_ISS04``.
::

@register_compute_fun(
name="P_ISS04",
label="P_{ISS04}",
units="W",
units_long="Watts",
description="Heating power required by the ISS04 energy confinement time scaling",
dim=0,
params=[],
transforms={"grid": []},
profiles=[],
coordinates="",
data=["a", "iota", "rho", "R0", "W_p", "<ne>_vol", "<|B|>_axis"],
method="str: Interpolation method. Default 'cubic'.",
H_ISS04="float: ISS04 confinement enhancement factor. Default 1.",
)
def _P_ISS04(params, transforms, profiles, data, **kwargs):
rho = transforms["grid"].compress(data["rho"], surface_label="rho")
iota = transforms["grid"].compress(data["iota"], surface_label="rho")
fx = {}
if "iota_r" in data:
fx["fx"] = transforms["grid"].compress(
data["iota_r"]
) # noqa: unused dependency
iota_23 = interp1d(2 / 3, rho, iota, method=kwargs.get("method", "cubic"), **fx)
data["P_ISS04"] = 1e6 * ( # MW -> W
jnp.abs(data["W_p"] / 1e6) # J -> MJ
/ (
0.134
* data["a"] ** 2.28 # m
* data["R0"] ** 0.64 # m
* (data["<ne>_vol"] / 1e19) ** 0.54 # 1/m^3 -> 1e19/m^3
* data["<|B|>_axis"] ** 0.84 # T
* iota_23**0.41
* kwargs.get("H_ISS04", 1)
)
) ** (1 / 0.39)
return data


This function can be called by following notation,
::

# Compute P_ISS04
# specify gamma and H_ISS04 values as keyword arguments
data = compute_fun(
"desc.equilibrium.equilibrium.Equilibrium",
"P_ISS04",
params=params,
transforms=transforms,
profiles=profiles,
gamma=gamma,
H_ISS04=H_ISS04,
)
P_ISS04 = data["P_ISS04"]
3 changes: 2 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@
:maxdepth: 1
:caption: Developer guides

notebooks/dev_guide/getting-started-eq-solve.ipynb
notebooks/dev_guide/grid.ipynb
adding_compute_funs
adding_objectives
adding_optimizers
notebooks/dev_guide/grid.ipynb



Expand Down
5 changes: 5 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Other package managers like venv could be used instead of conda, we have just ch
**NOTE: DESC requires python>=3.9.**
**If you have python2 also locally installed, replace all `pip` commands with `pip3` and all `python` commands with `python3` to ensure the correct python version is used.**

**NOTE: If you are on Windows, consider using the Windows Subsystem for Linux (WSL) to install DESC.**

We don't test DESC on Windows and there have been some instances that numerical discrepancies on Windows cause failures or wrong results. For how to install WSL see `here <https://learn.microsoft.com/en-us/windows/wsl/install>`__. For using WSL in VS Code see `here <https://code.visualstudio.com/docs/remote/wsl>`__.


On Your Local Machine
*********************

Expand Down
10 changes: 5 additions & 5 deletions docs/notebooks/basis_grid.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
"\n",
"The two primary attributes of any grid are `grid.nodes` and `grid.weights`.\n",
"\n",
"`grid.nodes` is a $k \\times 3$ array of the node locations in straight field line coordinates $(\\rho,\\theta,\\zeta)$\n",
"`grid.nodes` is a $k \\times 3$ array of the node locations in flux coordinates $(\\rho,\\theta,\\zeta)$\n",
"\n",
"`grid.weights` is a $k \\times 1$ array giving approximate or exact quadrature weights for each node."
]
Expand All @@ -442,9 +442,9 @@
"\n",
"The simplest collocation grid is one that is linearly spaced in all coordinates $(\\rho,\\theta,\\zeta)$. It accepts 3 non-negative integer arguments in two different formats: \n",
"\n",
"`L`, `M`, `N` specify the spectral resolution in each dimension. For example, `L=4` would give 5 radial grid points corresponding to a polynomial up to order $\\rho^4$. `M=2` would give 5 poloidal grid points corresponding to the 5 Fourier basis functions up to order $\\sin(2\\theta)$ and $\\cos(2\\theta)$. \n",
"* `L`, `M`, `N` specify the spectral resolution in each dimension. For example, `L=4` would give 5 radial grid points corresponding to a polynomial up to order $\\rho^4$. `M=2` would give 5 poloidal grid points corresponding to the 5 Fourier basis functions up to order $\\sin(2\\theta)$ and $\\cos(2\\theta)$. \n",
"\n",
"`rho`, `theta`, `zeta` directly specify the number of linearly spaced grid points in each dimension, if passed as integers. Alternatively, these inputs can be used to manually specify the arrays of nodes. \n",
"* `rho`, `theta`, `zeta` directly specify the number of linearly spaced grid points in each dimension, if passed as integers. Alternatively, these inputs can be used to manually specify the arrays of nodes. \n",
"\n",
"The number of field periods is also input as a positive integer `NFP`. \n",
"\n",
Expand Down Expand Up @@ -648,7 +648,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "desc-env",
"language": "python",
"name": "python3"
},
Expand All @@ -662,7 +662,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
Loading