Skip to content

Commit

Permalink
Merge pull request #18 from ORNL-Fusion/unit_tests
Browse files Browse the repository at this point in the history
Unit tests
  • Loading branch information
cianciosa authored Sep 13, 2024
2 parents 7029689 + 877bfa3 commit f0b7beb
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ target_link_libraries (xbmw PUBLIC bmw)
add_subdirectory (Sources)

install (TARGETS xbmw)

################################################################################
# Testing #
################################################################################

add_subdirectory (Testing)
2 changes: 2 additions & 0 deletions Testing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory (tests)

1 change: 1 addition & 0 deletions Testing/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory (run_tests)
29 changes: 29 additions & 0 deletions Testing/tests/run_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Run BME. THis just tests if the code executes correctly.

# Copy input file from the source to the build directory.
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/coils.test
${CMAKE_CURRENT_BINARY_DIR}/coils.test
COPYONLY)
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/input.test.vmec
${CMAKE_CURRENT_BINARY_DIR}/input.test.vmec
COPYONLY)

add_test (NAME bmw_mgrid_test
COMMAND $<TARGET_PROPERTY:mgrid,BINARY_DIR>/mgrid coils.test)
set_tests_properties (bmw_mgrid_test
PROPERTIES
PROCESSORS $<TARGET_PROPERTY:stell,MPIEXEC_MAX_NUMPROCS>)

add_test (NAME bmw_vmec_test
COMMAND $<TARGET_PROPERTY:stell,MPIEXEC_EXECUTABLE> $<TARGET_PROPERTY:stell,MPIEXEC_NUMPROC_FLAG> $<TARGET_PROPERTY:stell,MPIEXEC_MAX_NUMPROCS> $<TARGET_PROPERTY:vmec,BINARY_DIR>/xvmec input.test.vmec)
set_tests_properties (bmw_vmec_test
PROPERTIES
DEPENDS bmw_mgrid_test
PROCESSORS $<TARGET_PROPERTY:stell,MPIEXEC_MAX_NUMPROCS>)

add_test (NAME bmw_test
COMMAND $<TARGET_PROPERTY:bmw,BINARY_DIR>/xbmw -mgrid=mgrid_test.nc -woutf=wout_test.vmec.nc -outf=result.nc -para=-1)
set_tests_properties (bmw_test
PROPERTIES
DEPENDS bmw_vmec_test
PROCESSORS $<TARGET_PROPERTY:stell,MPIEXEC_MAX_NUMPROCS>)
229 changes: 229 additions & 0 deletions Testing/tests/run_tests/coils.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,229 @@
! Simplified Coil model based on CTH.

&MGRID_NLI
MGRID_EXT = 'test'
MGRID_MODE = 'R'
LSTELL_SYM = .TRUE.
RMIN = 0.45
RMAX = 1.05
ZMIN = -0.3
ZMAX = 0.3
IR = 25
JZ = 25
KP = 18
/

