Skip to content

Commit a2e2f8c

Browse files
authored
Merge pull request #124 from boutproject/example-tokamak-include-boundary-points
Minor improvements to tokamak example (include boundary points)
2 parents f2d6562 + 1a88325 commit a2e2f8c

File tree

12 files changed

+49
-16
lines changed

12 files changed

+49
-16
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
if: always()
1919
strategy:
2020
matrix:
21-
python-version: [3.7, 3.8, 3.9]
21+
python-version: [3.8, 3.9, '3.10']
2222
fail-fast: false
2323

2424
steps:
@@ -40,11 +40,11 @@ jobs:
4040
integrated-tests:
4141

4242
runs-on: ubuntu-latest
43-
timeout-minutes: 10
43+
timeout-minutes: 15
4444
if: always()
4545
strategy:
4646
matrix:
47-
python-version: [3.7, 3.8, 3.9]
47+
python-version: [3.8, 3.9, '3.10']
4848
fail-fast: false
4949

5050
steps:
@@ -69,7 +69,7 @@ jobs:
6969
examples:
7070

7171
runs-on: ubuntu-latest
72-
timeout-minutes: 10
72+
timeout-minutes: 30
7373
if: always()
7474
strategy:
7575
fail-fast: false

.github/workflows/pythonpublish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
timeout-minutes: 30
1616
strategy:
1717
matrix:
18-
python-version: [3.7, 3.8, 3.9]
18+
python-version: [3.8, 3.9, '3.10']
1919

2020
steps:
2121
- uses: actions/checkout@v2

examples/tokamak/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
> **Warning:** This example does not use/generate a geqdsk file, so does not
2+
support the 'standard' workflow with `hypnotoad-gui` or `hypnotoad_geqdsk`.
3+
14
To generate a tokamak grid for a simple poloidal flux, psi, given by an
25
analytic function:
36

examples/tokamak/connected-double-null.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,7 @@ psi_spacing_separatrix_multiplier: 0.5 # Smaller -> pack near separatrix
2828

2929
# Poloidal grid spacing
3030

31-
target_all_poloidal_spacing_length: 0.05 # Smaller -> pack near targets
31+
target_all_poloidal_spacing_length: 0.3 # Smaller -> pack near targets
3232
xpoint_poloidal_spacing_length: 0.05 # Smaller -> pack near X-points
33+
34+
y_boundary_guards: 2

examples/tokamak/disconnected-double-null.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,7 @@ psi_spacing_separatrix_multiplier: 0.5 # Smaller -> pack near separatrix
2929

3030
# Poloidal grid spacing
3131

32-
target_all_poloidal_spacing_length: 0.05 # Smaller -> pack near targets
32+
target_all_poloidal_spacing_length: 0.3 # Smaller -> pack near targets
3333
xpoint_poloidal_spacing_length: 0.05 # Smaller -> pack near X-points
34+
35+
y_boundary_guards: 2

examples/tokamak/single-null.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,7 @@ psi_spacing_separatrix_multiplier: 0.5 # Smaller -> pack near separatrix
2525

2626
# Poloidal grid spacing
2727

28-
target_all_poloidal_spacing_length: 0.05 # Smaller -> pack near targets
28+
target_all_poloidal_spacing_length: 0.3 # Smaller -> pack near targets
2929
xpoint_poloidal_spacing_length: 0.05 # Smaller -> pack near X-points
30+
31+
y_boundary_guards: 2

examples/tokamak/tokamak_example.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def create_tokamak(geometry="lsn", nx=65, ny=65):
2323
psi2d[nx,ny] 2D array of poloidal flux [Wb]
2424
"""
2525

26-
r1d = np.linspace(1.2, 1.8, nx)
27-
z1d = np.linspace(-0.5, 0.5, ny)
26+
r1d = np.linspace(1.0, 2.0, nx)
27+
z1d = np.linspace(-0.7, 0.7, ny)
2828
r2d, z2d = np.meshgrid(r1d, z1d, indexing="ij")
2929

3030
r0 = 1.5
@@ -115,23 +115,39 @@ def create_tokamak(geometry="lsn", nx=65, ny=65):
115115

116116
from hypnotoad import tokamak
117117

118+
# Put wall inside grid, so that we can have boundary points outside with wall wthout
119+
# hitting extrapolated psi.
120+
wall_extra = 0.2
121+
rmin = min(r1d) + wall_extra
122+
rmax = max(r1d) - wall_extra
123+
zmin = min(z1d) + wall_extra
124+
zmax = max(z1d) - wall_extra
118125
eq = tokamak.TokamakEquilibrium(
119-
r1d, z1d, psi2d, psi1d, [], settings=options # psi1d, fpol
126+
r1d,
127+
z1d,
128+
psi2d,
129+
psi1d,
130+
fpol1D=[],
131+
settings=options,
132+
wall=[(rmin, zmin), (rmin, zmax), (rmax, zmax), (rmax, zmin)],
120133
)
121134

122135
from hypnotoad.core.mesh import BoutMesh
123136

124137
mesh = BoutMesh(eq, options)
125138
mesh.geometry()
139+
mesh.writeGridfile("bout.grd.nc")
126140

127141
if not args.no_plot:
128142
import matplotlib.pyplot as plt
129143

130144
eq.plotPotential(ncontours=40)
145+
eq.plotWall()
131146

132147
plt.plot(*eq.x_points[0], "rx")
133148

134149
mesh.plotPoints(xlow=True, ylow=True, corners=True)
150+
eq.plotWall()
135151

136152
plt.show()
137153

hypnotoad/test_suite/test_fileutils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ def test_ChunkOutput():
1919
assert (
2020
output.getvalue()
2121
== """ 1.000000000E+00-3.200000000E+00 6.200000000E+05 8.765400000E-12 4.200000000E+01
22-
-76"""
22+
-76""" # noqa: E501
2323
)

integrated_tests/connected_doublenull_nonorthogonal/runtest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import sys
66
import xarray.testing as xrt
77

8-
from integrated_tests.utils import run_case
8+
# Put the integrated_tests directory into sys.path so we can import from it
9+
sys.path.append(str(Path(__file__).joinpath("..", "..", "..").resolve()))
10+
from integrated_tests.utils import run_case # noqa: E402
911

1012
diagnose = False
1113

integrated_tests/connected_doublenull_orthogonal/runtest.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import sys
66
import xarray.testing as xrt
77

8-
from integrated_tests.utils import run_case
8+
# Put the integrated_tests directory into sys.path so we can import from it
9+
sys.path.append(str(Path(__file__).joinpath("..", "..", "..").resolve()))
10+
from integrated_tests.utils import run_case # noqa: E402
911

1012
diagnose = False
1113

0 commit comments

Comments
 (0)