From 2d58bb04b0eef830f95772af7beb6cf6d8a0a0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Sun, 19 Dec 2021 12:56:15 +0100 Subject: [PATCH 1/4] Rationalize installation, run tests via ctest Testing via ctest leaves source folder unchanged and enables parallel test execution. Note: Python API is not tested yet --- .github/workflows/ci.yml | 39 ++- CMakeLists.txt | 235 ++++++++++--------- config.cmake | 4 + serial_interface/examples/fortran/main.F90 | 24 +- serial_interface/examples/fortran08/main.F90 | 4 +- serial_interface/tests/compare_output | 83 +++++++ serial_interface/tests/run_test_case | 31 +++ serial_interface/tests/run_tests.sh | 66 +++--- serial_interface/tests/tests | 63 +++++ 9 files changed, 373 insertions(+), 176 deletions(-) create mode 100755 serial_interface/tests/compare_output create mode 100755 serial_interface/tests/run_test_case create mode 100644 serial_interface/tests/tests diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 72e58f6..8fc3a1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,36 +17,53 @@ jobs: - name: Set up environment (Linux) if: contains(matrix.os, 'ubuntu') run: | - echo "ROOTFOLDER=${PWD}" >> $GITHUB_ENV + echo "SOURCEDIR=${PWD}" >> $GITHUB_ENV + echo "WORKDIR=${PWD}" >> $GITHUB_ENV echo "FC=gfortran" >> $GITHUB_ENV echo "CC=gcc" >> $GITHUB_ENV + echo "CXX=g++" >> $GITHUB_ENV sudo apt-get update sudo apt-get install cmake ninja-build - name: Set up environment (OSX) if: contains(matrix.os, 'macos') run: | - echo "ROOTFOLDER=${PWD}" >> $GITHUB_ENV + echo "SOURCEDIR=${PWD}" >> $GITHUB_ENV + echo "WORKDIR=${PWD}" >> $GITHUB_ENV echo "FC=gfortran-9" >> $GITHUB_ENV echo "CC=gcc-9" >> $GITHUB_ENV + echo "CXX=g++-9" >> $GITHUB_ENV brew install ninja - name: Configure build - run: >- - cmake -B _build -G Ninja - -DCMAKE_INSTALL_PREFIX=${ROOTFOLDER}/_install - -DWITH_FORTRAN08_API=1 + run: | + mkdir ${WORKDIR}/_build + cd ${WORKDIR}/_build + cmake -G Ninja -DCMAKE_INSTALL_PREFIX=${WORKDIR}/_install -DWITH_FORTRAN08_API=1 -DTEST_LABELS="minimal" ${SOURCEDIR} + cd - - name: Build project run: | - cmake --build _build + cd ${WORKDIR}/_build + ninja all + cd - + + - name: Test project + run: | + cd ${WORKDIR}/_build + ctest + cd - - name: Install project run: | - cmake --install _build + cd ${WORKDIR}/_build + ninja install + cd - - name: Run integration test run: | - CMAKE_PREFIX_PATH=${ROOTFOLDER}/_install cmake -B _build_integtest -G Ninja ${ROOTFOLDER}/serial_interface/examples/fortran08 - cmake --build _build_integtest - LD_LIBRARY_PATH=${ROOTFOLDER}/_install/lib ./_build_integtest/test_chimescalc ${ROOTFOLDER}/serial_interface/tests/force_fields/test_params.CHON.txt serial_interface/tests/configurations/CHON.testfile.000.xyz | grep "Energy (kcal/mol) -7.83714" + mkdir ${WORKDIR}/_build_integtest + cd ${WORKDIR}/_build_integtest + CMAKE_PREFIX_PATH=${WORKDIR}/_install cmake -G Ninja ${SOURCEDIR}/serial_interface/examples/fortran08 + ninja all + LD_LIBRARY_PATH=${WORKDIR}/_install/lib ./test_chimescalc ${SOURCEDIR}/serial_interface/tests/force_fields/test_params.CHON.txt ${SOURCEDIR}/serial_interface/tests/configurations/CHON.testfile.000.xyz | grep "Energy (kcal/mol): -7.83714" diff --git a/CMakeLists.txt b/CMakeLists.txt index c3f26b8..ffbe219 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.13) -############################################################ +#################################################################################################### # General settings -############################################################ +#################################################################################################### project(ChimesCalc VERSION 1.0 @@ -29,9 +29,9 @@ if(NEEDS_LIB_M) endif() -############################################################################### -# C++/C library -############################################################################### +#################################################################################################### +# Static/shared library +#################################################################################################### set(c-sources "chimesFF/src/chimesFF.cpp" @@ -65,102 +65,61 @@ target_compile_features(ChimesCalc PRIVATE cxx_std_11) install(TARGETS ChimesCalc EXPORT ${PROJECT_NAME_LOWER}-targets LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" - PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${INSTALL_INCLUDEDIR}") + PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDEDIR}") -############################################################ +#################################################################################################### # Executables for C/C++ -############################################################ +#################################################################################################### -add_executable(CPP-interface serial_interface/examples/cpp/main.cpp) -target_link_libraries(CPP-interface ChimesCalc) -target_compile_features (CPP-interface PUBLIC cxx_std_11) -target_compile_definitions(CPP-interface PRIVATE "DEBUG=${DEBUG}") +# Main executable installed as chimescalc +add_executable(chimescalc serial_interface/examples/cpp/main.cpp) +target_link_libraries(chimescalc ChimesCalc) +target_compile_features (chimescalc PUBLIC cxx_std_11) +target_compile_definitions(chimescalc PRIVATE "DEBUG=${DEBUG}") +install(TARGETS chimescalc DESTINATION ${CMAKE_INSTALL_BINDIR}) -if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS CPP-interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial_interface/examples/cpp/ OPTIONAL) -endif() - -add_executable(C_wrapper-direct_interface chimesFF/examples/c/main.c) -target_link_libraries (C_wrapper-direct_interface ChimesCalc ${LIB_M}) -target_compile_features (C_wrapper-direct_interface PRIVATE cxx_std_11) -target_compile_definitions(C_wrapper-direct_interface PRIVATE "DEBUG=${DEBUG}") - - -if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS C_wrapper-direct_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/chimesFF/examples/c/ OPTIONAL) -endif() - - -add_executable(C_wrapper-serial_interface serial_interface/examples/c/main.c) -target_link_libraries (C_wrapper-serial_interface ChimesCalc) -target_compile_features (C_wrapper-serial_interface PRIVATE cxx_std_11) -target_compile_definitions(C_wrapper-serial_interface PRIVATE "DEBUG=${DEBUG}") - -if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS C_wrapper-serial_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial_interface/examples/c/ OPTIONAL) -endif() +# Test executables +add_executable(test_c_direct chimesFF/examples/c/main.c) +target_link_libraries (test_c_direct ChimesCalc ${LIB_M}) +target_compile_features (test_c_direct PRIVATE cxx_std_11) +target_compile_definitions(test_c_direct PRIVATE "DEBUG=${DEBUG}") +add_executable(test_c_serial serial_interface/examples/c/main.c) +target_link_libraries (test_c_serial ChimesCalc) +target_compile_features (test_c_serial PRIVATE cxx_std_11) +target_compile_definitions(test_c_serial PRIVATE "DEBUG=${DEBUG}") -############################################################ -# Executables/libraries for Python -############################################################ +#################################################################################################### +# Dynamically loadable library (e.g for Python) +#################################################################################################### -# Shared: .dylib -# Static: .a -# Module: .so +add_library(ChimesCalc_dynamic MODULE "${c-sources}") -add_library(lib-C_wrapper-direct_interface MODULE - ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/api/chimescalc_C.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/src/chimesFF.cpp) +set_target_properties(ChimesCalc_dynamic + PROPERTIES OUTPUT_NAME "chimescalc_dl") -# Prevent CMake from prepending "lib" to libwrapper-C.so -set_target_properties (lib-C_wrapper-direct_interface PROPERTIES PREFIX "") -# Tell it which language to use -set_target_properties (lib-C_wrapper-direct_interface PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(lib-C_wrapper-direct_interface - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/src/) -target_include_directories(lib-C_wrapper-direct_interface - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/api/) -target_compile_features (lib-C_wrapper-direct_interface PUBLIC cxx_std_11) - -if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS lib-C_wrapper-direct_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/chimesFF/examples/python/ OPTIONAL) -endif() +target_include_directories(ChimesCalc_dynamic PUBLIC + $ + $ + $ + $ + $) +target_compile_definitions(ChimesCalc_dynamic PRIVATE "DEBUG=${DEBUG}") +target_compile_features(ChimesCalc_dynamic PRIVATE cxx_std_11) -add_library(lib-C_wrapper-serial_interface MODULE - ${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/api/chimescalc_serial_C.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/src/serial_chimes_interface.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/src/chimesFF.cpp) - -# Prevent CMake from prepending "lib" to libwrapper-C.so -set_target_properties (lib-C_wrapper-serial_interface PROPERTIES PREFIX "") -# Tell it which language to use -set_target_properties (lib-C_wrapper-serial_interface PROPERTIES LINKER_LANGUAGE CXX) -target_include_directories(lib-C_wrapper-serial_interface - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/api/) -target_include_directories(lib-C_wrapper-serial_interface - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/src/) -target_include_directories(lib-C_wrapper-serial_interface - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/chimesFF/src/) -target_compile_features (lib-C_wrapper-serial_interface PUBLIC cxx_std_11) - -if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS lib-C_wrapper-serial_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial_interface/examples/python/ OPTIONAL) -endif() +install(TARGETS ChimesCalc_dynamic + EXPORT ${PROJECT_NAME_LOWER}-targets + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDEDIR}") -############################################################################### -# Fortran library (separate library as it needs Fortran runtime to be linked) -############################################################################### +#################################################################################################### +# Fortran wrappers (not contained in base library as it requires Fortran runtime library) +#################################################################################################### if(WITH_FORTRAN_API OR WITH_FORTRAN08_API) @@ -196,47 +155,26 @@ if(WITH_FORTRAN_API OR WITH_FORTRAN08_API) install(DIRECTORY "${moddir}/" DESTINATION "${INSTALL_MODULEDIR}") - ############################################################ + ################################################################################################ # Executables for Fortran (90/08) - ############################################################ - - add_executable(fortran_wrapper-direct_interface chimesFF/examples/fortran/main.F90) - target_link_libraries (fortran_wrapper-direct_interface ChimesCalc_Fortran) - target_compile_definitions(fortran_wrapper-direct_interface PRIVATE "DEBUG=${DEBUG}") - - if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS fortran_wrapper-direct_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/chimesFF/examples/fortran/ OPTIONAL) - endif() - + ################################################################################################ - add_executable(fortran_wrapper-serial_interface serial_interface/examples/fortran/main.F90) - target_link_libraries (fortran_wrapper-serial_interface ChimesCalc_Fortran) - target_compile_definitions(fortran_wrapper-serial_interface PRIVATE "DEBUG=${DEBUG}") - - if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS fortran_wrapper-direct_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial_interface/examples/fortran/ OPTIONAL) - endif() + add_executable(test_fortran_serial serial_interface/examples/fortran/main.F90) + target_link_libraries(test_fortran_serial ChimesCalc_Fortran) + target_compile_definitions(test_fortran_serial PRIVATE "DEBUG=${DEBUG}") # Optional, as ancient Fortran compilers may have difficulties with it if(WITH_FORTRAN08_API) - add_executable(fortran08_wrapper-serial_interface - serial_interface/examples/fortran08/main.F90) - target_link_libraries (fortran08_wrapper-serial_interface ChimesCalc_Fortran) - target_compile_definitions(fortran08_wrapper-serial_interface PRIVATE "DEBUG=${DEBUG}") - - if(NOT CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - install(TARGETS fortran08_wrapper-serial_interface - DESTINATION ${CMAKE_INSTALL_PREFIX}/serial_interface/examples/fortran08/ OPTIONAL) - endif() + add_executable(test_fortran08_serial serial_interface/examples/fortran08/main.F90) + target_link_libraries(test_fortran08_serial ChimesCalc_Fortran) + target_compile_definitions(test_fortran08_serial PRIVATE "DEBUG=${DEBUG}") endif() endif() -############################################################################### +#################################################################################################### # Create CMake export file -############################################################################### +#################################################################################################### include(CMakePackageConfigHelpers) @@ -260,3 +198,68 @@ install( FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME_LOWER}-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME_LOWER}") + + +#################################################################################################### +# Add regression tests for the various APIs +#################################################################################################### + +enable_testing() + +set(apis + "cpp;${CMAKE_CURRENT_BINARY_DIR}/chimescalc" + "c;${CMAKE_CURRENT_BINARY_DIR}/test_c_serial" + "fortran;${CMAKE_CURRENT_BINARY_DIR}/test_fortran_serial" + "fortran08;${CMAKE_CURRENT_BINARY_DIR}/test_fortran08_serial") + +set(_testdir "${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/tests") +file(STRINGS ${_testdir}/tests _testcases) +foreach(_testcase IN LISTS _testcases) + if("${_testcase}" STREQUAL "") + continue() + endif() + list(GET _testcase 0 _paramfile) + string(STRIP "${_paramfile}" _paramfile) + list(GET _testcase 1 _geometry) + string(STRIP "${_geometry}" _geometry) + string(REPLACE "#" "" _geometry_escaped "${_geometry}") + list(GET _testcase 2 _configopt) + string(STRIP "${_configopt}" _configopt) + list(GET _testcase 3 _testlabels) + string(STRIP "${_testlabels}" _testlabels) + + set(_add_test False) + foreach(_label IN LISTS TEST_LABELS) + if("${_testlabels}" MATCHES "${_label}") + set(_add_test True) + break() + endif() + endforeach() + if(NOT _add_test) + continue() + endif() + + set(_apis "${apis}") + list(LENGTH _apis _apis_length ) + while(_apis_length GREATER 0) + list(POP_FRONT _apis _api_abbrev) + list(POP_FRONT _apis _api_executable) + #message(STATUS "Test added: ${_api_abbrev}:${_paramfile}:${_geometry_escaped}") + list(LENGTH _apis _apis_length) + + add_test( + NAME "${_api_abbrev}/${_paramfile}:${_geometry_escaped}" + COMMAND + ${_testdir}/run_test_case + ${_api_executable} + ${_paramfile} + ${_geometry} + ${_configopt} + ${CMAKE_CURRENT_BINARY_DIR}/_test/${_api_abbrev}/${_paramfile}:${_geometry_escaped}) + if("${_api_abbrev}" STREQUAL "py") + set_tests_properties("${_api_abbrev}/${_paramfile}:${_geometry_escaped}" + PROPERTIES ENVIRONMENT "PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}" + ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_CURRENT_BINARY_DIR}") + endif() + endwhile() +endforeach() diff --git a/config.cmake b/config.cmake index c567648..a98cf2f 100644 --- a/config.cmake +++ b/config.cmake @@ -14,6 +14,10 @@ option(WITH_FORTRAN08_API "Whether the Fortran 2008 style API should be built" T # Turn this on, if the libraries should be built as shared libraries option(BUILD_SHARED_LIBS "Whether the libraries built should be shared" TRUE) +# Test cases with labels matching the specified regexps will be included as tests in CMake builds +# (You can still select subsets of the selected tests by name using the -R option of ctest) +set(TEST_LABELS ".*" CACHE STRING "List of test label regexps to include as test in CMake builds") + # C++ compiler dependent config options if("GNU" STREQUAL "${CMAKE_CXX_COMPILER_ID}") diff --git a/serial_interface/examples/fortran/main.F90 b/serial_interface/examples/fortran/main.F90 index 4320859..ba55ad0 100644 --- a/serial_interface/examples/fortran/main.F90 +++ b/serial_interface/examples/fortran/main.F90 @@ -8,10 +8,9 @@ program test_F_api implicit none integer io_num, stat, small double precision, parameter :: GPa = 6.9479 ! convert kcal/mol.A^3 to GPa - character(C_char), dimension(80) :: c_file - character(C_char), dimension(80) :: dummy_var - character(80) :: coord_file, param_file - CHARACTER ( len = 100 ) :: wq_char + character(C_char), dimension(1025) :: c_file + character(1024) :: coord_file, param_file + CHARACTER ( len = 1024 ) :: wq_char integer :: i, j, k, l, natom, ns real(C_double) :: lx, ly, lz real(C_double) :: stress(9) @@ -78,34 +77,33 @@ program test_F_api energy = 0d0 call f_set_chimes(small) - + print*,"fcheck-1" - c_file = string2Cstring(param_file) - call f_init_chimes(c_file, 0) ! last '0' is the rank of the process - + call f_init_chimes(trim(param_file) // c_null_char, 0) ! last '0' is the rank of the process + print*,"fcheck-2" - + stress(:) = 0d0 do ns = 1, natom stringPtr(ns) = c_loc(c_atom(ns)) enddo - + print*,"fcheck-3" call f_calculate_chimes (natom, xc, yc, zc, stringPtr, ca, & & cb, cc, energy, fx, fy, fz, stress) print *, "Success!" - print '(A,1X, F0.6)', "Energy (kcal/mol)",energy - print *, "Stress tensors (GPa)" + print '(A,1X, F0.6)', "Energy (kcal/mol):",energy + print *, "Stress tensors (GPa):" print '(A,1X, F15.6)', "s_xx: ",stress(1)*GPa print '(A,1X, F15.6)', "s_yy: ",stress(5)*GPa print '(A,1X, F15.6)', "s_zz: ",stress(9)*GPa print '(A,1X, F15.6)', "s_xy: ",stress(2)*GPa print '(A,1X, F15.6)', "s_xz: ",stress(3)*GPa print '(A,1X, F15.6)', "s_yz: ",stress(6)*GPa - print *, "Forces (kcal/mol)" + print *, "Forces (kcal/mol/A):" do i = 1, natom print '(F15.6)',fx(i) print '(F15.6)',fy(i) diff --git a/serial_interface/examples/fortran08/main.F90 b/serial_interface/examples/fortran08/main.F90 index 62ab12b..26b06a7 100644 --- a/serial_interface/examples/fortran08/main.F90 +++ b/serial_interface/examples/fortran08/main.F90 @@ -70,7 +70,7 @@ program test_F08_api call chimes%calculate(coords, latvecs, energy, forces, stress) print *, "Success!" - print '(A,1X, F0.6)', "Energy (kcal/mol)", energy + print '(A,1X, F0.6)', "Energy (kcal/mol):", energy print *, "Stress tensors (GPa)" print '(A,1X, F15.6)', "s_xx: ", stress(1, 1) * GPa print '(A,1X, F15.6)', "s_yy: ", stress(2, 2) * GPa @@ -78,7 +78,7 @@ program test_F08_api print '(A,1X, F15.6)', "s_xy: ", stress(1, 2) * GPa print '(A,1X, F15.6)', "s_xz: ", stress(1, 3) * GPa print '(A,1X, F15.6)', "s_yz: ", stress(2, 3) * GPa - print *, "Forces (kcal/mol)" + print *, "Forces (kcal/mol/A)" print '(F15.6)', forces #if DEBUG==1 diff --git a/serial_interface/tests/compare_output b/serial_interface/tests/compare_output new file mode 100755 index 0000000..12953fc --- /dev/null +++ b/serial_interface/tests/compare_output @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +"""Compares the output of a ChIMES executable with stored reference data. + +Returns with non-zero exit code, if reference and output data do not match. + +Note: The script parses the ChIMES output in a very simple minded way. If the output changes, the +parsing algorithm must be adapted accordingly. +""" + +import re +import sys + +_FLOAT_REGEXP = r"[+-]?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?" +_FLOAT_PATTERN = re.compile(_FLOAT_REGEXP) + +_ENERGY_PATTERN = re.compile( + r"^\s*Energy \(kcal/mol\):?\s+(?P{})\s*$".format(_FLOAT_REGEXP), + re.MULTILINE) + +_STRESS_PATTERN = re.compile( + r"^\s*s_[xyz][xyz]:\s*(?P{})\s*$".format(_FLOAT_REGEXP), + re.MULTILINE) + +_FORCES_PATTERN = re.compile( + r"^\s*Forces \(kcal/mol/A\):?\s*(?P(?:\s*{}\s*)+)".format(_FLOAT_REGEXP), + re.MULTILINE) + +# Absolute tolerance when comparing data +_ABS_TOLERANCE = 1e-3 + + +def main(): + outfile = sys.argv[1] + reffile = sys.argv[2] + + with open(outfile) as fp: + outcontent = fp.read() + with open(reffile) as fp: + refcontent = fp.read() + + outdata = _parse_output(outcontent) + refdata = _parse_reference(refcontent) + match = _check_error(outdata, refdata) + if not match: + sys.exit(1) + + +def _parse_output(content): + """Parser the ChIMES output for energy, stress tensor and forces""" + data = [] + match = _ENERGY_PATTERN.search(content) + data.append(float(match.group("energy"))) + data += [float(m.group("stress")) + for m in _STRESS_PATTERN.finditer(content)] + match = _FORCES_PATTERN.search(content) + data += [float(s) for s in match.group("forces").split()] + return data + + +def _parse_reference(content): + """Returns all floats in the content as list.""" + data = [float(match.group(0)) for match in _FLOAT_PATTERN.finditer(content)] + return data + + +def _check_error(outdata, refdata): + "Cheks whether two list of float data are within a certain tolerance""" + + if len(outdata) != len(refdata): + print("Mismatching data list lengths! Expected: {:d}, obtained {:d}."\ + .format(len(refdata), len(outdata))) + return False + match = True + for outval, refval in zip(outdata, refdata): + if abs(outval - refval) > _ABS_TOLERANCE: + match = False + print("Mismatching values! Expected {:12.6f}, obtained {:12.6f}."\ + .format(refval, outval)) + return match + + +if __name__ == "__main__": + main() diff --git a/serial_interface/tests/run_test_case b/serial_interface/tests/run_test_case new file mode 100755 index 0000000..9c67b5d --- /dev/null +++ b/serial_interface/tests/run_test_case @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +SCRIPT_DIR=$(dirname $0) +SCRIPT_NAME=$(basename $0) + +if [ $# -ne 5 ]; then + echo "Wrong nr. of parameters" >&2 + echo "run_test_case BINARY PARAMETERFILE GEOMETRYFILE CONFIGOPT WORKDIR" >&2 + exit 1 +fi + +binary=$1 +parameterfile=$2 +geometryfile=$3 +configopt=$4 +workdir=$5 + +if [ ! -d ${workdir} ]; then + mkdir -p ${workdir} +fi + +cd ${workdir} +${binary} \ + ${SCRIPT_DIR}/force_fields/${parameterfile} \ + ${SCRIPT_DIR}/configurations/${geometryfile} \ + ${configopt} >& output + +${SCRIPT_DIR}/compare_output \ + output \ + ${SCRIPT_DIR}/expected_output/${parameterfile}.${geometryfile}.dat diff --git a/serial_interface/tests/run_tests.sh b/serial_interface/tests/run_tests.sh index aa6987b..229404a 100755 --- a/serial_interface/tests/run_tests.sh +++ b/serial_interface/tests/run_tests.sh @@ -44,39 +44,39 @@ API[4]="fortran08"; EXE[4]="fortran08_wrapper-serial_interface" ; XTRA[4]="" #"0 echo "Running $STYLE tests" date -for compile in MAKEFILE CMAKE +for compile in MAKEFILE do echo "Testing compilation type: $compile" # Do the compilation if [[ $compile == "MAKEFILE" ]]; then - + for i in $API_LIST # Cycle through APIs do - cd ../examples/${API[$i]} - + cd ../examples/${API[$i]} + echo "Compiling for API ${API[$i]}" echo "" if [[ "${API[$i]}" != "python" ]] ; then - + make all DEBUG=1 else make all cp lib-C_wrapper-serial_interface.so ../../tests fi - + cd ../../tests - - done - + + done + elif [[ $compile == "CMAKE" ]] ; then - + cd ../../ ./install.sh 1 $PREFX # Set the debug flag true - cp build/lib-C_wrapper-serial_interface.so serial_interface/tests - cd - + cp build/lib-C_wrapper-serial_interface.so serial_interface/tests + cd - else echo "Error: Unknown compilation method $compile" @@ -84,64 +84,64 @@ do echo "Check logic in run_test.sh" exit 0 fi - + # Run the tasks - + for i in $API_LIST # Cycle through APIs - do - + do + idx=1 for ((j=0;j /dev/null else ../examples/${API[$i]}/${EXE[$i]} force_fields/${FFS[$j]} configurations/$CFG ${OPTIONS[$j]} > /dev/null fi - - else - ${PYTH3} ../examples/${API[$i]}/${EXE[$i]} force_fields/${FFS[$j]} configurations/$CFG ${OPTIONS[$j]} ${LOC}/../api 1 > /dev/null + + else + ${PYTH3} ../examples/${API[$i]}/${EXE[$i]} force_fields/${FFS[$j]} configurations/$CFG ${OPTIONS[$j]} ${LOC}/../api 1 > /dev/null fi - + # Compare results against expected results (expected_output/${FFS[$j]}.$CFG.dat) - + paste debug.dat expected_output/${FFS[$j]}.$CFG.dat > san.dat # Print findings - - ${PYTH3} compare.py san.dat + + ${PYTH3} compare.py san.dat if [[ $STYLE == "SHORT" ]] ; then break fi - + done - + echo " Test $idx of $NO_TESTS for API ${API[$i]} complete" let idx=idx+1 - + done done @@ -163,5 +163,3 @@ rm -f debug.dat san.dat *.so cd ../../ ./uninstall.sh $PREFX - - diff --git a/serial_interface/tests/tests b/serial_interface/tests/tests new file mode 100644 index 0000000..5ede477 --- /dev/null +++ b/serial_interface/tests/tests @@ -0,0 +1,63 @@ +test_params.CHON.txt; CHON.testfile_#000.xyz; 0; minimal + +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#000.xyz; 0; short +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#001.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#002.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#003.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#004.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#005.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#006.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#007.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#008.xyz; 0; long +published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#009.xyz; 0; long + +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#000.xyz; 0; short +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#001.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#002.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#003.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#004.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#005.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#006.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#007.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#008.xyz; 0; long +published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#009.xyz; 0; long + +validated_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.relabel.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.xyz; 1; short +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#001.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#002.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#003.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#004.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#005.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#006.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#007.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#008.xyz; 1; long +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#009.xyz; 1; long + +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.scramble.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.translate.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.64_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.16_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.8_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.2_#000.xyz; 1; short + +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#000.xyz; 0; short +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#001.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#002.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#003.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#004.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#006.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#007.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#008.xyz; 0; long +published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#009.xyz; 0; long + +validated_params.TiO2.2+3b.Tersoff.txt; TiO2.unitcell_arbrot_#000.xyz; 0; short +validated_params.TiO2.2+3b.Tersoff.txt; TiO2.unitcell_arbrot_#001.xyz; 0; long + +published_params.CO2400K.2+3+4b.Tersoff.special.offsets.txt; CO.9GPa_2400K.OUTCAR_#000.xyz; 1; short From 836193d3bd4c206268bdbc8e814f012989fa885f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Mon, 20 Dec 2021 11:48:47 +0100 Subject: [PATCH 2/4] Fix dependency problems due to ambiguous naming --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffbe219..4d62cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,12 +73,13 @@ install(TARGETS ChimesCalc #################################################################################################### # Main executable installed as chimescalc -add_executable(chimescalc serial_interface/examples/cpp/main.cpp) -target_link_libraries(chimescalc ChimesCalc) -target_compile_features (chimescalc PUBLIC cxx_std_11) -target_compile_definitions(chimescalc PRIVATE "DEBUG=${DEBUG}") +add_executable(ChimesCalcExe serial_interface/examples/cpp/main.cpp) +set_target_properties(ChimesCalcExe PROPERTIES OUTPUT_NAME "chimescalc") +target_link_libraries(ChimesCalcExe ChimesCalc) +target_compile_features (ChimesCalcExe PUBLIC cxx_std_11) +target_compile_definitions(ChimesCalcExe PRIVATE "DEBUG=${DEBUG}") -install(TARGETS chimescalc DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS ChimesCalcExe DESTINATION ${CMAKE_INSTALL_BINDIR}) # Test executables add_executable(test_c_direct chimesFF/examples/c/main.c) From fd0fb5da9e8784ddc7c32c4af23e0378c4e9e341 Mon Sep 17 00:00:00 2001 From: "Lindsey, Rebecca Kristine" Date: Thu, 6 Jan 2022 21:05:56 -0800 Subject: [PATCH 3/4] Update file naming conventions for test suite compatibility. --- CMakeLists.txt | 38 ++++++++-------- chimesFF/api/chimescalc_py.py | 5 +-- chimesFF/examples/c/Makefile | 4 +- chimesFF/examples/cpp/Makefile | 4 +- chimesFF/examples/fortran/Makefile | 4 +- chimesFF/examples/python/Makefile | 2 +- chimesFF/examples/python/main.py | 4 +- pull_request_template.md | 3 +- serial_interface/api/chimescalc_serial_py.py | 5 +-- serial_interface/examples/c/Makefile | 4 +- serial_interface/examples/cpp/Makefile | 4 +- serial_interface/examples/fortran/Makefile | 8 ++-- serial_interface/examples/fortran08/Makefile | 8 ++-- serial_interface/examples/python/Makefile | 2 +- serial_interface/examples/python/main.py | 8 ++-- .../tests/{compare_output => compare.sh} | 0 .../{run_test_case => run_single_test.sh} | 4 +- serial_interface/tests/run_tests.sh | 43 +++++++++---------- .../tests/{tests => test_list.dat} | 24 +++++------ 19 files changed, 84 insertions(+), 90 deletions(-) rename serial_interface/tests/{compare_output => compare.sh} (100%) rename serial_interface/tests/{run_test_case => run_single_test.sh} (81%) rename serial_interface/tests/{tests => test_list.dat} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d62cab..bc4ff5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,15 +82,15 @@ target_compile_definitions(ChimesCalcExe PRIVATE "DEBUG=${DEBUG}") install(TARGETS ChimesCalcExe DESTINATION ${CMAKE_INSTALL_BINDIR}) # Test executables -add_executable(test_c_direct chimesFF/examples/c/main.c) -target_link_libraries (test_c_direct ChimesCalc ${LIB_M}) -target_compile_features (test_c_direct PRIVATE cxx_std_11) -target_compile_definitions(test_c_direct PRIVATE "DEBUG=${DEBUG}") +add_executable(chimescalc-test_direct-C chimesFF/examples/c/main.c) +target_link_libraries (chimescalc-test_direct-C ChimesCalc ${LIB_M}) +target_compile_features (chimescalc-test_direct-C PRIVATE cxx_std_11) +target_compile_definitions(chimescalc-test_direct-C PRIVATE "DEBUG=${DEBUG}") -add_executable(test_c_serial serial_interface/examples/c/main.c) -target_link_libraries (test_c_serial ChimesCalc) -target_compile_features (test_c_serial PRIVATE cxx_std_11) -target_compile_definitions(test_c_serial PRIVATE "DEBUG=${DEBUG}") +add_executable(chimescalc-test_serial-C serial_interface/examples/c/main.c) +target_link_libraries (chimescalc-test_serial-C ChimesCalc) +target_compile_features (chimescalc-test_serial-C PRIVATE cxx_std_11) +target_compile_definitions(chimescalc-test_serial-C PRIVATE "DEBUG=${DEBUG}") #################################################################################################### @@ -160,15 +160,15 @@ if(WITH_FORTRAN_API OR WITH_FORTRAN08_API) # Executables for Fortran (90/08) ################################################################################################ - add_executable(test_fortran_serial serial_interface/examples/fortran/main.F90) - target_link_libraries(test_fortran_serial ChimesCalc_Fortran) - target_compile_definitions(test_fortran_serial PRIVATE "DEBUG=${DEBUG}") + add_executable(chimescalc-test_serial-F serial_interface/examples/fortran/main.F90) + target_link_libraries(chimescalc-test_serial-F ChimesCalc_Fortran) + target_compile_definitions(chimescalc-test_serial-F PRIVATE "DEBUG=${DEBUG}") # Optional, as ancient Fortran compilers may have difficulties with it if(WITH_FORTRAN08_API) - add_executable(test_fortran08_serial serial_interface/examples/fortran08/main.F90) - target_link_libraries(test_fortran08_serial ChimesCalc_Fortran) - target_compile_definitions(test_fortran08_serial PRIVATE "DEBUG=${DEBUG}") + add_executable(chimescalc-test_serial-F08 serial_interface/examples/fortran08/main.F90) + target_link_libraries(chimescalc-test_serial-F08 ChimesCalc_Fortran) + target_compile_definitions(chimescalc-test_serial-F08 PRIVATE "DEBUG=${DEBUG}") endif() endif() @@ -209,12 +209,12 @@ enable_testing() set(apis "cpp;${CMAKE_CURRENT_BINARY_DIR}/chimescalc" - "c;${CMAKE_CURRENT_BINARY_DIR}/test_c_serial" - "fortran;${CMAKE_CURRENT_BINARY_DIR}/test_fortran_serial" - "fortran08;${CMAKE_CURRENT_BINARY_DIR}/test_fortran08_serial") + "c;${CMAKE_CURRENT_BINARY_DIR}/chimescalc-test_serial-C" + "fortran;${CMAKE_CURRENT_BINARY_DIR}/chimescalc-test_serial-F" + "fortran08;${CMAKE_CURRENT_BINARY_DIR}/chimescalc-test_serial-F08") set(_testdir "${CMAKE_CURRENT_SOURCE_DIR}/serial_interface/tests") -file(STRINGS ${_testdir}/tests _testcases) +file(STRINGS ${_testdir}/test_list.dat _testcases) foreach(_testcase IN LISTS _testcases) if("${_testcase}" STREQUAL "") continue() @@ -251,7 +251,7 @@ foreach(_testcase IN LISTS _testcases) add_test( NAME "${_api_abbrev}/${_paramfile}:${_geometry_escaped}" COMMAND - ${_testdir}/run_test_case + ${_testdir}/run_single_test.sh ${_api_executable} ${_paramfile} ${_geometry} diff --git a/chimesFF/api/chimescalc_py.py b/chimesFF/api/chimescalc_py.py index dc6af64..647dccc 100644 --- a/chimesFF/api/chimescalc_py.py +++ b/chimesFF/api/chimescalc_py.py @@ -2,13 +2,10 @@ A simple python interface for chimesFF access. - Expects "libwrapper-C.so" in the same directory as this script - - The following must be included in any python script calling this wrapper: import chimescalc_py - chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("/path/to/lib-C_wrapper-direct_interface.so") + chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("libchimescalc-direct_dl.so") chimescalc_py.set_chimes() chimescalc_py.init_chimes() chimescalc_py.read_params("some_parameter_file.txt") diff --git a/chimesFF/examples/c/Makefile b/chimesFF/examples/c/Makefile index 079f024..d6573d8 100644 --- a/chimesFF/examples/c/Makefile +++ b/chimesFF/examples/c/Makefile @@ -22,14 +22,14 @@ test_wrapper-C.o : main.c $(WRAPPER_SRC) $(WRAPPER_HDR) LINKS = chimesFF.o test_wrapper-C.o chimescalc_C.o test_wrapper-C : $(LINKS) - $(CXX) $(LINKS) -o C_wrapper-direct_interface + $(CXX) $(LINKS) -o chimescalc-test_direct-C clean: rm -f *.o clean-all: rm -f *.o - rm -f C_wrapper-direct_interface + rm -f chimescalc-test_direct-C all: make chimesFF.o diff --git a/chimesFF/examples/cpp/Makefile b/chimesFF/examples/cpp/Makefile index 29da334..94bc6d9 100644 --- a/chimesFF/examples/cpp/Makefile +++ b/chimesFF/examples/cpp/Makefile @@ -6,6 +6,6 @@ CXX_SRC = main.cpp $(CXX_LOC)/../../../serial_interface/src/serial_chimes_interf CXX_HDR = $(CXX_LOC)/../../../serial_interface/src/serial_chimes_interface.h $(CXX_LOC)/../../src/chimesFF.h all: $(CXX_SRC) $(CXX_HDR) - $(CXX) $(CXX_SRC) -o CPP-interface -I $(CXX_LOC)/../../src -I $(CXX_LOC)/../../../serial_interface/src/ + $(CXX) $(CXX_SRC) -o chimescalc -I $(CXX_LOC)/../../src -I $(CXX_LOC)/../../../serial_interface/src/ clean: - rm -f CPP-interface + rm -f chimescalc diff --git a/chimesFF/examples/fortran/Makefile b/chimesFF/examples/fortran/Makefile index 1b75181..c27ec1a 100644 --- a/chimesFF/examples/fortran/Makefile +++ b/chimesFF/examples/fortran/Makefile @@ -36,14 +36,14 @@ else endif test_wrapper-F: $(LINKS) - $(FCC) $(LINKS) -o fortran_wrapper-direct_interface + $(FCC) $(LINKS) -o chimescalc-test_direct-F clean: rm -f *.o *.mod clean-all: rm -f *.o *.mod - rm -f fortran_wrapper-direct_interface + rm -f chimescalc-test_direct-F all: make chimesFF.o diff --git a/chimesFF/examples/python/Makefile b/chimesFF/examples/python/Makefile index ae1fa90..c03e152 100644 --- a/chimesFF/examples/python/Makefile +++ b/chimesFF/examples/python/Makefile @@ -15,7 +15,7 @@ chimescalc_C.o : $(CC_WRAPPER_SRC) $(CC_WRAPPER_HDR) $(CHIMESFF_SRC) $(CHIMESFF $(CXX) -c $(CC_WRAPPER_SRC) $(CHIMESFF_SRC) -I $(CC_LOC)/../../api/ -I $(CC_LOC)/../../src/ chimescalc_C.so: - $(CXX) -shared -o lib-C_wrapper-direct_interface.so chimescalc_C.o chimesFF.o + $(CXX) -shared -o libchimescalc-direct_dl.so chimescalc_C.o chimesFF.o clean: diff --git a/chimesFF/examples/python/main.py b/chimesFF/examples/python/main.py index 204f9ef..b8ec185 100644 --- a/chimesFF/examples/python/main.py +++ b/chimesFF/examples/python/main.py @@ -3,7 +3,7 @@ A simple usage example for computing system force, stress, and energy via the chimesFF python wrapper. - Expects "lib-C_wrapper-serial_interface.so" in the same directory as this script. This file + Expects "libchimescalc-direct_dl.so" in the same directory as this script. This file can be generated by typing "make all" in the directory containing this file Expects to be run with python version 3.X @@ -47,7 +47,7 @@ def get_dist(lx,ly,lz,xrd,ycrd,zcrd,i,j): # Initialize the ChIMES calculator -chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("lib-C_wrapper-direct_interface.so") +chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("libchimescalc-direct_dl.so") chimescalc_py.set_chimes() chimescalc_py.init_chimes() diff --git a/pull_request_template.md b/pull_request_template.md index 1c831fc..69fc76d 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -1,4 +1,5 @@ -## Pull request template +## Items to be completed prior to PR review +# Note: If not completed, submit as a draft PR - [ ] Requested `develop` as target branch - [ ] Attached test suite log file diff --git a/serial_interface/api/chimescalc_serial_py.py b/serial_interface/api/chimescalc_serial_py.py index 46fb753..da3abfd 100644 --- a/serial_interface/api/chimescalc_serial_py.py +++ b/serial_interface/api/chimescalc_serial_py.py @@ -2,13 +2,10 @@ A simple python interface for the serial_chimes_interface. - Expects "libwrapper-C.so" in the same directory as this script - - The following must be included in any python script calling this wrapper: import wrapper_py - wrapper_py.chimes_wrapper = wrapper_py.init_chimes_wrapper("/path/to/lib-C_wrapper-serial_interface.so") + wrapper_py.chimes_wrapper = wrapper_py.init_chimes_wrapper("/path/to/libchimescalc_dl.so") wrapper_py.set_chimes() wrapper_py.init_chimes() wrapper_py.read_params("some_parameter_file.txt") diff --git a/serial_interface/examples/c/Makefile b/serial_interface/examples/c/Makefile index d40fbaa..74216a2 100644 --- a/serial_interface/examples/c/Makefile +++ b/serial_interface/examples/c/Makefile @@ -34,14 +34,14 @@ main.o: $(TEST_SRC) TEST_LNK = chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o main.o test-C: $(TEST_LNK) - $(CXX) $(TEST_LNK) -o C_wrapper-serial_interface + $(CXX) $(TEST_LNK) -o chimescalc-test_serial-C clean: rm -f *.o clean-all: make clean - rm -f C_wrapper-serial_interface + rm -f chimescalc-test_serial-C all: make chimesFF.o diff --git a/serial_interface/examples/cpp/Makefile b/serial_interface/examples/cpp/Makefile index 26bcbd8..181fcf3 100644 --- a/serial_interface/examples/cpp/Makefile +++ b/serial_interface/examples/cpp/Makefile @@ -9,7 +9,7 @@ CXX_HDR = $(CXX_LOC)/../../src/serial_chimes_interface.h $(CXX_LOC)/../../../chi clean: clean-all: - rm -f CPP-interface + rm -f chimescalc all: $(CXX_SRC) $(CXX_HDR) - $(CXX) $(CXX_SRC) -o CPP-interface -I $(CXX_LOC)/../../src -I $(CXX_LOC)/../../../chimesFF/src/ -DDEBUG=${DEBUG} + $(CXX) $(CXX_SRC) -o chimescalc -I $(CXX_LOC)/../../src -I $(CXX_LOC)/../../../chimesFF/src/ -DDEBUG=${DEBUG} diff --git a/serial_interface/examples/fortran/Makefile b/serial_interface/examples/fortran/Makefile index 0501ac9..1f09d6d 100644 --- a/serial_interface/examples/fortran/Makefile +++ b/serial_interface/examples/fortran/Makefile @@ -54,18 +54,18 @@ endif test-F: $(LINKS) - $(FCC) $(LINKS) -o fortran_wrapper-serial_interface + $(FCC) $(LINKS) -o chimescalc-test_serial-F lib : chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o - ar rcs libchimes.a chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o + ar rcs libchimescalc-fortran.a chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o clean: rm -f *.o *.mod clean-all: make clean - rm -f fortran_wrapper-serial_interface - rm -f libchimes.a + rm -f chimescalc-test_serial-F + rm -f libchimescalc-fortran.a all: make chimesFF.o diff --git a/serial_interface/examples/fortran08/Makefile b/serial_interface/examples/fortran08/Makefile index a672703..e475a79 100644 --- a/serial_interface/examples/fortran08/Makefile +++ b/serial_interface/examples/fortran08/Makefile @@ -56,17 +56,17 @@ else endif test-F: $(LINKS) - $(FCC) $(LINKS) -o fortran08_wrapper-serial_interface + $(FCC) $(LINKS) -o chimescalc-test_serial-F08 lib : chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o - ar rcs libchimes.a chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o + ar rcs libchimescalc-fortran08.a chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o clean: rm -f *.o *.mod clean-all: make clean - rm -f fortran08_wrapper-serial_interface - rm -f libchimes.a + rm -f chimescalc-test_serial-F08 + rm -f libchimescalc-fortran08.a all: make chimesFF.o diff --git a/serial_interface/examples/python/Makefile b/serial_interface/examples/python/Makefile index aedd5c6..f370f1a 100644 --- a/serial_interface/examples/python/Makefile +++ b/serial_interface/examples/python/Makefile @@ -31,7 +31,7 @@ chimescalc_serial_C.o : $(WRAPPER_SRC) chimescalc_serial_C.so: - $(CXX) -shared -o lib-C_wrapper-serial_interface.so chimescalc_serial_C.o serial_chimes_interface.o chimesFF.o + $(CXX) -shared -o libchimescalc-serial_dl.so chimescalc_serial_C.o serial_chimes_interface.o chimesFF.o clean: rm -f *.o diff --git a/serial_interface/examples/python/main.py b/serial_interface/examples/python/main.py index d15a012..4a5ff55 100644 --- a/serial_interface/examples/python/main.py +++ b/serial_interface/examples/python/main.py @@ -3,7 +3,7 @@ A simple usage example for computing system force, stress, and energy via the serial_chimes_calculator python wrapper. - Expects "lib-C_wrapper-serial_interface.so" in the same directory as this script. This file + Expects "libchimescalc_dl.so" in the same directory as this script. This file can be generated by typing "make all" in the directory containing this file Depends on chimescalc_serial_py.py from the chimes_serial_interface's api files @@ -28,7 +28,7 @@ print( "ERROR: Wrong number of commandline args") print( " Run with: python ") print( " or") - print( " Run with: python3 ") + print( " Run with: python3 ") exit() # A small helper function @@ -64,7 +64,9 @@ def str2bool(v): # Initialize the ChIMES calculator curr_path should be /.../usr/WS2/rlindsey/chimes_calculator-fork/serial_interface/tests/ -chimescalc_serial_py.chimes_wrapper = chimescalc_serial_py.init_chimes_wrapper("lib-C_wrapper-serial_interface.so") +print("HERE:",os.getcwd) + +chimescalc_serial_py.chimes_wrapper = chimescalc_serial_py.init_chimes_wrapper("libchimescalc_dl.so") chimescalc_serial_py.set_chimes(small) rank = 0 diff --git a/serial_interface/tests/compare_output b/serial_interface/tests/compare.sh similarity index 100% rename from serial_interface/tests/compare_output rename to serial_interface/tests/compare.sh diff --git a/serial_interface/tests/run_test_case b/serial_interface/tests/run_single_test.sh similarity index 81% rename from serial_interface/tests/run_test_case rename to serial_interface/tests/run_single_test.sh index 9c67b5d..58b6ed0 100755 --- a/serial_interface/tests/run_test_case +++ b/serial_interface/tests/run_single_test.sh @@ -6,7 +6,7 @@ SCRIPT_NAME=$(basename $0) if [ $# -ne 5 ]; then echo "Wrong nr. of parameters" >&2 - echo "run_test_case BINARY PARAMETERFILE GEOMETRYFILE CONFIGOPT WORKDIR" >&2 + echo "run_single_test.sh BINARY PARAMETERFILE GEOMETRYFILE CONFIGOPT WORKDIR" >&2 exit 1 fi @@ -26,6 +26,6 @@ ${binary} \ ${SCRIPT_DIR}/configurations/${geometryfile} \ ${configopt} >& output -${SCRIPT_DIR}/compare_output \ +${SCRIPT_DIR}/compare.sh \ output \ ${SCRIPT_DIR}/expected_output/${parameterfile}.${geometryfile}.dat diff --git a/serial_interface/tests/run_tests.sh b/serial_interface/tests/run_tests.sh index 229404a..cf5a859 100755 --- a/serial_interface/tests/run_tests.sh +++ b/serial_interface/tests/run_tests.sh @@ -16,35 +16,29 @@ STYLE=${1-"LONG"} # By default,run "LONG" test, but if user runs with "./run_tes PREFX=${2-""} # By default, don't set any special install prefix PYTH3=python3.7 -FFS[0 ]="published_params.liqC.2b.cubic.txt" ; CFGS[0 ]="liqC.2.5gcc_6000K.OUTCAR_#000.xyz" ; OPTIONS[0 ]="0" -FFS[1 ]="published_params.liqC.2+3b.cubic.txt" ; CFGS[1 ]="liqC.2.5gcc_6000K.OUTCAR_#000.xyz" ; OPTIONS[1 ]="0" -FFS[2 ]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[2 ]="CO.2.5gcc_6500K.OUTCAR_#000.xyz" ; OPTIONS[2 ]="1" -FFS[3 ]="validated_params.liqCO.2+3b.cubic.txt" ; CFGS[3 ]="CO.2.5gcc_6500K.OUTCAR_#000.relabel.xyz" ; OPTIONS[3 ]="1" -FFS[4 ]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[4 ]="CO.2.5gcc_6500K.OUTCAR_#000.scramble.xyz" ; OPTIONS[4 ]="1" -FFS[5 ]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[5 ]="CO.2.5gcc_6500K.OUTCAR_#000.translate.xyz" ; OPTIONS[5 ]="1" -FFS[6 ]="published_params.HN3.2+3+4b.Tersoff.special.offsets.txt" ; CFGS[6 ]="HN3.2gcc_3000K.OUTCAR_#000.xyz" ; OPTIONS[6 ]="0" -FFS[7 ]="validated_params.TiO2.2+3b.Tersoff.txt" ; CFGS[7 ]="TiO2.unitcell_arbrot_#000.xyz" ; OPTIONS[7 ]="0" -FFS[8 ]="test_params.CHON.txt" ; CFGS[8 ]="CHON.testfile_#000.xyz" ; OPTIONS[8 ]="0" -FFS[9 ]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[9 ]="diam.64_#000.xyz" ; OPTIONS[9 ]="1" -FFS[10]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[10]="diam.16_#000.xyz" ; OPTIONS[10]="1" -FFS[11]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[11]="diam.8_#000.xyz" ; OPTIONS[11]="1" -FFS[12]="published_params.liqCO.2+3b.cubic.txt" ; CFGS[12]="diam.2_#000.xyz" ; OPTIONS[12]="1" -FFS[13]="published_params.CO2400K.2+3+4b.Tersoff.special.offsets.txt" ; CFGS[13]="CO.9GPa_2400K.OUTCAR_#000.xyz" ; OPTIONS[13]="1" +# Populate FFS, CFGS, and OPTIONS from test_list.dat + + +awk '/short/||/minimal/{print}' test_list.dat | tr ';' ' ' > tmp-data.dat +while read FF CFG OPTION TMP +do + FFS+=($FF); CFGS+=($CFG); OPTIONS+=($OPTION) +done < tmp-data.dat; rm -f tmp-data.dat API_LIST="0 1 2 3 4" NO_TESTS=${#FFS[@]} LOC=`pwd` -API[0]="cpp" ; EXE[0]="CPP-interface" ; XTRA[0]="" #"2" -API[1]="c" ; EXE[1]="C_wrapper-serial_interface" ; XTRA[1]="" #"2" -API[2]="fortran" ; EXE[2]="fortran_wrapper-serial_interface" ; XTRA[2]="" #"2" -API[3]="python" ; EXE[3]="main.py" ; XTRA[3]="" #"2 1" -API[4]="fortran08"; EXE[4]="fortran08_wrapper-serial_interface" ; XTRA[4]="" #"0" +API[0]="cpp" ; EXE[0]="chimescalc" ; XTRA[0]="" #"2" +API[1]="c" ; EXE[1]="chimescalc-test_serial-C" ; XTRA[1]="" #"2" +API[2]="fortran" ; EXE[2]="chimescalc-test_serial-F" ; XTRA[2]="" #"2" +API[3]="python" ; EXE[3]="main.py" ; XTRA[3]="" #"2 1" +API[4]="fortran08"; EXE[4]="chimescalc-test_serial-F08" ; XTRA[4]="" #"0" echo "Running $STYLE tests" date -for compile in MAKEFILE +for compile in CMAKE MAKEFILE do echo "Testing compilation type: $compile" @@ -64,7 +58,7 @@ do make all DEBUG=1 else make all - cp lib-C_wrapper-serial_interface.so ../../tests + cp libchimescalc-serial_dl.so ../../tests/libchimescalc_dl.so fi cd ../../tests @@ -75,7 +69,7 @@ do cd ../../ ./install.sh 1 $PREFX # Set the debug flag true - cp build/lib-C_wrapper-serial_interface.so serial_interface/tests + cp build/libchimescalc_dl.so serial_interface/tests cd - else @@ -149,6 +143,9 @@ do done +read -p "Press enter to continue on to test cleanup." tmpvar + + # Clean up for i in $API_LIST # Cycle through APIs @@ -159,7 +156,7 @@ do cd ../../tests done -rm -f debug.dat san.dat *.so +rm -f debug.dat san.dat *.so output_lib.xyzf cd ../../ ./uninstall.sh $PREFX diff --git a/serial_interface/tests/tests b/serial_interface/tests/test_list.dat similarity index 100% rename from serial_interface/tests/tests rename to serial_interface/tests/test_list.dat index 5ede477..716d4b2 100644 --- a/serial_interface/tests/tests +++ b/serial_interface/tests/test_list.dat @@ -1,5 +1,3 @@ -test_params.CHON.txt; CHON.testfile_#000.xyz; 0; minimal - published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#000.xyz; 0; short published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#001.xyz; 0; long published_params.liqC.2b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#002.xyz; 0; long @@ -22,8 +20,6 @@ published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#007.xyz; 0; l published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#008.xyz; 0; long published_params.liqC.2+3b.cubic.txt; liqC.2.5gcc_6000K.OUTCAR_#009.xyz; 0; long -validated_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.relabel.xyz; 1; short - published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.xyz; 1; short published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#001.xyz; 1; long published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#002.xyz; 1; long @@ -35,18 +31,12 @@ published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#007.xyz; 1; lo published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#008.xyz; 1; long published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#009.xyz; 1; long +validated_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.relabel.xyz; 1; short + published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.scramble.xyz; 1; short published_params.liqCO.2+3b.cubic.txt; CO.2.5gcc_6500K.OUTCAR_#000.translate.xyz; 1; short -published_params.liqCO.2+3b.cubic.txt; diam.64_#000.xyz; 1; short - -published_params.liqCO.2+3b.cubic.txt; diam.16_#000.xyz; 1; short - -published_params.liqCO.2+3b.cubic.txt; diam.8_#000.xyz; 1; short - -published_params.liqCO.2+3b.cubic.txt; diam.2_#000.xyz; 1; short - published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#000.xyz; 0; short published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#001.xyz; 0; long published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_#002.xyz; 0; long @@ -60,4 +50,14 @@ published_params.HN3.2+3+4b.Tersoff.special.offsets.txt; HN3.2gcc_3000K.OUTCAR_ validated_params.TiO2.2+3b.Tersoff.txt; TiO2.unitcell_arbrot_#000.xyz; 0; short validated_params.TiO2.2+3b.Tersoff.txt; TiO2.unitcell_arbrot_#001.xyz; 0; long +test_params.CHON.txt; CHON.testfile_#000.xyz; 0; minimal + +published_params.liqCO.2+3b.cubic.txt; diam.64_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.16_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.8_#000.xyz; 1; short + +published_params.liqCO.2+3b.cubic.txt; diam.2_#000.xyz; 1; short + published_params.CO2400K.2+3+4b.Tersoff.special.offsets.txt; CO.9GPa_2400K.OUTCAR_#000.xyz; 1; short From fbcf906e778b00a1c34e9c2b1b59625ee4e66445 Mon Sep 17 00:00:00 2001 From: "Lindsey, Rebecca Kristine" Date: Thu, 6 Jan 2022 22:02:38 -0800 Subject: [PATCH 4/4] Update documentation to match current code. --- doc/source/chimesFF.rst | 28 ++++++++++++------------ doc/source/getting_started.rst | 2 +- doc/source/releases.rst | 2 ++ doc/source/serial_interface.rst | 33 +++++++++++++++-------------- doc/source/utils.rst | 2 ++ serial_interface/tests/run_tests.sh | 4 ++-- 6 files changed, 39 insertions(+), 32 deletions(-) diff --git a/doc/source/chimesFF.rst b/doc/source/chimesFF.rst index 50fc5e3..61d23c0 100644 --- a/doc/source/chimesFF.rst +++ b/doc/source/chimesFF.rst @@ -329,7 +329,7 @@ void chimes_compute_4b_props_fromf90 ============ === The Fortran API ^^^^^^^^^^^^^^^ -The Fortran API (``chimescalc_F*``) is located in ``chimesFF/api``. This wrapper enables access to ``chimesFF`` functions +The Fortran API (``chimescalc_F.f90``) is located in ``chimesFF/api``. This wrapper enables access to ``chimesFF`` functions through the C API and handles other details like differences in array storage order. @@ -449,13 +449,13 @@ operations, in order: .. code-block:: python - chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("lib-C_wrapper-serial_interface.so") # Associate the wrapper with a compiled C API library file + chimescalc_py.chimes_wrapper = chimescalc_py.init_chimes_wrapper("chimescalc_dl.so") # Associate the wrapper with a compiled C API library file chimescalc_py.set_chimes() # Instantiate chimescalc_py.init_chimes() # If run with MPI, an integer MPI rank can be passed to this function. By default, assumes rank = 0 chimescalc_py.read_params("my_parameter_file") -For additional information on compiling (i.e. generation of ``lib-C_wrapper-serial_interface.so``), see :ref:`Implementation Examples `. +For additional information on compiling (i.e. generation of ``chimescalc_dl.so``), see :ref:`Implementation Examples `. Note that the ChIMES calculator ``chimescalc_py`` API provides users with the following functions: @@ -558,7 +558,7 @@ The following codes demonstrates how ``chimesFF.{h,cpp}`` can be used to obtain .. Note:: - All example executables can be compiled at once via ``./install.sh`` from the ``chimes_calculator`` base directory, and similarly uninstalled via ``./uninstall.sh``. However, the examples below compile via the user-generated Makefiles located in each ``examples`` subdirectory, for demonstrative purposes. + All example executables can be compiled at once in ``./build`` with CMake, via ``./install.sh`` from the ``chimes_calculator`` base directory, and similarly uninstalled via ``./uninstall.sh``. However, the examples below compile via the user-generated Makefiles located in each ``examples`` subdirectory, for demonstrative purposes. * **C Example:** The ``main`` function of this example includes the C API, ``chimescalc_C.{h,cpp}``, which creates a global static pointer to a ``chimesFF`` object. @@ -566,7 +566,7 @@ The following codes demonstrates how ``chimesFF.{h,cpp}`` can be used to obtain * Navigate to ``chimesFF/examples/c`` * Compile with: ``make all`` - * Test with: ``./C_wrapper-direct_interface `` + * Test with: ``./chimescalc-test_direct-C `` * Additional notes: * ``*.xyz`` files must not contain any information beyond atom type and x-, y-, and z- coordinate on coordinate lines. @@ -577,7 +577,7 @@ The following codes demonstrates how ``chimesFF.{h,cpp}`` can be used to obtain * Navigate to ``chimesFF/examples/cpp`` * Compile with: ``make all`` - * Test with: ``./CPP-interface `` + * Test with: ``./chimescalc `` * **Fortran Example:** Similar to the C example, this ``main`` function establishes a pointer to a ``chimesFF`` object via ``f_set_chimes()``. The ``f_set_chimes()`` function call is defined in ``chimescalc_F.f90,`` a wrapper for the C API ``chimescalc_C.cpp`` (i.e which facilitates C-style access to @@ -585,20 +585,22 @@ The following codes demonstrates how ``chimesFF.{h,cpp}`` can be used to obtain * Navigate to ``chimesFF/examples/fortran`` * Compile with: ``make all`` - * Test with: ``./fortran_wrapper-direct_interface `` + * Test with: ``./chimescalc-test_direct-F `` * Additional notes: * ``*.xyz`` files must not contain any information beyond atom type and x-, y-, and z- coordinate on coordinate lines. * This implementation does NOT use ghost atoms/layering thus the input system MUST have box lengths greater than two times the largest outer cutoff, or results will not be correct. -* **Python Example:** This example accesses ``chimesFF`` functions through `chimescalc_py.py``, a ctypes-based python API for access to the C API functions - (i.e. through ``chimescalc_C.cpp``). Once ``chimescalc_py.py`` is imported, it is associated with a compiled C API library file, i.e. ``lib-C_wrapper-direct_interface.so`` and can be used to access ``chimesFF`` member functions. +* **Python Example:** This example accesses ``chimesFF`` functions through ``chimescalc_py.py``, a ctypes-based python API for access to the C API functions + (i.e. through ``chimescalc_C.cpp``). Once ``chimescalc_py.py`` is imported, it is associated with a compiled C API library file, i.e. ``chimescalc_dl.so`` and can be used to access ``chimesFF`` member functions. * Navigate to ``chimesFF/examples/python`` - * Compile lib-C_wrapper-direct_interface.so with: ``make all`` - * Test with: python main.py + * Compile ``chimescalc_dl.so`` with: ``make all`` + * Test with: ``python main.py `` * Additional notes: - * Requires ``lib-C_wrapper-direct_interface.so`` in the same directory, which is generated via ``make all`` + * Requires ``chimescalc_dl.so`` in the same directory, which is generated via ``make all`` * Expects to be run with Python version 3.X - * This implementation does NOT use ghost atoms/layering thus the input system MUST have box lengths greater than two times the largest outer cutoff, or results will not be correct. + +.. Warning:: + This Python implementation example does NOT use ghost atoms/layering thus the input system MUST have box lengths greater than two times the largest outer cutoff, or results will not be correct. diff --git a/doc/source/getting_started.rst b/doc/source/getting_started.rst index 2348c48..257e505 100644 --- a/doc/source/getting_started.rst +++ b/doc/source/getting_started.rst @@ -103,7 +103,7 @@ Sample ChIMES parameter and input files are provided in the ``serial_interface/t .. code-block:: bash - serial_interface/examples/cpp/CPP-interface \ + serial_interface/examples/cpp/chimescalc \ serial_interface/tests/force_fields/published_params.liqC.2b.cubic.txt \ serial_interface/tests/configurations/liqC.2.5gcc_6000K.OUTCAR_#000.xyz | tee my_test.log diff --git a/doc/source/releases.rst b/doc/source/releases.rst index 8e1bda7..a30ef56 100644 --- a/doc/source/releases.rst +++ b/doc/source/releases.rst @@ -3,4 +3,6 @@ ChIMES Calculator Releases ========================== +* v1.0.2: (Jan. 6 2022) Test suite bug fixes, file renaming, documentation update +* v1.0.1: (Dec. 22, 2021) CMake/Make bugfixes * v1.0.0: (Dec. 12, 2021) First stable release diff --git a/doc/source/serial_interface.rst b/doc/source/serial_interface.rst index 0b18a90..9d69042 100644 --- a/doc/source/serial_interface.rst +++ b/doc/source/serial_interface.rst @@ -6,7 +6,7 @@ The ChIMES Calculator Serial Interface Overview ******** -The ChIMES calculator serial interface provides an easier means of evaluating ChIMES interactions for a given system. In constrast to the ChIMES calculator (i.e. ``chimesFF``), which takes information on *individual* atom clusters and returns the cluster energy, stress tensor, via ``compute_xB`` functions, the serial interface (i.e. ``serial_chimes_interface``) takes *overall* system information and returns *overall* provides *overall* system energy, stress tensor, and forces. Though far less flexible than direct use of ``chimesFF``, ``serial_chimes_interface`` allows users to leverage ChIMES with much less coding. For further details on ``chimesFF``, see :ref:`The ChIMES Calculator `. For a complete set of ChIMES references, see :ref:`Citing ChIMES `. +The ChIMES calculator serial interface provides an easier means of evaluating ChIMES interactions for a given system. In constrast to the ChIMES calculator (i.e. ``chimesFF``), which takes information on *individual* atom clusters and returns the cluster energy, stress tensor, via ``compute_xB`` functions, the serial interface (i.e. ``serial_chimes_interface``) takes *overall* system information and returns *overall* system energy, stress tensor, and forces. Though far less flexible than direct use of ``chimesFF``, ``serial_chimes_interface`` allows users to leverage ChIMES with much less coding. For further details on ``chimesFF``, see :ref:`The ChIMES Calculator `. For a complete set of ChIMES references, see :ref:`Citing ChIMES `. Note that this functionality is primarily intended for instructive purposes, and is not recommended for large scale simulations. The ChIMES Calculator Serial Interface @@ -26,9 +26,9 @@ The ChIMES calculator serial interface source files are located in ``serial_inte For small simulation cells (e.g., a single atom in a face-centered cubic unit cell), the ChIMES calculator must be instantiated via ``serial_chimes_interface chimes(true)``. This allows for automatic replication in situations where the ChIMES outer cutoff is greater than one half of the smallest supercell length. Please note that use of extra-small simulation cells is ill-advised for aything except crystalline systems and should be used with caution. - Developer note: To recover behavior of the research code, instantiate with: ``serial_chimes_interface chimes(false)`` + *Developer note: To recover behavior of the research code, instantiate with:* ``serial_chimes_interface chimes(false)``. -Please see the following example of interfacing a C++ code with the ChIMES calculator: ``serial_interface/examples/cpp/main.cpp``. Note that the ChIMES calculator serial interface ``serial_chimes_interface`` class provides users with the following functions: +Please see the following example of interfacing a C++ code with the ChIMES calculator: ``serial_interface/examples/cpp/main.cpp``. Note that the ChIMES calculator ``serial_chimes_interface`` class provides users with the following functions: =========== ================= =============================== Return Type Name Arguments and Description @@ -69,7 +69,7 @@ void calculate The C API ^^^^^^^^^ -The C API (``chimescalc_serial_C*``) is located in ``serial_interface/api``. This wrapper provides C style name mangling and creates a set of C-style wrapper functions. The latter are needed for compatibility with std::vector which is heavily used in ``serial_chimes_interface`` and not supported in most other languages. Any C code attempting to use the ChIMES calculator serial interface should ``#include "chimescalc_serial_C.h"`` +The C API (``chimescalc_serial_C*``) is located in ``serial_interface/api``. This wrapper provides C style name mangling and creates a set of C-style wrapper functions. The latter are needed for compatibility with ``std::vector`` which is heavily used in ``serial_chimes_interface`` and not supported in most other languages. Any C code attempting to use the ChIMES calculator serial interface should ``#include "chimescalc_serial_C.h"`` and initialize calculations with the following operations, in order: .. code-block:: cpp @@ -128,7 +128,7 @@ void calculate_chimes ======================= ===== The Fortran90 API ^^^^^^^^^^^^^^^^^ -The Fortran90 API (``chimescalc_serial_F*``) is located in ``serial_interface/api``. This wrapper enables access to ``serial_chimes_interface`` functions +The Fortran90 API (``chimescalc_serial_F.f90``) is located in ``serial_interface/api``. This wrapper enables access to ``serial_chimes_interface`` functions through the C API and handles other details like differences in array storage order. @@ -204,7 +204,7 @@ C_string string2Cstring ====== === The Fortran2008 API ^^^^^^^^^^^^^^^^^^^ -The Fortran2008 API (``chimescalc_serial_F08*``) is located in ``serial_interface/api``. This wrapper enables access to ``serial_chimes_interface`` functions +The Fortran2008 API (``chimescalc_serial_F08.f90``) is located in ``serial_interface/api``. This wrapper enables access to ``serial_chimes_interface`` functions through the C API and handles other details like differences in array storage order. @@ -269,7 +269,7 @@ subroutine %calculate Performs ChIMES calculation based The Python API ^^^^^^^^^^^^^^ -The Python API (``chimescalc_serial_py*``) is located in ``serial_interface/api``. Like the Fortran API, this wrapper enables access to +The Python API (``chimescalc_serial_py.py``) is located in ``serial_interface/api``. Like the Fortran API, this wrapper enables access to ``serial_chimes_interface`` functions through the C API, via ctypes. Any python code attempting to use the ChIMES Calculator should ``import chimescalc_serial_py`` and at least include the following @@ -278,7 +278,7 @@ operations, in order: .. code-block:: python # Associate the wrapper with a compiled C API library file - chimescalc_serial_py.chimes_wrapper = chimescalc_serial_py.init_chimes_wrapper("lib-C_wrapper-serial_interface.so") + chimescalc_serial_py.chimes_wrapper = chimescalc_serial_py.init_chimes_wrapper("libchimescalc_dl.so") # Instantiate; as for the C++ API (see warning message), can pass 0/1 for false/true chimescalc_serial_py.set_chimes() # Read the parameter file, set MPI rank to 0 (i.e. no MPI used) @@ -376,7 +376,7 @@ For user generated tests, note that ``*.xyz`` files must provide lattice vectors .. Note:: - All example executables can be compiled at once via ``./install.sh`` from the ``chimes_calculator`` base directory, and similarly uninstalled via ``./uninstall.sh``. However, the examples below compile via the user-generated Makefiles located in each ``examples`` subdirectory, for demonstrative purposes. + All example executables can be compiled at once in ``./build`` with CMake, via ``./install.sh`` from the ``chimes_calculator`` base directory, and similarly uninstalled via ``./uninstall.sh``. However, the examples below compile via the user-generated Makefiles located in each ``examples`` subdirectory, for demonstrative purposes. * **C Example:** The ``main`` function of this example includes the C API, ``chimescalc_serial_C.{h,cpp}``, which creates a global static pointer to a ``serial_chimes_interface`` object. @@ -384,14 +384,14 @@ For user generated tests, note that ``*.xyz`` files must provide lattice vectors * Navigate to ``serial_interface/examples/c`` * Compile with: ``make all`` - * Test with: ``./C_wrapper-serial_interface `` + * Test with: ``./chimescalc-test_serial-C `` * **C++ Example:** The ``main`` function of this example creates an instance of ``serial_chimes_interface`` (i.e. a class inheriting ``chimesFF``, which computes energy, per-atom forces, and stress tensor for an overall system). For additional details, see :ref:`The ChIMES Calculator ` * Navigate to ``serial_interface/examples/cpp`` * Compile with: ``make all`` - * Test with: ``./CPP-interface `` + * Test with: ``./chimescalc `` * **Fortran90 Example:** Similar to the C example, this ``main`` function establishes a pointer to a ``serial_chimes_interface`` object via ``f_set_chimes()``. The ``f_set_chimes()`` function call is defined in ``chimescalc_serial_F.F90,`` a wrapper for the C API ``chimescalc_serial_C.cpp`` (i.e which facilitates C-style access to @@ -399,7 +399,7 @@ For user generated tests, note that ``*.xyz`` files must provide lattice vectors * Navigate to ``serial_interface/examples/fortran`` * Compile with: ``make all`` - * Test with: ``./fortran_wrapper-serial_interface `` + * Test with: ``./chimescalc-test_serial-F `` * Additional notes: * **Fortran2008 Example:** Similarly, this ``main`` function establishes a pointer to a ``serial_chimes_interface`` object via calls to ``ChimesCalc_init()`` and subroutine calls within the ``ChimesCalc`` class, defined in ``chimescalc_serial_F08.f90.`` @@ -407,13 +407,14 @@ For user generated tests, note that ``*.xyz`` files must provide lattice vectors * Navigate to ``serial_interface/examples/fortran08`` * Compile with: ``make all`` - * Test with: ``./fortran08_wrapper-serial_interface `` + * Test with: ``./chimescalc-test_serial-F08 `` * Additional notes: * **Python Example:** This example accesses ``serial_chimes_interface`` functions through ``chimescalc_serial_py.py``, a ctypes-based python API for access to the C API functions (i.e. through ``chimescalc_serial_C.cpp``). Once ``chimescalc_serial_py.py`` is imported, it is associated with a compiled C API library file, i.e. ``lib-C_wrapper-serial_interface.so`` and can be used to access ``serial_chimes_interface`` member functions. * Navigate to ``serial_interface/examples/python`` - * Compile lib-C_wrapper-serial_interface.so with: ``make all`` - * Test with: python main.py - * Additional notes: + * Compile ``libchimescalc-serial_dl.so`` with: ``make all`` + * Rename: ``cp libchimescalc-serial_dl.so libchimescalc_dl.so`` + * Test with: ``python main.py `` + \ No newline at end of file diff --git a/doc/source/utils.rst b/doc/source/utils.rst index 1d51dc3..7339753 100644 --- a/doc/source/utils.rst +++ b/doc/source/utils.rst @@ -39,7 +39,9 @@ A utility for generating ChIMES potential energy surface scans for *n*-body clus Variables ``CHMS_REPO`` and ``PARAM_FILE`` specify the ``chimes_calculator`` repository location, and path to the ChIMES parameter of file. Note that paths should be provided in their absolute form. Following these variables, three sets of options are provided. Focusing on options beginning with ``PAIR``, one must provide the following: * A list of pair type indices for which scans should be generated + * Indices should correspond to values following ``PAIRTYPE PARAMS:`` in the target parameter file + * A list of the minimum pair distance for each pair type to consider during the scan * A list of the maximum pair distance for each pair type to consider during the scan * A scan step size diff --git a/serial_interface/tests/run_tests.sh b/serial_interface/tests/run_tests.sh index cf5a859..7978823 100755 --- a/serial_interface/tests/run_tests.sh +++ b/serial_interface/tests/run_tests.sh @@ -143,7 +143,7 @@ do done -read -p "Press enter to continue on to test cleanup." tmpvar +read -p "Press enter to continue on to test cleanup. " tmpvar # Clean up @@ -153,7 +153,7 @@ do cd ../examples/${API[$i]} make clean-all rm -f *.so *.a - cd ../../tests + cd - done rm -f debug.dat san.dat *.so output_lib.xyzf