** coils_dot_starts_below **
periods 5
begin filament
mirror NUL
1.13366 0. 0. 96
1.1284 0.0324661 0.0600069 96
1.11269 0.0660545 0.118482 96
1.0867 0.101324 0.173958 96
1.05079 0.1379 0.225085 96
1.00565 0.174435 0.270661 96
0.95232 0.208904 0.309637 96
0.892312 0.239152 0.341109 96
0.827436 0.263483 0.364319 96
0.759623 0.28112 0.37865 96
0.690669 0.292363 0.383661 96
0.622062 0.298452 0.379121 96
0.554917 0.301189 0.365058 96
0.490005 0.302485 0.341791 96
0.427826 0.303968 0.309939 96
0.368663 0.306766 0.270398 96
0.312606 0.311488 0.224283 96
0.259552 0.318366 0.172851 96
0.209208 0.327452 0.117433 96
0.161083 0.338787 0.0593731 96
0.114531 0.35249 5.0307E-17 96
0.0688152 0.368767 -0.0593731 96
0.0232192 0.387884 -0.117433 96
-0.0228512 0.410125 -0.172851 96
-0.0698152 0.435744 -0.224283 96
-0.117943 0.464873 -0.270398 96
-0.167451 0.497385 -0.309939 96
-0.218626 0.532733 -0.341791 96
-0.271902 0.569839 -0.365058 96
-0.327833 0.607092 -0.379121 96
-0.386916 0.642492 -0.383661 96
-0.44931 0.673926 -0.37865 96
-0.514538 0.699517 -0.364319 96
-0.581326 0.717965 -0.341109 96
-0.647652 0.728767 -0.309637 96
-0.711054 0.732224 -0.270661 96
-0.769054 0.729204 -0.225085 96
-0.8196 0.720717 -0.173958 96
-0.861359 0.707462 -0.118482 96
-0.893813 0.689523 -0.0600069 96
-0.917147 0.666346 -9.54098E-17 96
-0.931979 0.636992 0.0600069 96
-0.939011 0.600584 0.118482 96
-0.938713 0.556772 0.173958 96
-0.931165 0.506077 0.225085 96
-0.916114 0.449983 0.270661 96
-0.893234 0.390753 0.309637 96
-0.862465 0.33101 0.341109 96
-0.824281 0.273192 0.364319 96
-0.779786 0.219064 0.37865 96
-0.73061 0.169438 0.383661 96
-0.678685 0.124186 0.379121 96
-0.625972 0.0825046 0.365058 96
-0.574219 0.0433018 0.341791 96
-0.524787 0.00555449 0.309939 96
-0.478567 -0.0314838 0.270398 96
-0.435991 -0.0682541 0.224283 96
-0.397113 -0.105003 0.172851 96
-0.361724 -0.141945 0.117433 96
-0.329453 -0.179402 0.0593731 96
-0.299846 -0.217851 1.50054E-16 96
-0.272429 -0.25789 -0.0593731 96
-0.246777 -0.300157 -0.117433 96
-0.222578 -0.34523 -0.172851 96
-0.199642 -0.393561 -0.224283 96
-0.177828 -0.445415 -0.270398 96
-0.156885 -0.500818 -0.309939 96
-0.136261 -0.559495 -0.341791 96
-0.114969 -0.62083 -0.365058 96
-0.091617 -0.683843 -0.379121 96
-0.0646255 -0.747211 -0.383661 96
-0.0326245 -0.809315 -0.37865 96
0.00510449 -0.868359 -0.364319 96
0.0482928 -0.922541 -0.341109 96
0.0956033 -0.970266 -0.309637 96
0.144864 -1.01033 -0.270661 96
0.193562 -1.04198 -0.225085 96
0.239443 -1.06482 -0.173958 96
0.281019 -1.07864 -0.118482 96
0.317818 -1.08321 -0.0600069 96
0.350319 -1.07817 -1.89952E-16 96
0.379572 -1.06314 0.0600069 96
0.406662 -1.03782 0.118482 96
0.432173 -1.0022 0.173958 96
0.455864 -0.95675 0.225085 96
0.476659 -0.902522 0.270661 96
0.492963 -0.841156 0.309637 96
0.503186 -0.774737 0.341109 96
0.506279 -0.705518 0.364319 96
0.502097 -0.635573 0.37865 96
0.491482 -0.56652 0.383661 96
0.476073 -0.49939 0.379121 96
0.457927 -0.434685 0.365058 96
0.4391 -0.372549 0.341791 96
0.421296 -0.312956 0.309939 96
0.405675 -0.255824 0.270398 96
0.392843 -0.20105 0.224283 96
0.382991 -0.148468 0.172851 96
0.376075 -0.0977799 0.117433 96
0.371983 -0.0485082 0.0593731 96
0.37063 -4.94396E-17 2.498E-16 96
0.371983 0.0485082 -0.0593731 96
0.376075 0.0977799 -0.117433 96
0.382991 0.148468 -0.172851 96
0.392843 0.20105 -0.224283 96
0.405675 0.255824 -0.270398 96
0.421296 0.312956 -0.309939 96
0.4391 0.372549 -0.341791 96
0.457927 0.434685 -0.365058 96
0.476073 0.49939 -0.379121 96
0.491482 0.56652 -0.383661 96
0.502097 0.635573 -0.37865 96
0.506279 0.705518 -0.364319 96
0.503186 0.774737 -0.341109 96
0.492963 0.841156 -0.309637 96
0.476659 0.902522 -0.270661 96
0.455864 0.95675 -0.225085 96
0.432173 1.0022 -0.173958 96
0.406662 1.03782 -0.118482 96
0.379572 1.06314 -0.0600069 96
0.350319 1.07817 -2.7929E-16 96
0.317818 1.08321 0.0600069 96
0.281019 1.07864 0.118482 96
0.239443 1.06482 0.173958 96
0.193562 1.04198 0.225085 96
0.144864 1.01033 0.270661 96
0.0956033 0.970266 0.309637 96
0.0482928 0.922541 0.341109 96
0.00510449 0.868359 0.364319 96
-0.0326245 0.809315 0.37865 96
-0.0646255 0.747211 0.383661 96
-0.091617 0.683843 0.379121 96
-0.114969 0.62083 0.365058 96
-0.136261 0.559495 0.341791 96
-0.156885 0.500818 0.309939 96
-0.177828 0.445415 0.270398 96
-0.199642 0.393561 0.224283 96
-0.222578 0.34523 0.172851 96
-0.246777 0.300157 0.117433 96
-0.272429 0.25789 0.0593731 96
-0.299846 0.217851 3.50414E-16 96
-0.329453 0.179402 -0.0593731 96
-0.361724 0.141945 -0.117433 96
-0.397113 0.105003 -0.172851 96
-0.435991 0.0682541 -0.224283 96
-0.478567 0.0314838 -0.270398 96
-0.524787 -0.00555449 -0.309939 96
-0.574219 -0.0433018 -0.341791 96
-0.625972 -0.0825046 -0.365058 96
-0.678685 -0.124186 -0.379121 96
-0.73061 -0.169438 -0.383661 96
-0.779786 -0.219064 -0.37865 96
-0.824281 -0.273192 -0.364319 96
-0.862465 -0.33101 -0.341109 96
-0.893234 -0.390753 -0.309637 96
-0.916114 -0.449983 -0.270661 96
-0.931165 -0.506077 -0.225085 96
-0.938713 -0.556772 -0.173958 96
-0.939011 -0.600584 -0.118482 96
-0.931979 -0.636992 -0.0600069 96
-0.917147 -0.666346 -3.75568E-16 96
-0.893813 -0.689523 0.0600069 96
-0.861359 -0.707462 0.118482 96
-0.8196 -0.720717 0.173958 96
-0.769054 -0.729204 0.225085 96
-0.711054 -0.732224 0.270661 96
-0.647652 -0.728767 0.309637 96
-0.581326 -0.717965 0.341109 96
-0.514538 -0.699517 0.364319 96
-0.44931 -0.673926 0.37865 96
-0.386916 -0.642492 0.383661 96
-0.327833 -0.607092 0.379121 96
-0.271902 -0.569839 0.365058 96
-0.218626 -0.532733 0.341791 96
-0.167451 -0.497385 0.309939 96
-0.117943 -0.464873 0.270398 96
-0.0698152 -0.435744 0.224283 96
-0.0228512 -0.410125 0.172851 96
0.0232192 -0.387884 0.117433 96
0.0688152 -0.368767 0.0593731 96
0.114531 -0.35249 3.99854E-16 96
0.161083 -0.338787 -0.0593731 96
0.209208 -0.327452 -0.117433 96
0.259552 -0.318366 -0.172851 96
0.312606 -0.311488 -0.224283 96
0.368663 -0.306766 -0.270398 96
0.427826 -0.303968 -0.309939 96
0.490005 -0.302485 -0.341791 96
0.554917 -0.301189 -0.365058 96
0.622062 -0.298452 -0.379121 96
0.690669 -0.292363 -0.383661 96
0.759623 -0.28112 -0.37865 96
0.827436 -0.263483 -0.364319 96
0.892312 -0.239152 -0.341109 96
0.95232 -0.208904 -0.309637 96
1.00565 -0.174435 -0.270661 96
1.05079 -0.1379 -0.225085 96
1.0867 -0.101324 -0.173958 96
1.11269 -0.0660545 -0.118482 96
1.1284 -0.0324661 -0.0600069 96
1.13366 0. 0. 0.00000000000000E+00 1 HF-OVF
1.26599000000000E+00 0.00000000000000E+00 -5.23002000000000E-01 -16.0000000000000E+00 1 HF-OVF
1.26599000000000E+00 0.00000000000000E+00 5.23002000000000E-01 -16.0000000000000E+00 1 HF-OVF
1.26799000000000E+00 0.00000000000000E+00 5.73261000000000E-01 -36.0000000000000E+00 2 TVF
1.26799000000000E+00 0.00000000000000E+00 -5.73261000000000E-01 -36.0000000000000E+00 2 TVF
1.26799000000000E+00 0.00000000000000E+00 4.63502000000000E-01 -36.0000000000000E+00 2 TVF
1.26799000000000E+00 0.00000000000000E+00 -4.63502000000000E-01 -36.0000000000000E+00 2 TVF
2.51000000000000E-01 0.00000000000000E+00 4.31000000000000E-01 1.24000000000000E+02 2 TVF
2.51000000000000E-01 0.00000000000000E+00 -4.31000000000000E-01 1.24000000000000E+02 2 TVF
end
Loading

0 comments on commit f0b7beb

Please sign in to comment.