Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,5 @@ dmypy.json
.DS_Store
.idea/
*.sw[po]
examples/dipole/bout.dipole.grd.nc
examples/dipole/dipole_eq.h5
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ Hypnotoad provides several executables for working with equilibria and grid file
equilibria from geqdsk equilibrium files
- `hypnotoad-circular` is a command line interface for creating grid files for
concentric, circular flux surfaces
- `hypnotoad-dipole` is a command line interface for creating grid files for
dipole flux surfaces
- `hypnotoad-torpex` is a command line interface for creating grid files for
TORPEX X-point configurations
- `hypnotoad-plot-equilibrium` is a command line tool for creating plots of the
Expand Down
7 changes: 7 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ def create_options_rst(filename, title, options_factory, *, exclude=None):
"Circular options",
hypnotoad.circular.CircularEquilibrium.user_options_factory,
)

create_options_rst(
"dipole-options.rst",
"Dipole options",
hypnotoad.cases.dipole.DipoleEquilibrium.user_options_factory,
)

create_options_rst(
"torpex-options.rst",
"TORPEX options",
Expand Down
2 changes: 1 addition & 1 deletion doc/utilities.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Plotting and other utilities
============================

``hypnotoad-plot-equilibrum``
``hypnotoad-plot-equilibrium``
-----------------------------

.. argparse::
Expand Down
98 changes: 98 additions & 0 deletions examples/dipole/make_dipole_mesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

#%%
# %load_ext autoreload
# %autoreload 2


import os
import hypnotoad
from hypnotoad.cases.dipole import DipoleEquilibrium
from hypnotoad.core.mesh import BoutMesh
#%%

options = {}



options["dpeqfile"] = os.path.join(hypnotoad.__path__[0],"../examples/dipole/dipole_eq.h5")
options["y_boundary_guards"] = 0
options["ny"] = 32
options["nx"] = 34
options["psi_spacing_separatrix_multiplier"] = 0.1 # Smaller -> pack near separatrix

# Poloidal grid spacing

options["target_all_poloidal_spacing_length"] = 0.3 # Smaller -> pack near targets
options["xpoint_poloidal_spacing_length"]= 0.25
#options["psi_inner"] = -2.0
# xpoint_poloidal_spacing_length
#
# finecontour_Nfine: 500
# finecontour_atol: 5.0e-16
# finecontour_diagnose: false
# finecontour_extend_prefactor: 2.0
# finecontour_maxits: 1000
# finecontour_overdamping_factor: 0.8
# follow_perpendicular_atol: 1.0e-20
# follow_perpendicular_rtol: 1.0e-16
# geometry_rtol: 1.0e-10
# leg_refine_atol: 2.0e-16
# leg_refine_maxits: 10000
options["nonorthogonal_radial_range_power"]: 2
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options["nonorthogonal_radial_range_power"]: 2
options["nonorthogonal_radial_range_power"] = 2

options["nonorthogonal_spacing_method"]: combined
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
options["nonorthogonal_spacing_method"]: combined
options["nonorthogonal_spacing_method"] = "combined"

# nonorthogonal_target_all_poloidal_spacing_length: 1.0
# nonorthogonal_target_all_poloidal_spacing_range: 0.05
# nonorthogonal_target_all_poloidal_spacing_range_inner: 0.05
# nonorthogonal_target_all_poloidal_spacing_range_outer: 0.05
# nonorthogonal_target_inner_lower_poloidal_spacing_length: 1.0
# nonorthogonal_target_inner_lower_poloidal_spacing_range: 0.05
# nonorthogonal_target_inner_lower_poloidal_spacing_range_inner: 0.05
# nonorthogonal_target_inner_lower_poloidal_spacing_range_outer: 0.05
# nonorthogonal_target_inner_upper_poloidal_spacing_length: 1.0
# nonorthogonal_target_inner_upper_poloidal_spacing_range: 0.05
# nonorthogonal_target_inner_upper_poloidal_spacing_range_inner: 0.05
# nonorthogonal_target_inner_upper_poloidal_spacing_range_outer: 0.05
# nonorthogonal_target_outer_lower_poloidal_spacing_length: 1.0
# nonorthogonal_target_outer_lower_poloidal_spacing_range: 0.05
# nonorthogonal_target_outer_lower_poloidal_spacing_range_inner: 0.05
# nonorthogonal_target_outer_lower_poloidal_spacing_range_outer: 0.05
# nonorthogonal_target_outer_upper_poloidal_spacing_length: 1.0
# nonorthogonal_target_outer_upper_poloidal_spacing_range: 0.05
# nonorthogonal_target_outer_upper_poloidal_spacing_range_inner: 0.05
# nonorthogonal_target_outer_upper_poloidal_spacing_range_outer: 0.05
# nonorthogonal_xpoint_poloidal_spacing_length: 1.0
# nonorthogonal_xpoint_poloidal_spacing_range: 0.015
# nonorthogonal_xpoint_poloidal_spacing_range_inner: 0.05
# nonorthogonal_xpoint_poloidal_spacing_range_outer: 0.02

eq = DipoleEquilibrium(settings=options, nonorthogonal_settings=options)

import matplotlib.pyplot as plt

eq.plotPotential(ncontours=40)
for region in eq.regions.values():
plt.plot(
[p.R for p in region.points],
[p.Z for p in region.points],
marker="o",
)
plt.show()

mesh = BoutMesh(eq, options)
mesh.calculateRZ()


import matplotlib.pyplot as plt

ax = eq.plotPotential(ncontours=40)
mesh.plotPoints(
xlow=options.get("plot_xlow", True),
ylow=options.get("plot_ylow", True),
corners=options.get("plot_corners", True),
ax=ax,
)
plt.show()


mesh.geometry()
mesh.writeGridfile(options.get("grid_file", "bout.dipole.grd.nc"))
Loading
Loading