Skip to content

Commit 2755f7b

Browse files
committed
Check that volumes are increasing
1 parent 0da2ed6 commit 2755f7b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

torax/geometry/standard_geometry.py

+12
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,18 @@ def calculate_area(x, z):
866866
/ (F_eqdsk * flux_surf_avg_1_over_R2_eqdsk)
867867
)
868868

869+
# Sense-check the profiles
870+
dvolumes = np.diff(volumes)
871+
if not np.all(dvolumes > 0):
872+
idx = np.where(dvolumes <= 0)
873+
raise ValueError(
874+
'Volumes are not monotonically increasing (got decrease in volume '
875+
f'between surfaces {", ".join([f"{i} -> {i+1}" for i in idx[0]])}). '
876+
'This likely means that the contour generation failed to produce a '
877+
'closed flux surface at these indices. To fix, try reducing '
878+
'last_surface_factor or n_surfaces.'
879+
)
880+
869881
return cls(
870882
geometry_type=geometry.GeometryType.EQDSK,
871883
Ip_from_parameters=Ip_from_parameters,

0 commit comments

Comments
 (0)