Skip to content

Commit

Permalink
Update examples and format notes in Jupyter notebook examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hansec committed Feb 29, 2024
1 parent 23837d9 commit 63a2b39
Show file tree
Hide file tree
Showing 7 changed files with 166 additions and 199 deletions.
4 changes: 3 additions & 1 deletion src/docs/doc_tokamaker_main.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ The following examples illustrate usage of TokaMaker to compute different Grad-S

### Mesh Generation
- \subpage doc_tMaker_mesh_ex1
- \subpage doc_tMaker_mesh_ex2

### Fixed Boundary Equilibria
- \subpage doc_tMaker_ex1
- \subpage doc_tMaker_ex2

### Free Boundary Equilibria
- \subpage doc_tMaker_ex3
- \subpage doc_tMaker_ex3
- \subpage doc_tMaker_ex4
131 changes: 90 additions & 41 deletions src/examples/TokaMaker/HBT/HBT_eq_ex.ipynb

Large diffs are not rendered by default.

Binary file modified src/examples/TokaMaker/HBT/HBT_mesh.h5
Binary file not shown.
50 changes: 26 additions & 24 deletions src/examples/TokaMaker/HBT/HBT_mesh_ex.ipynb

Large diffs are not rendered by default.

164 changes: 36 additions & 128 deletions src/examples/TokaMaker/ITER/ITER_baseline_ex.ipynb

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions src/examples/TokaMaker/ITER/ITER_mesh_ex.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@
" - `vv2`: The outer vacuum vessel\n",
" - `PF1,...`: Each of the 14 coils in ITER (6 CS, 6 PF, 2 VS)\n",
"\n",
"In ITER all coils are independent except for the vertical stability coil (`VS`), which is single coil set composed of two counter-wound coils. To treat this set as a single coil we use the `coil_set` and `nTurns` argument to \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.define_region \"define_region()\" to join the coils in a single `VS` coil set with opposing polarities.\n",
"\n",
"**Note:** `nTurns` can also be used to define the number of turns in a given coil region. At the moment we are not including # of turns in this model so we keep the amplitude for each coil as 1.0 and only adjust the polarity.\n",
"\n",
"For each region you can provide a target size and one of four region types:\n",
" - `plasma`: The region where the plasma can exist and the classic Grad-Shafranov equation with $F*F'$ and $P'$ are allowed. **There can only be one region of this type**\n",
" - `vacuum`: A region where not current can flow and $\\nabla^* \\psi = 0$ is solved\n",
" - `boundary`: A special case of the `vacuum` region, which forms the outer boundary of the computational domain. **A region of this type is required if more than one region is specified**\n",
" - `conductor`: A region where toroidal current can flow passively (no externally applied voltage). For this type of region the resistivity should be specified with the argument `eta` in units of $\\omega \\mathrm{-m}$.\n",
" - `coil`: A region where toroidal current can flow with specified amplitude through \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_coil_currents or via shape optimization \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_coil_reg and \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_isoflux"
" - `coil`: A region where toroidal current can flow with specified amplitude through \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_coil_currents \"set_coil_currents()\" or via shape optimization \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_coil_reg \"set_coil_reg()\" and \\ref OpenFUSIONToolkit.TokaMaker.TokaMaker.set_isoflux \"set_isoflux()\""
]
},
{
Expand Down Expand Up @@ -161,8 +165,8 @@
"## Define geometry for region boundaries\n",
"Once the region types and properties are defined we now define the geometry of the mesh using shapes and references to the defined regions.\n",
" 1. We add the limiter contour as a \"polygon\", referencing `plasma` as the region enclosed by the contour and `vacuum1` as the region outside the contour.\n",
" 2. We add the inner vacuum as an \"annulus\" with curves defining the inner and outer edges respectively. We also reference `vacuum1` as the region enclosed by the annulus, `vv1` as the annular region itself, and `vacuum2` as the region outside the annulus.\n",
" 3. We add the outer vacuum as an \"annulus\" with curves defining the inner and outer edges respectively. We also reference `vacuum2` as the region enclosed by the annulus, `vv2` as the annular region itself, and `air` as the region outside the annulus.\n",
" 2. We add the inner vacuum vessel as an \"annulus\" with curves defining the inner and outer edges respectively. We also reference `vacuum1` as the region enclosed by the annulus, `vv1` as the annular region itself, and `vacuum2` as the region outside the annulus.\n",
" 3. We add the outer vacuum vessel as an \"annulus\" with curves defining the inner and outer edges respectively. We also reference `vacuum2` as the region enclosed by the annulus, `vv2` as the annular region itself, and `air` as the region outside the annulus.\n",
" 4. We add each of the 14 coils as \"rectangles\", which are defined by a center point (R,Z) along with a width (W) and height (H). We also reference `air` as the region outside the rectangle for the CS and PF coils and `vacuum1` for the VS coils."
]
},
Expand Down Expand Up @@ -237,7 +241,7 @@
"metadata": {},
"source": [
"## Create mesh\n",
"Now we generate the actual mesh using the \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.build_mesh \"build_mesh\" method. Additionally, if `coil` and/or `conductor` regions are defined the \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.get_coils \"get_coils\" and \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.get_conductors \"get_conductors\" methods should also be called to get descriptive dictionaries for later use in TokaMaker. This step may take a few moments as [triangle](https://www.cs.cmu.edu/~quake/triangle.html) generates the mesh.\n",
"Now we generate the actual mesh using the \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.build_mesh \"build_mesh()\" method. Additionally, if `coil` and/or `conductor` regions are defined the \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.get_coils \"get_coils()\" and \\ref OpenFUSIONToolkit.TokaMaker.gs_Domain.get_conductors \"get_conductors()\" methods should also be called to get descriptive dictionaries for later use in TokaMaker. This step may take a few moments as [triangle](https://www.cs.cmu.edu/~quake/triangle.html) generates the mesh.\n",
"\n",
"Note that, as is common with unstructured meshes, the mesh is stored a list of points `mesh_pts` of size (np,2), a list of cells formed from three points each `mesh_lc` of size (nc,3), and an array providing a region id number for each cell `mesh_reg` of size (nc,), which is mapped to the names above using the `coil_dict` and `cond_dict` dictionaries."
]
Expand Down Expand Up @@ -324,7 +328,7 @@
"metadata": {},
"source": [
"## Save mesh for later use\n",
"As generation of the mesh often takes comparable, or longer, time compare to runs in TokaMaker it is useful to separate generation of the mesh into a different script as demonstrated here. The method \\ref OpenFUSIONToolkit.TokaMaker.save_gs_mesh can be used to save the resulting information for later use. This is done using and an [HDF5](https://www.hdfgroup.org/solutions/hdf5/) file through the [h5py](https://www.h5py.org/) library."
"As generation of the mesh often takes comparable, or longer, time compare to runs in TokaMaker it is useful to separate generation of the mesh into a different script as demonstrated here. The method \\ref OpenFUSIONToolkit.TokaMaker.save_gs_mesh \"save_gs_mesh()\" can be used to save the resulting information for later use. This is done using and an [HDF5](https://www.hdfgroup.org/solutions/hdf5/) file through the [h5py](https://www.h5py.org/) library."
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/utilities/generate_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ def parse_fortran_file(fid):
# Update image paths
contents = contents.replace("{0}_files".format(file_name), "images")
contents = contents.replace("[png]", "[]")
# Convert notes to note blocks
contents = contents.replace("**Note:**", r'@note')
# Convert code block style
contents_split = contents.split('```')
for i, content_segment in enumerate(contents_split):
Expand Down

0 comments on commit 63a2b39

Please sign in to comment.