Skip to content

Commit 87ca4e5

Browse files
authored
Merge pull request #191 from boutproject/fix-xbout-grid-loading
Set the dimension for R_closed_wall and Z_closed_wall to 'closed_wall'
2 parents 60a02e9 + 0f1759d commit 87ca4e5

File tree

7 files changed

+69
-28
lines changed

7 files changed

+69
-28
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
name: Python package
55

66
on:
7-
[push, pull_request]
7+
push:
8+
pull_request:
9+
schedule:
10+
- cron: '25 1 3 * *'
811

912
concurrency:
1013
group: ${{ github.workflow}}-${{ github.ref }}
@@ -18,7 +21,7 @@ jobs:
1821
if: always()
1922
strategy:
2023
matrix:
21-
python-version: ['3.10', '3.11', '3.12']
24+
python-version: ['3.10', '3.11', '3.12', '3.13']
2225
fail-fast: false
2326

2427
steps:
@@ -42,7 +45,7 @@ jobs:
4245
if: always()
4346
strategy:
4447
matrix:
45-
python-version: ['3.10', '3.11', '3.12']
48+
python-version: ['3.10', '3.11', '3.12', '3.13']
4649
fail-fast: false
4750

4851
steps:

doc/whats-new.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ Release history
44
### Bug fixes
55
- When using the GUI, if there is an error in `TokamakEquilibrium` object
66
creation, still plot the equilibrium data (#186).
7+
By [John Omotani](https://github.com/johnomotani)
8+
- Set the dimension for R_closed_wall and Z_closed_wall to 'closed_wall'. Fixes
9+
loading of grid files by xBOUT (#191).
10+
By [John Omotani](https://github.com/johnomotani)
711

812

913
### New features
1014

1115
- Radial grid line construction can recover from failure and generate
1216
a rough grid to help visual inspection when option
1317
`follow_perpendicular_recover` is set to True (#175)
18+
By [Ben Dudson](https://github.com/bendudson)
1419
- A `View` menu enables the grid plot to be customised, with cell edges, corners,
1520
grid lines and other components (#176).
21+
By [Ben Dudson](https://github.com/bendudson)
1622
- `penalty_mask` is calculated and written to the grid file, based on intersection
1723
of the grid with the wall. This enables immersed boundary conditions.
24+
By [Ben Dudson](https://github.com/bendudson)
1825
- Wall coordinates are written to output grid as `closed_wall_R` and `closed_wall_Z`
1926
(#176)
27+
By [Ben Dudson](https://github.com/bendudson)
2028

2129
0.5.2 (13th March 2023)
2230
-------------------------

hypnotoad/core/equilibrium.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1854,11 +1854,18 @@ def checkFineContourExtend(self, *, psi):
18541854
minind = numpy.argmin(distances)
18551855
# if minind > 0, or the distance to point 1 is less than the distance between
18561856
# point 0 and point 1 of the fine_contour, then fine_contour extends past p so
1857-
# does not need to be extended
1858-
if minind == 0 and distances[1] > numpy.sqrt(
1859-
numpy.sum(
1860-
(fine_contour.positions[1, :] - fine_contour.positions[0, :]) ** 2
1857+
# does not need to be extended.
1858+
# Include some tolerance to allow for rounding errors when the first point on
1859+
# the FineContour and the first point on the PsiContour are in 'the same place'.
1860+
if (
1861+
minind == 0
1862+
and distances[1]
1863+
- numpy.sqrt(
1864+
numpy.sum(
1865+
(fine_contour.positions[1, :] - fine_contour.positions[0, :]) ** 2
1866+
)
18611867
)
1868+
> 1.0e-13
18621869
):
18631870
ds = fine_contour.distance[1] - fine_contour.distance[0]
18641871
n_extend_lower = max(int(numpy.ceil(distances[0] / ds)), 1)
@@ -1874,10 +1881,17 @@ def checkFineContourExtend(self, *, psi):
18741881
# if minind < len(distances)-1, or the distance to the last point is less than
18751882
# the distance between the last and second-last of the fine_contour, then
18761883
# fine_contour extends past p so does not need to be extended
1877-
if minind == len(distances) - 1 and distances[-2] > numpy.sqrt(
1878-
numpy.sum(
1879-
(fine_contour.positions[-1, :] - fine_contour.positions[-2, :]) ** 2
1884+
# Include some tolerance to allow for rounding errors when the last point on
1885+
# the FineContour and the last point on the PsiContour are in 'the same place'.
1886+
if (
1887+
minind == len(distances) - 1
1888+
and distances[-2]
1889+
- numpy.sqrt(
1890+
numpy.sum(
1891+
(fine_contour.positions[-1, :] - fine_contour.positions[-2, :]) ** 2
1892+
)
18801893
)
1894+
> 1.0e-13
18811895
):
18821896
ds = fine_contour.distance[-1] - fine_contour.distance[-2]
18831897
n_extend_upper = max(int(numpy.ceil(distances[-1] / ds)), 1)

hypnotoad/core/mesh.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3728,8 +3728,16 @@ def writeGridfile(self, filename):
37283728
f.write("psi_bdry_gfile", self.equilibrium.psi_bdry_gfile)
37293729

37303730
if hasattr(self.equilibrium, "closed_wallarray"):
3731-
f.write("closed_wall_R", self.equilibrium.closed_wallarray[:, 0])
3732-
f.write("closed_wall_Z", self.equilibrium.closed_wallarray[:, 1])
3731+
f.write(
3732+
"closed_wall_R",
3733+
self.equilibrium.closed_wallarray[:, 0],
3734+
dims=("closed_wall",),
3735+
)
3736+
f.write(
3737+
"closed_wall_Z",
3738+
self.equilibrium.closed_wallarray[:, 1],
3739+
dims=("closed_wall",),
3740+
)
37333741

37343742
# write the 2d fields
37353743
for name in self.fields_to_output:

hypnotoad/scripts/hypnotoad_plot_grid_cells.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,25 @@ def main():
137137
# kwarg for something else.
138138
ds_region.isel(
139139
x=slice(xin, xout_centre), theta=slice(ylow, yup_centre)
140-
).plot.scatter("R", "Z", marker=".", color="k", s=1)
140+
).plot.scatter(x="R", y="Z", marker=".", color="k", s=1)
141141

142142
# plot radial grid lines
143143
plt.plot(
144-
ds_region["Rxy_corners"].isel(
144+
ds_region["Rxy_lower_left_corners"].isel(
145145
x=slice(xin, xout_corner_rad), theta=slice(ylow, yup_corner)
146146
),
147-
ds_region["Zxy_corners"].isel(
147+
ds_region["Zxy_lower_left_corners"].isel(
148148
x=slice(xin, xout_corner_rad), theta=slice(ylow, yup_corner)
149149
),
150150
color="k",
151151
)
152152

153153
# plot poloidal grid lines
154154
plt.plot(
155-
ds_region["Rxy_corners"]
155+
ds_region["Rxy_lower_left_corners"]
156156
.isel(x=slice(xin_pol, xout_corner_pol), theta=slice(ylow, yup_corner))
157157
.T,
158-
ds_region["Zxy_corners"]
158+
ds_region["Zxy_lower_left_corners"]
159159
.isel(x=slice(xin_pol, xout_corner_pol), theta=slice(ylow, yup_corner))
160160
.T,
161161
color="k",
@@ -175,8 +175,12 @@ def main():
175175
# neighbouring in the global grid, because if they are the boundary between
176176
# regions is not (or 'not really') a branch cut.
177177
plt.plot(
178-
ds_region["Rxy_corners"].isel(x=slice(xin, xout_corner_rad), theta=-1),
179-
ds_region["Zxy_corners"].isel(x=slice(xin, xout_corner_rad), theta=-1),
178+
ds_region["Rxy_lower_left_corners"].isel(
179+
x=slice(xin, xout_corner_rad), theta=-1
180+
),
181+
ds_region["Zxy_lower_left_corners"].isel(
182+
x=slice(xin, xout_corner_rad), theta=-1
183+
),
180184
color="r",
181185
linewidth=3,
182186
zorder=1000,
@@ -187,8 +191,12 @@ def main():
187191
# By arbitrary choice, plot from the region(s) inside the separatrix, so
188192
# highlight the outer edge.
189193
plt.plot(
190-
ds_region["Rxy_corners"].isel(x=-1, theta=slice(ylow, yup_corner)),
191-
ds_region["Zxy_corners"].isel(x=-1, theta=slice(ylow, yup_corner)),
194+
ds_region["Rxy_lower_left_corners"].isel(
195+
x=-1, theta=slice(ylow, yup_corner)
196+
),
197+
ds_region["Zxy_lower_left_corners"].isel(
198+
x=-1, theta=slice(ylow, yup_corner)
199+
),
192200
color="b",
193201
linewidth=3,
194202
zorder=999,
@@ -197,10 +205,10 @@ def main():
197205
if targets:
198206
if ds_region.regions[r].connection_lower_y is None:
199207
plt.plot(
200-
ds_region["Rxy_corners"].isel(
208+
ds_region["Rxy_lower_left_corners"].isel(
201209
x=slice(xin, xout_corner_rad), theta=ylow
202210
),
203-
ds_region["Zxy_corners"].isel(
211+
ds_region["Zxy_lower_left_corners"].isel(
204212
x=slice(xin, xout_corner_rad), theta=ylow
205213
),
206214
color="k",
@@ -210,10 +218,10 @@ def main():
210218
if ds_region.regions[r].connection_upper_y is None:
211219
yval = -1 if yup_corner is None else yup_corner
212220
plt.plot(
213-
ds_region["Rxy_corners"].isel(
221+
ds_region["Rxy_lower_left_corners"].isel(
214222
x=slice(xin, xout_corner_rad), theta=yval
215223
),
216-
ds_region["Zxy_corners"].isel(
224+
ds_region["Zxy_lower_left_corners"].isel(
217225
x=slice(xin, xout_corner_rad), theta=yval
218226
),
219227
color="k",

integrated_tests/connected_doublenull_with_rounding_error_nonorthogonal/runtest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
diagnose = False
1212

13-
rtol = 1.0e-9
14-
atol = 5.0e-10
13+
rtol = 2.0e-9
14+
atol = 2.0e-9
1515

1616
# make sure we are in the test directory
1717
os.chdir(Path(__file__).parent)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ classifiers = [
2626

2727
requires-python = ">=3.10"
2828
dependencies = [
29-
"boututils~=0.1.7",
29+
"boutdata~=0.3.0",
3030
"dill~=0.3,!=0.3.5,!=0.3.5.1",
3131
"func_timeout~=4.3",
3232
"matplotlib~=3.7",

0 commit comments

Comments
 (0)