Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -68,3 +68,5 @@ thirdparty/pyplot_module.F90
.claude
docs/_build/
build*/
artifacts/plots/
artifacts/notebooks/
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ f90wrap==0.2.16
pytest==7.4.3
pytest-cov==6.2.1
netCDF4==1.7.2
gvec==1.4.0

# Optional dependencies for examples/plotting
matplotlib==3.9.4
Expand Down
9 changes: 3 additions & 6 deletions src/boozer_converter.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1132,11 +1132,8 @@ subroutine export_boozer_chartmap(filename)
R, Zval, alam, dR_ds, dR_dt, dR_dp, &
dZ_ds, dZ_dt, dZ_dp, dl_ds, dl_dt, dl_dp)

! Convert to Cartesian using phi_B as the azimuthal angle.
! This creates a pseudo-Cartesian representation consistent
! with the Boozer toroidal grid (atan2(y,x) = phi_B).
x_arr(i_rho, i_theta, i_phi) = R * cos(phi_B)
y_arr(i_rho, i_theta, i_phi) = R * sin(phi_B)
x_arr(i_rho, i_theta, i_phi) = R * cos(phi_V)
y_arr(i_rho, i_theta, i_phi) = R * sin(phi_V)
z_arr(i_rho, i_theta, i_phi) = Zval
end do
end do
Expand Down Expand Up @@ -1193,7 +1190,7 @@ subroutine export_boozer_chartmap(filename)
! Global attributes
call nc_assert(nf90_put_att(ncid, nf90_global, "rho_convention", "rho_tor"), &
"att rho_convention")
call nc_assert(nf90_put_att(ncid, nf90_global, "zeta_convention", "cyl"), &
call nc_assert(nf90_put_att(ncid, nf90_global, "zeta_convention", "boozer"), &
"att zeta_convention")
call nc_assert(nf90_put_att(ncid, nf90_global, "rho_lcfs", rho_arr(ns_B)), &
"att rho_lcfs")
Expand Down
Binary file modified test/test_data/figure8.gvec.chartmap.nc
Binary file not shown.
Binary file modified test/test_data/wout_qa.gvec.chartmap.nc
Binary file not shown.
29 changes: 23 additions & 6 deletions test/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
set(TEST_DATA_DIR "${CMAKE_SOURCE_DIR}/test/test_data")
set(WOUT_FILE "${TEST_DATA_DIR}/wout.nc")
set(WOUT_URL "https://github.com/hiddenSymmetries/simsopt/raw/master/tests/test_files/wout_LandremanPaul2021_QA_reactorScale_lowres_reference.nc")
set(WOUT_QH_FILE "${TEST_DATA_DIR}/wout_qh.nc")
set(WOUT_QH_URL "https://raw.githubusercontent.com/hiddenSymmetries/simsopt/master/tests/test_files/wout_LandremanPaul2021_QH_reactorScale_lowres_reference.nc")

# Download if not present
if(NOT EXISTS "${WOUT_FILE}")
Expand All @@ -14,8 +16,15 @@ if(NOT EXISTS "${WOUT_FILE}")
message(STATUS "Downloaded VMEC test file")
endif()

if(NOT EXISTS "${WOUT_QH_FILE}")
file(MAKE_DIRECTORY "${TEST_DATA_DIR}")
message(STATUS "Downloading QH VMEC file to ${WOUT_QH_FILE}...")
file(DOWNLOAD "${WOUT_QH_URL}" "${WOUT_QH_FILE}")
endif()

# Create symlink in test binary directory for backward compatibility
file(CREATE_LINK "${WOUT_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/wout.nc" SYMBOLIC)
file(CREATE_LINK "${WOUT_QH_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/wout_qh.nc" SYMBOLIC)

set(WOUT_QA_GVEC_CHARTMAP_SOURCE "${TEST_DATA_DIR}/wout_qa.gvec.chartmap.nc")
set(WOUT_QA_GVEC_CHARTMAP_BINARY "${CMAKE_CURRENT_BINARY_DIR}/wout_qa.gvec.chartmap.nc")
Expand All @@ -26,6 +35,11 @@ endif()
set(FIGURE8_BOUNDARY_SOURCE "${TEST_DATA_DIR}/figure8.quasr.boundary.nc")
set(FIGURE8_CHARTMAP_SOURCE "${TEST_DATA_DIR}/figure8.gvec.chartmap.nc")

set(BOOZER_CHARTMAP_PYTHON "${Python_EXECUTABLE}")
if(EXISTS "${CMAKE_SOURCE_DIR}/.venv/bin/python")
set(BOOZER_CHARTMAP_PYTHON "${CMAKE_SOURCE_DIR}/.venv/bin/python")
endif()

# Generate chartmap file from VMEC for testing chartmap coordinate detection
# Uses libneo's vmec_to_chartmap tool built as part of dependencies
set(CHARTMAP_FILE "${CMAKE_CURRENT_BINARY_DIR}/wout.chartmap.nc")
Expand Down Expand Up @@ -368,7 +382,7 @@ add_test(NAME test_array_utils COMMAND test_array_utils.x)
${WOUT_FILE}
${CMAKE_CURRENT_BINARY_DIR}/roundtrip_test.nc
export
/tmp/boozer_chartmap_roundtrip
${CMAKE_CURRENT_BINARY_DIR}/boozer_chartmap_roundtrip
1.0e-4
1.0e-6)
set_tests_properties(test_boozer_chartmap_roundtrip PROPERTIES
Expand All @@ -381,7 +395,7 @@ add_test(NAME test_array_utils COMMAND test_array_utils.x)
wout.nc
wout_qa.gvec.chartmap.nc
external
/tmp/boozer_chartmap_gvec_qa
${CMAKE_CURRENT_BINARY_DIR}/boozer_chartmap_gvec_qa
2.5e-4
1.0e-6)
set_tests_properties(test_boozer_chartmap_gvec_qa PROPERTIES
Expand All @@ -395,19 +409,22 @@ add_test(NAME test_array_utils COMMAND test_array_utils.x)

# E2E test: VMEC-Boozer vs chartmap confined fractions
add_test(NAME test_e2e_boozer_chartmap
COMMAND ${Python_EXECUTABLE}
COMMAND ${BOOZER_CHARTMAP_PYTHON}
${CMAKE_CURRENT_SOURCE_DIR}/test_e2e_boozer_chartmap.py)
set_tests_properties(test_e2e_boozer_chartmap PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
LABELS "slow")
LABELS "slow;plot;python"
TIMEOUT 7200)

if(EXISTS "${FIGURE8_BOUNDARY_SOURCE}" AND EXISTS "${FIGURE8_CHARTMAP_SOURCE}")
add_test(NAME test_figure8_boozer_chartmap
COMMAND ${Python_EXECUTABLE}
COMMAND ${BOOZER_CHARTMAP_PYTHON}
${CMAKE_CURRENT_SOURCE_DIR}/test_figure8_boozer_chartmap.py)
set_tests_properties(test_figure8_boozer_chartmap PROPERTIES
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
LABELS "slow;plot")
LABELS "slow;plot;python;golden_record"
TIMEOUT 7200
DEPENDS test_e2e_boozer_chartmap)
endif()

if(SIMPLE_ENABLE_CGAL)
Expand Down
Loading
Loading