From c6c51a474e660d6112b669b3a6a13da1aea66c46 Mon Sep 17 00:00:00 2001 From: lukaswittmann Date: Mon, 18 Mar 2024 15:58:09 +0100 Subject: [PATCH 01/13] Update for consistent parameterization on the extended acqm --- src/multicharge/param/eeq2019.f90 | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/multicharge/param/eeq2019.f90 b/src/multicharge/param/eeq2019.f90 index 48da970c..aadd81b5 100644 --- a/src/multicharge/param/eeq2019.f90 +++ b/src/multicharge/param/eeq2019.f90 @@ -75,11 +75,10 @@ module multicharge_param_eeq2019 & 0.56999999_wp, 0.87936784_wp, 1.02761808_wp, 0.93297476_wp, 1.10172128_wp, & & 0.97350071_wp, 1.16695666_wp, 1.23997927_wp, 1.18464453_wp, 1.14191734_wp, & & 1.12334192_wp, 1.01485321_wp, 1.12950808_wp, 1.30804834_wp, 1.33689961_wp, & - & 1.27465977_wp, 1.06598299_wp, 0.68184178_wp, 1.25994649_wp, 0.40030316_wp, & - & 0.29458157_wp, 0.75460678_wp, 0.42330605_wp, 0.53613714_wp, 0.58870880_wp, & - & 0.50349105_wp, 0.02647510_wp, 0.45350118_wp, 0.63133032_wp, 0.45995218_wp, & - & 1.01557723_wp, 1.17163176_wp, 0.23501195_wp] - + & 1.27465977_wp, 1.06598299_wp, 0.68184178_wp, 1.04581665_wp, 1.09888688_wp, & + & 1.07206461_wp, 1.09821942_wp, 1.10900303_wp, 1.01039812_wp, 1.00095966_wp, & + & 1.11003303_wp, 1.16831853_wp, 1.00887482_wp, 1.05928842_wp, 1.07672363_wp, & + & 1.11308426_wp, 1.14340090_wp, 1.13714110_wp] !> Element-specific chemical hardnesses for the electronegativity equilibration charges. real(wp), parameter :: eeq_eta(max_elem) = [& @@ -100,10 +99,10 @@ module multicharge_param_eeq2019 & 0.11000000_wp,-0.02786741_wp, 0.01057858_wp,-0.03892226_wp,-0.04574364_wp, & &-0.03874080_wp,-0.03782372_wp,-0.07046855_wp, 0.09546597_wp, 0.21953269_wp, & & 0.02522348_wp, 0.15263050_wp, 0.08042611_wp, 0.01878626_wp, 0.08715453_wp, & - & 0.10500484_wp, 0.10034731_wp, 0.15801991_wp,-0.00995585_wp, 0.13654805_wp, & - & 0.15968516_wp, 0.12442023_wp, 0.13340491_wp, 0.11523968_wp, 0.12165907_wp, & - & 0.08181387_wp, 0.65060023_wp, 0.18634958_wp, 0.16685501_wp, 0.15080023_wp, & - & 0.10094112_wp, 0.10503808_wp, 0.68963544_wp] + & 0.10500484_wp, 0.10034731_wp, 0.15801991_wp,-0.00071039_wp,-0.00170887_wp, & + &-0.00133327_wp,-0.00104386_wp,-0.00094936_wp,-0.00111390_wp,-0.00125257_wp, & + &-0.00095936_wp,-0.00102814_wp,-0.00104450_wp,-0.00112666_wp,-0.00101529_wp, & + &-0.00059592_wp,-0.00012585_wp,-0.00140896_wp] !> Element-specific CN scaling constant for the electronegativity equilibration charges. real(wp), parameter :: eeq_kcn(max_elem) = [& @@ -124,10 +123,10 @@ module multicharge_param_eeq2019 &-0.11000000_wp,-0.03585873_wp,-0.03132400_wp,-0.05902379_wp,-0.02827592_wp, & &-0.07606260_wp,-0.02123839_wp, 0.03814822_wp, 0.02146834_wp, 0.01580538_wp, & &-0.00894298_wp,-0.05864876_wp,-0.01817842_wp, 0.07721851_wp, 0.07936083_wp, & - & 0.05849285_wp, 0.00013506_wp,-0.00020631_wp, 0.00328823_wp, 0.00419390_wp, & - & 0.00429264_wp, 0.00193300_wp, 0.00478177_wp, 0.00264040_wp, 0.00418168_wp, & - & 0.00399258_wp,-0.00293781_wp,-0.00195990_wp, 0.00148017_wp,-0.00011254_wp, & - & 0.00023249_wp,-0.00006144_wp,-0.02459107_wp] + & 0.05849285_wp, 0.00013506_wp,-0.00020631_wp, 0.00473118_wp, 0.01590519_wp, & + & 0.00369763_wp, 0.00417543_wp, 0.00706682_wp, 0.00488679_wp, 0.00505103_wp, & + & 0.00710682_wp, 0.00463050_wp, 0.00387799_wp, 0.00296795_wp, 0.00400648_wp, & + & 0.00548481_wp, 0.01350400_wp, 0.00675380_wp] !> Element-specific charge widths for the electronegativity equilibration charges. real(wp), parameter :: eeq_rad(max_elem) = [& @@ -148,10 +147,10 @@ module multicharge_param_eeq2019 & 1.63999999_wp, 1.47055223_wp, 1.81127084_wp, 1.40189963_wp, 1.54015481_wp, & & 1.33721475_wp, 1.57165422_wp, 1.04815857_wp, 1.78342098_wp, 2.79106396_wp, & & 1.78160840_wp, 2.47588882_wp, 2.37670734_wp, 1.76613217_wp, 2.66172302_wp, & - & 2.82773085_wp, 1.04059593_wp, 0.60550051_wp, 1.93854984_wp, 0.50189075_wp, & - & 0.58180664_wp, 0.73094166_wp, 0.49548126_wp, 0.67685715_wp, 0.59573917_wp, & - & 0.35345732_wp, 0.29902232_wp, 0.49626064_wp, 0.55816329_wp, 0.49019371_wp, & - & 1.05120718_wp, 0.95651052_wp, 0.35885251_wp] + & 2.82773085_wp, 1.04059593_wp, 0.60550051_wp, 1.22262145_wp, 1.28736399_wp, & + & 1.44431317_wp, 1.29032833_wp, 1.41009404_wp, 1.25501213_wp, 1.15181468_wp, & + & 1.42010424_wp, 1.43955530_wp, 1.28565237_wp, 1.35017463_wp, 1.33011749_wp, & + & 1.30745135_wp, 1.26526071_wp, 1.34071499_wp] contains From ed63d6d68a87e939c3daba91e540c89481839263 Mon Sep 17 00:00:00 2001 From: lukaswittmann Date: Mon, 18 Mar 2024 16:14:25 +0100 Subject: [PATCH 02/13] Update actinides test --- test/test_model.f90 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test_model.f90 b/test/test_model.f90 index 5a5e3df7..f16c1a47 100644 --- a/test/test_model.f90 +++ b/test/test_model.f90 @@ -417,12 +417,12 @@ subroutine test_q_actinides(error) type(structure_type) :: mol real(wp), parameter :: ref(17) = [& - &-3.30509539864000E-01_wp, 1.04514976082945E-01_wp,-1.77396038980278E+00_wp, & - & 3.33146719321694E-01_wp, 4.95141129349174E-01_wp, 4.70782337923003E-02_wp, & - & 2.74391145645531E-01_wp, 3.24692748232074E-01_wp, 1.42515975903486E-01_wp, & - & 1.41998267354686E-01_wp, 2.27799879597567E-01_wp, 2.17718820771047E-01_wp, & - & 1.06681646773478E-01_wp, 1.79629037301893E-01_wp,-2.97275399624992E-01_wp, & - &-3.75140594107334E-01_wp, 1.81577343273231E-01_wp] + & 1.86904766283711E-02_wp, 2.89972818160259E-01_wp, 3.59298070941105E-02_wp, & + &-4.61256458126589E-02_wp,-7.02605348653647E-02_wp,-7.42052215689073E-02_wp, & + &-8.21938718945845E-02_wp, 1.64953118841151E-01_wp, 2.10381640633390E-01_wp, & + &-6.65485355096282E-02_wp,-2.59873890255450E-01_wp, 1.33839147940414E-01_wp, & + & 7.20768968601809E-02_wp,-3.36652347675997E-03_wp,-1.14546280789657E-01_wp, & + &-8.55922398441004E-02_wp,-1.23131162140762E-01_wp] !> Molecular structure data mol%nat = 17 From f268b5b1be27f69065d8539b4416c71e7d2b6ed4 Mon Sep 17 00:00:00 2001 From: Lukas Wittmann Date: Mon, 18 Mar 2024 18:07:13 +0100 Subject: [PATCH 03/13] Fix issue #27: Charge Handling (#28) * Fix issue #27: Added possibility to read charges from .CHRG and the command line; now also prints the sum of all atomic partial charges after calculation * Revised help printout * Fixed exists type --- app/main.f90 | 60 +++++++++++++++++++++++++++++++------- src/multicharge/output.f90 | 3 ++ 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/app/main.f90 b/app/main.f90 index aac5665e..aaa212b3 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -24,18 +24,20 @@ program main implicit none character(len=*), parameter :: prog_name = "multicharge" - character(len=:), allocatable :: input + character(len=:), allocatable :: input, chargeinput integer, allocatable :: input_format + integer :: stat, unit type(error_type), allocatable :: error type(structure_type) :: mol type(mchrg_model_type) :: model - logical :: grad + logical :: grad, exist real(wp), parameter :: cn_max = 8.0_wp, cutoff = 25.0_wp real(wp), allocatable :: cn(:), dcndr(:, :, :), dcndL(:, :, :), rcov(:), trans(:, :) real(wp), allocatable :: energy(:), gradient(:, :), sigma(:, :) real(wp), allocatable :: qvec(:), dqdr(:, :, :), dqdL(:, :, :) + real(wp), allocatable :: charge - call get_arguments(input, input_format, grad, error) + call get_arguments(input, input_format, grad, charge, error) if (allocated(error)) then write(error_unit, '(a)') error%message error stop @@ -52,6 +54,27 @@ program main error stop end if + if (allocated(charge)) then + mol%charge = charge + else + chargeinput = ".CHRG" + inquire(file=chargeinput, exist=exist) + if (exist) then + open(file=chargeinput, newunit=unit) + allocate(charge) + read(unit, *, iostat=stat) charge + if (stat == 0) then + mol%charge = charge + write(output_unit, '(a,/)') & + "[Info] Molecular charge read from '"//chargeinput//"'" + else + write(output_unit, '(a,/)') & + "[Warn] Could not read molecular charge read from '"//chargeinput//"'" + end if + close(unit) + end if + end if + call new_eeq2019_model(mol, model) call get_lattice_points(mol%periodic, mol%lattice, cutoff, trans) @@ -96,9 +119,10 @@ subroutine help(unit) write(unit, '(2x, a, t25, a)') & "-i, --input ", "Hint for the format of the input file", & - "--grad", "Evaluate molecular gradient and virial", & - "--version", "Print program version and exit", & - "--help", "Show this help message" + "-c, --charge ", "Set the molecular charge", & + "-g, --grad", "Evaluate molecular gradient and virial", & + "-v, --version", "Print program version and exit", & + "-h, --help", "Show this help message" write(unit, '(a)') @@ -116,7 +140,7 @@ subroutine version(unit) end subroutine version -subroutine get_arguments(input, input_format, grad, error) +subroutine get_arguments(input, input_format, grad, charge, error) !> Input file name character(len=:), allocatable :: input @@ -127,10 +151,13 @@ subroutine get_arguments(input, input_format, grad, error) !> Evaluate gradient logical, intent(out) :: grad + !> Charge + real(wp), allocatable, intent(out) :: charge + !> Error handling type(error_type), allocatable, intent(out) :: error - integer :: iarg, narg + integer :: iarg, narg, iostat character(len=:), allocatable :: arg grad = .false. @@ -140,10 +167,10 @@ subroutine get_arguments(input, input_format, grad, error) iarg = iarg + 1 call get_argument(iarg, arg) select case(arg) - case("-help", "--help") + case("-h", "-help", "--help") call help(output_unit) stop - case("-version", "--version") + case("-v", "-version", "--version") call version(output_unit) stop case default @@ -161,6 +188,19 @@ subroutine get_arguments(input, input_format, grad, error) exit end if input_format = get_filetype("."//arg) + case("-c", "-charge", "--charge") + iarg = iarg + 1 + call get_argument(iarg, arg) + if (.not.allocated(arg)) then + call fatal_error(error, "Missing argument for charge") + exit + end if + allocate(charge) + read(arg, *, iostat=iostat) charge + if (iostat /= 0) then + call fatal_error(error, "Invalid charge value") + exit + end if case("-grad", "--grad") grad = .true. end select diff --git a/src/multicharge/output.f90 b/src/multicharge/output.f90 index 220fd140..43682684 100644 --- a/src/multicharge/output.f90 +++ b/src/multicharge/output.f90 @@ -82,6 +82,9 @@ subroutine write_ascii_properties(unit, mol, model, cn, qvec) & iat, mol%num(isp), mol%sym(isp), cn(iat), qvec(iat), & & model%chi(isp) - model%kcn(isp) * sqrt(cn(iat)) end do + write(unit, '(50("-"))') + write(unit, '(a7,22x,f10.4)') & + & "Σ", sum(qvec) write(unit, '(50("-"),/)') end subroutine write_ascii_properties From 3ad750346fa3a92c2f2c1c9d4dd21908e20dbf82 Mon Sep 17 00:00:00 2001 From: albert <92109627+Albkat@users.noreply.github.com> Date: Tue, 16 Apr 2024 10:23:57 +0200 Subject: [PATCH 04/13] Update mstore.wrap --- subprojects/mstore.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/mstore.wrap b/subprojects/mstore.wrap index 6f620815..acf5df9d 100644 --- a/subprojects/mstore.wrap +++ b/subprojects/mstore.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = mstore url = https://github.com/grimme-lab/mstore -revision = v0.1.2 +revision = v0.2.0 From 92b37fbdb85a9a310b137d3f18410f66d37fb7a5 Mon Sep 17 00:00:00 2001 From: Marcel Mueller Date: Wed, 31 Jul 2024 23:13:04 +0200 Subject: [PATCH 05/13] Fix continuous integration (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update GH workflow to more recent Python version and Intel env vars Signed-off-by: Marcel Müller * fix intel compiler version and increase gcc version for macOS Signed-off-by: Marcel Müller * remove unnecessary brew install and take appropriate gfortran version Signed-off-by: Marcel Müller * check gfortran version Signed-off-by: Marcel Müller * add brew install command back again Signed-off-by: Marcel Müller * check only for present gfortran versions Signed-off-by: Marcel Müller * correct alias for pre-installed gfortran and gcc Signed-off-by: Marcel Müller * use symbolic link instead of alias Signed-off-by: Marcel Müller * install openblas for lapack Signed-off-by: Marcel Müller * use openBLAS instead of Accelerate Signed-off-by: Marcel Müller * add some more compiler flags to find openblas Signed-off-by: Marcel Müller --------- Signed-off-by: Marcel Müller --- .github/workflows/build.yml | 50 ++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3e25bccd..b2d9ad7f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,7 +5,7 @@ on: [push, pull_request] env: BUILD_DIR: _build PIP_PACKAGES: >- - meson==0.55 + meson cmake ninja gcovr @@ -14,10 +14,10 @@ env: MACOS_HPCKIT_URL: >- https://registrationcenter-download.intel.com/akdlm/irc_nas/17890/m_HPCKit_p_2021.3.0.3226_offline.dmg LINUX_INTEL_COMPONENTS: >- - intel-oneapi-compiler-fortran - intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic - intel-oneapi-mkl - intel-oneapi-mkl-devel + intel-oneapi-compiler-fortran-2021.2.0 + intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic-2021.2.0 + intel-oneapi-mkl-2021.2.0 + intel-oneapi-mkl-devel-2021.2.0 jobs: build: @@ -29,14 +29,14 @@ jobs: build: [meson, cmake] build-type: [debug] compiler: [gnu] - version: [10] + version: [12] include: - os: ubuntu-latest build: meson build-type: coverage compiler: gnu - version: 10 + version: 11 - os: windows-latest build: meson @@ -58,24 +58,33 @@ jobs: FC: ${{ matrix.compiler == 'intel' && 'ifort' || 'gfortran' }} CC: ${{ matrix.compiler == 'intel' && 'icc' || 'gcc' }} GCC_V: ${{ matrix.version }} - PYTHON_V: 3.8 + PYTHON_V: 3.9 OMP_NUM_THREADS: 1,2,1 steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - uses: actions/setup-python@v1 + - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_V }} - - name: Install GCC (OSX) + - name: Link pre-installed GCC and FC (macOS) if: ${{ contains(matrix.os, 'macos') && matrix.compiler == 'gnu' }} run: | - brew install gcc@${{ env.GCC_V }} - ln -s /usr/local/bin/gfortran-${{ env.GCC_V }} /usr/local/bin/gfortran - ln -s /usr/local/bin/gcc-${{ env.GCC_V }} /usr/local/bin/gcc - ln -s /usr/local/bin/g++-${{ env.GCC_V }} /usr/local/bin/g++ + brew install openblas + gfortran_path=$( which gfortran-${{ env.GCC_V }} ) + gcc_path=$( which gcc-${{ env.GCC_V }} ) + gplusplus_path=$( which g++-${{ env.GCC_V }} ) + export FC=$gfortran_path + export CC=$gcc_path + export CXX=$gplusplus_path + ln -s $gfortran_path /usr/local/bin/gfortran + ln -s $gcc_path /usr/local/bin/gcc + ln -s $gplusplus_path /usr/local/bin/g++ + echo "PKG_CONFIG_PATH=/usr/local/opt/openblas/lib/pkgconfig" >> $GITHUB_ENV + echo "LDFLAGS=-L/opt/homebrew/opt/openblas/lib" >> $GITHUB_ENV + echo "CPPFLAGS=-I/opt/homebrew/opt/openblas/include" >> $GITHUB_ENV - name: Install GCC (Linux) if: ${{ contains(matrix.os, 'ubuntu') && matrix.compiler == 'gnu' }} @@ -176,7 +185,6 @@ jobs: if: ${{ matrix.compiler == 'intel' }} run: | source /opt/intel/oneapi/setvars.sh - source /opt/intel/oneapi/compiler/2024.0/env/vars.sh printenv >> $GITHUB_ENV - name: Install build and test dependencies @@ -187,6 +195,12 @@ jobs: if: ${{ contains(matrix.os, 'windows') }} run: pip3 install meson==0.55 + - name: Check gfortran version for meson build + if: ${{ matrix.build == 'meson' && matrix.compiler == 'gnu' }} + run: | + gfortran --version + which gfortran + - name: Configure build (meson) if: ${{ matrix.build == 'meson' }} run: >- @@ -199,7 +213,9 @@ jobs: ${{ env.MESON_ARGS }} env: COVERAGE: ${{ matrix.build-type == 'coverage' }} - MESON_ARGS: ${{ matrix.compiler == 'intel' && '-Dfortran_link_args=-qopenmp' || '' }} + MESON_ARGS: >- + ${{ matrix.compiler == 'intel' && '-Dfortran_link_args=-qopenmp' || '' }} + ${{ contains(matrix.os, 'macos') && '-Dlapack=openblas' || '' }} - name: Configure build (CMake) if: ${{ matrix.build == 'cmake' }} From bdc5171f0352cc52891a364936ea03b238238337 Mon Sep 17 00:00:00 2001 From: hongyi-zhao Date: Tue, 6 Aug 2024 19:12:41 +0800 Subject: [PATCH 06/13] Treat Intel LLVM compiler as standard Intel compiler. (#32) These changes ensure that the Intel LLVM compiler is treated as the standard Intel compiler, addressing specific compatibility issues we've encountered. --- config/meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/meson.build b/config/meson.build index e35c7acd..75c632b7 100644 --- a/config/meson.build +++ b/config/meson.build @@ -17,6 +17,10 @@ os = host_machine.system() fc = meson.get_compiler('fortran') fc_id = fc.get_id() +# Treat Intel LLVM compiler as standard Intel compiler for compatibility +if fc_id == 'intel-llvm' + fc_id = 'intel' +endif if fc_id == 'gcc' add_project_arguments( '-ffree-line-length-none', From 744deabddb86720fcb9fcd050dc5e65be079346d Mon Sep 17 00:00:00 2001 From: Marcel Mueller Date: Wed, 7 Aug 2024 13:33:29 +0200 Subject: [PATCH 07/13] Provide support for JSON output in `tblite` flavour (#29) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * provide support for JSON output in tblite flavour for multicharge Signed-off-by: Marcel Mueller * add CN to JSON output, correct compiler warnings, and improve output Signed-off-by: Marcel Mueller * add validation tests for multicharge Signed-off-by: Marcel Müller * CMake and meson files for new dir structure Signed-off-by: Marcel Müller * update CI, help files, and CLI Signed-off-by: Marcel Müller * correct CI errors Signed-off-by: Marcel Müller * correct wrong conditional statement and inconsistent indentation Signed-off-by: Marcel Müller * improve documentation Signed-off-by: Marcel Müller * Revert unrelated change on gradient argument --------- Signed-off-by: Marcel Mueller Signed-off-by: Marcel Müller Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> --- .github/workflows/build.yml | 14 +- app/main.f90 | 23 ++- man/multicharge.1.adoc | 3 + src/multicharge/output.f90 | 75 ++++++++- test/CMakeLists.txt | 32 +--- test/meson.build | 41 +---- test/unit/CMakeLists.txt | 46 ++++++ test/{ => unit}/main.f90 | 0 test/unit/meson.build | 54 +++++++ test/{ => unit}/test_model.f90 | 0 test/{ => unit}/test_ncoord.f90 | 0 test/{ => unit}/test_pbc.f90 | 0 test/{ => unit}/test_wignerseitz.f90 | 0 test/validation/01_h3+/coord | 6 + test/validation/01_h3+/multicharge_ref.json | 25 +++ test/validation/02_heada/coord | 29 ++++ test/validation/02_heada/multicharge_ref.json | 145 ++++++++++++++++++ test/validation/03_etlicl-/coord | 12 ++ .../03_etlicl-/multicharge_ref.json | 55 +++++++ test/validation/meson.build | 38 +++++ test/validation/tester.py | 72 +++++++++ 21 files changed, 594 insertions(+), 76 deletions(-) create mode 100644 test/unit/CMakeLists.txt rename test/{ => unit}/main.f90 (100%) create mode 100644 test/unit/meson.build rename test/{ => unit}/test_model.f90 (100%) rename test/{ => unit}/test_ncoord.f90 (100%) rename test/{ => unit}/test_pbc.f90 (100%) rename test/{ => unit}/test_wignerseitz.f90 (100%) create mode 100644 test/validation/01_h3+/coord create mode 100644 test/validation/01_h3+/multicharge_ref.json create mode 100644 test/validation/02_heada/coord create mode 100644 test/validation/02_heada/multicharge_ref.json create mode 100644 test/validation/03_etlicl-/coord create mode 100644 test/validation/03_etlicl-/multicharge_ref.json create mode 100644 test/validation/meson.build create mode 100755 test/validation/tester.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b2d9ad7f..4c6915c7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,6 +9,8 @@ env: cmake ninja gcovr + numpy + pytest MACOS_BASEKIT_URL: >- https://registrationcenter-download.intel.com/akdlm/irc_nas/17969/m_BaseKit_p_2021.3.0.3043.dmg MACOS_HPCKIT_URL: >- @@ -236,18 +238,26 @@ jobs: meson test -C ${{ env.BUILD_DIR }} --print-errorlogs --no-rebuild env: OMP_NUM_THREADS: 1 + MKL_NUM_THREADS: 1 + - name: Run validation tests + if: ${{ matrix.build == 'meson' && ! contains(matrix.os, 'windows') }} + run: | + meson test -C ${{ env.BUILD_DIR }} --print-errorlogs --no-rebuild --suite multicharge --benchmark + env: + OMP_NUM_THREADS: 1 + MKL_NUM_THREADS: 1 - name: Run unit tests if: ${{ matrix.build == 'cmake' }} run: | - ctest --output-on-failure --parallel 2 + ctest --output-on-failure --parallel 2 working-directory: ${{ env.BUILD_DIR }} - name: Create coverage report if: ${{ matrix.build == 'meson' && matrix.build-type == 'coverage' }} run: - ninja -C ${{ env.BUILD_DIR }} coverage + ninja -C ${{ env.BUILD_DIR }} coverage - name: Install project run: | diff --git a/app/main.f90 b/app/main.f90 index aaa212b3..25923795 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -21,8 +21,10 @@ program main & write_ascii_model, write_ascii_properties, write_ascii_results, & & get_coordination_number, get_covalent_rad, get_lattice_points, & & get_multicharge_version + use multicharge_output, only : json_results implicit none character(len=*), parameter :: prog_name = "multicharge" + character(len=*), parameter :: json_output = "multicharge.json" character(len=:), allocatable :: input, chargeinput integer, allocatable :: input_format @@ -30,14 +32,14 @@ program main type(error_type), allocatable :: error type(structure_type) :: mol type(mchrg_model_type) :: model - logical :: grad, exist + logical :: grad, json, exist real(wp), parameter :: cn_max = 8.0_wp, cutoff = 25.0_wp real(wp), allocatable :: cn(:), dcndr(:, :, :), dcndL(:, :, :), rcov(:), trans(:, :) real(wp), allocatable :: energy(:), gradient(:, :), sigma(:, :) real(wp), allocatable :: qvec(:), dqdr(:, :, :), dqdL(:, :, :) real(wp), allocatable :: charge - call get_arguments(input, input_format, grad, charge, error) + call get_arguments(input, input_format, grad, charge, json, error) if (allocated(error)) then write(error_unit, '(a)') error%message error stop @@ -102,6 +104,14 @@ program main call write_ascii_properties(output_unit, mol, model, cn, qvec) call write_ascii_results(output_unit, mol, energy, gradient, sigma) + if (json) then + open(file=json_output, newunit=unit) + call json_results(unit, " ", energy=sum(energy), gradient=gradient, charges=qvec, cn=cn) + close(unit) + write(output_unit, '(a)') & + "[Info] JSON dump of results written to '"// json_output //"'" + end if + contains @@ -121,6 +131,7 @@ subroutine help(unit) "-i, --input ", "Hint for the format of the input file", & "-c, --charge ", "Set the molecular charge", & "-g, --grad", "Evaluate molecular gradient and virial", & + "-j, --json", "Provide output in JSON format to the file 'multicharge.json'", & "-v, --version", "Print program version and exit", & "-h, --help", "Show this help message" @@ -140,7 +151,7 @@ subroutine version(unit) end subroutine version -subroutine get_arguments(input, input_format, grad, charge, error) +subroutine get_arguments(input, input_format, grad, charge, json, error) !> Input file name character(len=:), allocatable :: input @@ -151,6 +162,9 @@ subroutine get_arguments(input, input_format, grad, charge, error) !> Evaluate gradient logical, intent(out) :: grad + !> Provide JSON output + logical, intent(out) :: json + !> Charge real(wp), allocatable, intent(out) :: charge @@ -161,6 +175,7 @@ subroutine get_arguments(input, input_format, grad, charge, error) character(len=:), allocatable :: arg grad = .false. + json = .false. iarg = 0 narg = command_argument_count() do while(iarg < narg) @@ -203,6 +218,8 @@ subroutine get_arguments(input, input_format, grad, charge, error) end if case("-grad", "--grad") grad = .true. + case("-j", "--json") + json = .true. end select end do diff --git a/man/multicharge.1.adoc b/man/multicharge.1.adoc index c479aff3..796cf6aa 100644 --- a/man/multicharge.1.adoc +++ b/man/multicharge.1.adoc @@ -17,6 +17,9 @@ Electronegativity equilibration model for atomic partial charges. *-i, --input* _format_:: Hint for the format of the input file +*--json*:: +Provide output in JSON format to the file 'multicharge.json' + *--grad*:: Evaluate molecular gradient and virial diff --git a/src/multicharge/output.f90 b/src/multicharge/output.f90 index 43682684..852407a7 100644 --- a/src/multicharge/output.f90 +++ b/src/multicharge/output.f90 @@ -19,10 +19,11 @@ module multicharge_output use mctc_io_convert, only : autoaa use mctc_io_constants, only : pi use multicharge_model, only : mchrg_model_type + use multicharge_version, only : get_multicharge_version implicit none private - public :: write_ascii_model, write_ascii_properties, write_ascii_results + public :: write_ascii_model, write_ascii_properties, write_ascii_results, json_results contains @@ -139,4 +140,76 @@ subroutine write_ascii_results(unit, mol, energy, gradient, sigma) end subroutine write_ascii_results +subroutine json_results(unit, indentation, energy, gradient, charges, cn) + integer, intent(in) :: unit + character(len=*), intent(in), optional :: indentation + real(wp), intent(in), optional :: energy + real(wp), intent(in), optional :: gradient(:, :) + real(wp), intent(in), optional :: charges(:) + real(wp), intent(in), optional :: cn(:) + character(len=:), allocatable :: indent, version_string + character(len=*), parameter :: jsonkey = "('""',a,'"":',1x)" + real(wp), allocatable :: array(:) + + call get_multicharge_version(string=version_string) + + if (present(indentation)) then + indent = indentation + else + indent = "" + end if + + write(unit, '("{")', advance='no') + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, jsonkey, advance='no') 'version' + write(unit, '(1x,a)', advance='no') '"'//version_string//'"' + if (present(energy)) then + write(unit, '(",")', advance='no') + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, jsonkey, advance='no') 'energy' + write(unit, '(1x,es25.16)', advance='no') energy + end if + if (present(gradient)) then + write(unit, '(",")', advance='no') + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, jsonkey, advance='no') 'gradient' + array = reshape(gradient, [size(gradient)]) + call write_json_array(unit, array, indent) + end if + if (present(charges)) then + write(unit, '(",")', advance='no') + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, jsonkey, advance='no') 'charges' + array = reshape(charges, [size(charges)]) + call write_json_array(unit, array, indent) + end if + if (present(cn)) then + write(unit, '(",")', advance='no') + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, jsonkey, advance='no') 'coordination numbers' + array = reshape(cn, [size(cn)]) + call write_json_array(unit, array, indent) + end if + if (allocated(indent)) write(unit, '(/)', advance='no') + write(unit, '("}")') + +end subroutine json_results + + +subroutine write_json_array(unit, array, indent) + integer, intent(in) :: unit + real(wp), intent(in) :: array(:) + character(len=:), allocatable, intent(in) :: indent + integer :: i + write(unit, '("[")', advance='no') + do i = 1, size(array) + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 2) + write(unit, '(es23.16)', advance='no') array(i) + if (i /= size(array)) write(unit, '(",")', advance='no') + end do + if (allocated(indent)) write(unit, '(/,a)', advance='no') repeat(indent, 1) + write(unit, '("]")', advance='no') +end subroutine write_json_array + + end module multicharge_output diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index df75f3d0..6dd1d8e9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,34 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Unit testing -set( - tests - "model" - "ncoord" - "pbc" - "wignerseitz" -) -set( - test-srcs - "main.f90" -) -foreach(t IN LISTS tests) - string(MAKE_C_IDENTIFIER ${t} t) - list(APPEND test-srcs "test_${t}.f90") -endforeach() - -add_executable( - "${PROJECT_NAME}-tester" - "${test-srcs}" -) -target_link_libraries( - "${PROJECT_NAME}-tester" - PRIVATE - "${PROJECT_NAME}-lib" - "mstore::mstore" -) - -foreach(t IN LISTS tests) - add_test("${t}" "${PROJECT_NAME}-tester" "${t}") -endforeach() +add_subdirectory("unit") \ No newline at end of file diff --git a/test/meson.build b/test/meson.build index 740e5080..16dc8acf 100644 --- a/test/meson.build +++ b/test/meson.build @@ -13,42 +13,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -# Find mstore dependency for testing -mstore_dep = dependency( - 'mstore', - version: '>=0.1', - fallback: ['mstore', 'mstore_dep'], - required: not meson.is_subproject(), - default_options: [ - 'default_library=static', - ], -) -# If we do not find mstore and are a subproject, we just skip testing -if not mstore_dep.found() - subdir_done() -endif - -tests = [ - 'model', - 'ncoord', - 'pbc', - 'wignerseitz', -] - -test_srcs = files( - 'main.f90', -) -foreach t : tests - test_srcs += files('test_@0@.f90'.format(t.underscorify())) -endforeach - -tester = executable( - 'tester', - sources: test_srcs, - dependencies: [multicharge_dep, mstore_dep], - link_language: 'fortran', -) - -foreach t : tests - test(t, tester, args: t) -endforeach +subdir('validation') +subdir('unit') \ No newline at end of file diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt new file mode 100644 index 00000000..df75f3d0 --- /dev/null +++ b/test/unit/CMakeLists.txt @@ -0,0 +1,46 @@ +# This file is part of multicharge. +# SPDX-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Unit testing +set( + tests + "model" + "ncoord" + "pbc" + "wignerseitz" +) +set( + test-srcs + "main.f90" +) +foreach(t IN LISTS tests) + string(MAKE_C_IDENTIFIER ${t} t) + list(APPEND test-srcs "test_${t}.f90") +endforeach() + +add_executable( + "${PROJECT_NAME}-tester" + "${test-srcs}" +) +target_link_libraries( + "${PROJECT_NAME}-tester" + PRIVATE + "${PROJECT_NAME}-lib" + "mstore::mstore" +) + +foreach(t IN LISTS tests) + add_test("${t}" "${PROJECT_NAME}-tester" "${t}") +endforeach() diff --git a/test/main.f90 b/test/unit/main.f90 similarity index 100% rename from test/main.f90 rename to test/unit/main.f90 diff --git a/test/unit/meson.build b/test/unit/meson.build new file mode 100644 index 00000000..740e5080 --- /dev/null +++ b/test/unit/meson.build @@ -0,0 +1,54 @@ +# This file is part of multicharge. +# SPDX-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Find mstore dependency for testing +mstore_dep = dependency( + 'mstore', + version: '>=0.1', + fallback: ['mstore', 'mstore_dep'], + required: not meson.is_subproject(), + default_options: [ + 'default_library=static', + ], +) +# If we do not find mstore and are a subproject, we just skip testing +if not mstore_dep.found() + subdir_done() +endif + +tests = [ + 'model', + 'ncoord', + 'pbc', + 'wignerseitz', +] + +test_srcs = files( + 'main.f90', +) +foreach t : tests + test_srcs += files('test_@0@.f90'.format(t.underscorify())) +endforeach + +tester = executable( + 'tester', + sources: test_srcs, + dependencies: [multicharge_dep, mstore_dep], + link_language: 'fortran', +) + +foreach t : tests + test(t, tester, args: t) +endforeach diff --git a/test/test_model.f90 b/test/unit/test_model.f90 similarity index 100% rename from test/test_model.f90 rename to test/unit/test_model.f90 diff --git a/test/test_ncoord.f90 b/test/unit/test_ncoord.f90 similarity index 100% rename from test/test_ncoord.f90 rename to test/unit/test_ncoord.f90 diff --git a/test/test_pbc.f90 b/test/unit/test_pbc.f90 similarity index 100% rename from test/test_pbc.f90 rename to test/unit/test_pbc.f90 diff --git a/test/test_wignerseitz.f90 b/test/unit/test_wignerseitz.f90 similarity index 100% rename from test/test_wignerseitz.f90 rename to test/unit/test_wignerseitz.f90 diff --git a/test/validation/01_h3+/coord b/test/validation/01_h3+/coord new file mode 100644 index 00000000..40859ae8 --- /dev/null +++ b/test/validation/01_h3+/coord @@ -0,0 +1,6 @@ +$coord + -0.47073898552969 0.81534384004086 0.00000000000000 h + -0.47073898552969 -0.81534384004086 0.00000000000000 h + 0.94147797105939 0.00000000000000 0.00000000000000 h +$eht charge=+1 +$end diff --git a/test/validation/01_h3+/multicharge_ref.json b/test/validation/01_h3+/multicharge_ref.json new file mode 100644 index 00000000..f0628165 --- /dev/null +++ b/test/validation/01_h3+/multicharge_ref.json @@ -0,0 +1,25 @@ +{ + "version": "0.2.0", + "energy": 5.9509615561036766E-01, + "gradient": [ + -3.8496744880950964E-03, + 6.6678318059824465E-03, + 0.0000000000000000E+00, + -3.8496744880951173E-03, + -6.6678318059824535E-03, + 0.0000000000000000E+00, + 7.6993489761902068E-03, + 1.2143064331837650E-17, + 0.0000000000000000E+00 + ], + "charges": [ + 3.3333333333333348E-01, + 3.3333333333333304E-01, + 3.3333333333333337E-01 + ], + "coordination numbers": [ + 9.0462899697901555E-01, + 9.0462899697901555E-01, + 9.0462899697901733E-01 + ] +} diff --git a/test/validation/02_heada/coord b/test/validation/02_heada/coord new file mode 100644 index 00000000..30498abc --- /dev/null +++ b/test/validation/02_heada/coord @@ -0,0 +1,29 @@ +$coord + 0.00000000000000 0.00000000000000 0.00000000000000 he + 3.45821348512771 -0.00000000000000 -0.00000000000000 c + 1.75464592422341 -1.75464592422341 -1.75464592422341 c + 0.00000000000000 -0.00000000000000 -3.45821348512771 c + -1.75464592422341 1.75464592422341 -1.75464592422341 c + 0.00000000000000 3.45821348512771 0.00000000000000 c + 1.75464592422341 1.75464592422341 1.75464592422341 c + -0.00000000000000 -3.45821348512771 0.00000000000000 c + -3.45821348512771 0.00000000000000 -0.00000000000000 c + 0.00000000000000 0.00000000000000 3.45821348512771 c + -1.75464592422341 -1.75464592422341 1.75464592422341 c + 4.69306399710192 1.17200806786605 -1.17200806786605 h + 4.69306399710192 -1.17200806786605 1.17200806786605 h + 2.94855848349429 -2.94855848349429 -2.94855848349429 h + -1.17200806786605 -1.17200806786605 -4.69306399710192 h + 1.17200806786605 1.17200806786605 -4.69306399710192 h + -2.94855848349429 2.94855848349429 -2.94855848349429 h + -1.17200806786605 4.69306399710192 1.17200806786605 h + 1.17200806786605 4.69306399710192 -1.17200806786605 h + 2.94855848349429 2.94855848349429 2.94855848349429 h + 1.17200806786605 -4.69306399710192 1.17200806786605 h + -1.17200806786605 -4.69306399710192 -1.17200806786605 h + -4.69306399710192 1.17200806786605 1.17200806786605 h + -4.69306399710192 -1.17200806786605 -1.17200806786605 h + -1.17200806786605 1.17200806786605 4.69306399710192 h + 1.17200806786605 -1.17200806786605 4.69306399710192 h + -2.94855848349429 -2.94855848349429 2.94855848349429 h +$end diff --git a/test/validation/02_heada/multicharge_ref.json b/test/validation/02_heada/multicharge_ref.json new file mode 100644 index 00000000..570bd7dc --- /dev/null +++ b/test/validation/02_heada/multicharge_ref.json @@ -0,0 +1,145 @@ +{ + "version": "0.2.0", + "energy": -6.9073923077553639E-02, + "gradient": [ + 5.4685297775906385E-18, + 3.7880164102381066E-18, + -3.6524911386774186E-18, + -3.0849876857277875E-03, + -1.3045459427211193E-18, + -6.0636064192913160E-19, + 1.1975944355421286E-03, + -1.1975944355421303E-03, + -1.1975944355421294E-03, + -6.1564798081555210E-19, + -2.1591866731057316E-18, + 3.0849876857277979E-03, + -1.1975944355421303E-03, + 1.1975944355421290E-03, + -1.1975944355421303E-03, + -5.9218047127941819E-18, + -3.0849876857277957E-03, + 5.0694445830727641E-18, + 1.1975944355421238E-03, + 1.1975944355421251E-03, + 1.1975944355421273E-03, + -1.8575363339891593E-18, + 3.0849876857278035E-03, + -1.5405484152757073E-18, + 3.0849876857277862E-03, + 7.6543332838226718E-19, + 2.9426082167072994E-18, + -6.9834148374823181E-18, + 4.2723695961834720E-18, + -3.0849876857277935E-03, + -1.1975944355421409E-03, + -1.1975944355421416E-03, + 1.1975944355421418E-03, + 1.5534875034218820E-03, + 6.3528000234702698E-04, + -6.3528000234702622E-04, + 1.5534875034218846E-03, + -6.3528000234702687E-04, + 6.3528000234702763E-04, + 9.6854360862262602E-04, + -9.6854360862262527E-04, + -9.6854360862262646E-04, + -6.3528000234702850E-04, + -6.3528000234702796E-04, + -1.5534875034218891E-03, + 6.3528000234702904E-04, + 6.3528000234702937E-04, + -1.5534875034218878E-03, + -9.6854360862262429E-04, + 9.6854360862262483E-04, + -9.6854360862262527E-04, + -6.3528000234702470E-04, + 1.5534875034218848E-03, + 6.3528000234702492E-04, + 6.3528000234703110E-04, + 1.5534875034218913E-03, + -6.3528000234703078E-04, + 9.6854360862262960E-04, + 9.6854360862262982E-04, + 9.6854360862262819E-04, + 6.3528000234703121E-04, + -1.5534875034218904E-03, + 6.3528000234703121E-04, + -6.3528000234702882E-04, + -1.5534875034218874E-03, + -6.3528000234702904E-04, + -1.5534875034218828E-03, + 6.3528000234702633E-04, + 6.3528000234702546E-04, + -1.5534875034218848E-03, + -6.3528000234702720E-04, + -6.3528000234702850E-04, + -6.3528000234702416E-04, + 6.3528000234702481E-04, + 1.5534875034218798E-03, + 6.3528000234703208E-04, + -6.3528000234703121E-04, + 1.5534875034218900E-03, + -9.6854360862261865E-04, + -9.6854360862261844E-04, + 9.6854360862261865E-04 + ], + "charges": [ + 1.2186483847965052E-01, + -1.7320969829383182E-01, + -9.0167540102614741E-02, + -1.7320969829383204E-01, + -9.0167540102614741E-02, + -1.7320969829383193E-01, + -9.0167540102614852E-02, + -1.7320969829383237E-01, + -1.7320969829383182E-01, + -1.7320969829383204E-01, + -9.0167540102614296E-02, + 8.1086719360566051E-02, + 8.1086719360566106E-02, + 7.6255719841751557E-02, + 8.1086719360566273E-02, + 8.1086719360566301E-02, + 7.6255719841751501E-02, + 8.1086719360566079E-02, + 8.1086719360566467E-02, + 7.6255719841751751E-02, + 8.1086719360566384E-02, + 8.1086719360566217E-02, + 8.1086719360566079E-02, + 8.1086719360566190E-02, + 8.1086719360565912E-02, + 8.1086719360566412E-02, + 7.6255719841751113E-02 + ], + "coordination numbers": [ + 2.5125124130330718E+00, + 4.0181738840822980E+00, + 4.4334366410989272E+00, + 4.0181738840822980E+00, + 4.4334366410989263E+00, + 4.0181738840822980E+00, + 4.4334366410989263E+00, + 4.0181738840822980E+00, + 4.0181738840822980E+00, + 4.0181738840822980E+00, + 4.4334366410989263E+00, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9269385294693535E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9269385294693535E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9269385294693535E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9276904481668637E-01, + 9.9269385294693535E-01 + ] +} diff --git a/test/validation/03_etlicl-/coord b/test/validation/03_etlicl-/coord new file mode 100644 index 00000000..1bd9b3e5 --- /dev/null +++ b/test/validation/03_etlicl-/coord @@ -0,0 +1,12 @@ +$coord + 0.89396255378253 2.10736170652362 0.00000000000000 c + 0.97239001887296 -0.78427942500677 0.00000000000000 c + 2.75167341074035 3.07798924513758 0.00000000000000 h + -0.12572495466197 2.84199486858183 -1.65261641319524 h + -0.12572495466197 2.84199486858183 1.65261641319524 h + 2.09631685859630 -1.40781857214772 -1.64450579081954 h + 2.09631685859630 -1.40781857214772 1.64450579081954 h + -2.48518471782932 -2.65050970583691 0.00000000000000 li + -6.07402507343515 -4.61891441368572 0.00000000000000 cl +$eht charge=-1 +$end diff --git a/test/validation/03_etlicl-/multicharge_ref.json b/test/validation/03_etlicl-/multicharge_ref.json new file mode 100644 index 00000000..6effd3be --- /dev/null +++ b/test/validation/03_etlicl-/multicharge_ref.json @@ -0,0 +1,55 @@ +{ + "version": "0.2.0", + "energy": -8.1229405654410192E-01, + "gradient": [ + 1.4232201382417559E-05, + -1.0290897995788412E-02, + -4.8111471404044259E-19, + 8.8181192331940640E-03, + 1.6040868979181680E-02, + -2.1684043449710089E-19, + -1.1262761030204154E-03, + -7.9344514548550888E-04, + -6.7762635780344027E-21, + 7.6009524154963947E-04, + -7.1958985135979090E-04, + 1.1312329300021994E-03, + 7.6009524154963903E-04, + -7.1958985135979036E-04, + -1.1312329300021988E-03, + -7.6669966088608894E-04, + 6.8324957888392694E-04, + 1.1831223238083551E-03, + -7.6669966088608894E-04, + 6.8324957888392704E-04, + -1.1831223238083551E-03, + 2.6974466454641639E-03, + 1.2199223431970472E-05, + 5.4210108624275222E-20, + -1.0390313138347335E-02, + -4.8960445163879988E-03, + -1.3552527156068805E-20 + ], + "charges": [ + -3.7490477825182533E-01, + -4.9002846040519082E-01, + -1.3110484383964643E-02, + -1.7219399835397248E-02, + -1.7219399835397234E-02, + -1.2981335776944464E-02, + -1.2981335776944464E-02, + 5.5301996167376810E-01, + -6.1457476740810379E-01 + ], + "coordination numbers": [ + 3.9752453171971291E+00, + 3.9430550631132357E+00, + 9.9030843464528484E-01, + 9.9205566589431982E-01, + 9.9205566589431982E-01, + 9.9159659365792852E-01, + 9.9159659365792852E-01, + 2.0021222111180936E+00, + 9.9634262150427322E-01 + ] +} diff --git a/test/validation/meson.build b/test/validation/meson.build new file mode 100644 index 00000000..8be67f8e --- /dev/null +++ b/test/validation/meson.build @@ -0,0 +1,38 @@ +# This file is part of multicharge. +# SPDX-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +validation_tester = find_program(files('tester.py')) + +run_element = [ + '01_h3+', + '02_heada', + '03_etlicl-', +] + +foreach t : run_element + benchmark( + '@0@'.format(t), + validation_tester, + args: [ + multicharge_exe, + files(t/'multicharge_ref.json'), + files(t/'coord'), + '--grad', + t.contains('+') ? ['--charge', '+1'] : [], + t.contains('-') ? ['--charge', '-1'] : [], + ], + suite: 'multicharge', + ) +endforeach diff --git a/test/validation/tester.py b/test/validation/tester.py new file mode 100755 index 00000000..ef667457 --- /dev/null +++ b/test/validation/tester.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python + +# This file is part of multicharge. +# SPDX-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +Minimal Python wrapper for testing the multicharge command line interface. + +The wrapper will assume a specific order in the arguments rather than +providing a generic command line interface by itself since it is +supposed to be used by meson for testing purposes only. +""" + +try: + import json + import os + import subprocess + import sys + + import numpy as np + import pytest +except ImportError: + exit(77) + +if len(sys.argv) < 4: + raise RuntimeError("Requires at least four arguments") + +THR = 5.0e-7 +prog = sys.argv[1] +reference_file = sys.argv[2] +args = sys.argv[3:] + +method_name = os.path.basename(reference_file) +test_name = os.path.basename(os.path.dirname(reference_file)) + +stat = subprocess.call( + [prog] + args + ["--json"], + shell=False, + stdin=None, + stderr=subprocess.STDOUT, +) +if stat != 0: + raise RuntimeError("Calculation failed") + +with open(reference_file, encoding="utf8") as f: + ref = json.load(f) + del ref["version"] + +with open("multicharge.json", encoding="utf8") as f: + res = json.load(f) + +for key in ref: + if key not in res: + raise RuntimeError("Missing '" + key + "' entry in results") + _res = np.array(res[key]) + _ref = np.array(ref[key]) + assert pytest.approx(_res, abs=THR) == _ref, \ + f"mismatch for {key}:\n" \ + f"+actual\n{_res}\n" \ + f"-reference\n{_ref}\n" \ + f"@difference\n{_res - _ref}" From f8b414143fe192de379b85f4c30b6d9b6a58fb1e Mon Sep 17 00:00:00 2001 From: Marcel Mueller Date: Fri, 9 Aug 2024 09:12:15 +0200 Subject: [PATCH 08/13] Make flags for gradient evaluation more consistent (#33) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * make flags for gradient evaluation more consistent Signed-off-by: Marcel Müller * Update app/main.f90 Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> * make documentation and effective CLI consistent Signed-off-by: Marcel Müller --------- Signed-off-by: Marcel Müller Co-authored-by: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> --- app/main.f90 | 16 ++++++++-------- man/multicharge.1.adoc | 13 ++++++++----- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/main.f90 b/app/main.f90 index 25923795..c528a8bf 100644 --- a/app/main.f90 +++ b/app/main.f90 @@ -128,12 +128,12 @@ subroutine help(unit) "" write(unit, '(2x, a, t25, a)') & - "-i, --input ", "Hint for the format of the input file", & - "-c, --charge ", "Set the molecular charge", & - "-g, --grad", "Evaluate molecular gradient and virial", & - "-j, --json", "Provide output in JSON format to the file 'multicharge.json'", & - "-v, --version", "Print program version and exit", & - "-h, --help", "Show this help message" + "-i, -input, --input ", "Hint for the format of the input file", & + "-c, -charge, --charge ", "Set the molecular charge", & + "-g, -grad, --grad", "Evaluate molecular gradient and virial", & + "-j, -json, --json", "Provide output in JSON format to the file 'multicharge.json'", & + "-v, -version, --version", "Print program version and exit", & + "-h, -help, --help", "Show this help message" write(unit, '(a)') @@ -216,9 +216,9 @@ subroutine get_arguments(input, input_format, grad, charge, json, error) call fatal_error(error, "Invalid charge value") exit end if - case("-grad", "--grad") + case("-g", "-grad", "--grad") grad = .true. - case("-j", "--json") + case("-j", "-json", "--json") json = .true. end select end do diff --git a/man/multicharge.1.adoc b/man/multicharge.1.adoc index 796cf6aa..e7128d8b 100644 --- a/man/multicharge.1.adoc +++ b/man/multicharge.1.adoc @@ -14,17 +14,20 @@ Electronegativity equilibration model for atomic partial charges. == Options -*-i, --input* _format_:: +*-i, -input, --input* _format_:: Hint for the format of the input file -*--json*:: +*-c, -charge, --charge* _value_:: +Provide the molecular charge + +*-j, -json, --json*:: Provide output in JSON format to the file 'multicharge.json' -*--grad*:: +*-g, -grad, --grad*:: Evaluate molecular gradient and virial -*--version*:: +*-v, -version, --version*:: Print program version and exit -*--help*:: +*-h, -help, --help*:: Show this help message From 282626e690aa7db2aec448d9032636a5cd75f25c Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 29 Aug 2024 14:25:54 +0100 Subject: [PATCH 09/13] Update to version 0.3.0 (#34) --- CMakeLists.txt | 2 +- config/cmake/Findcustom-blas.cmake | 2 +- config/cmake/Findcustom-lapack.cmake | 4 ++-- config/cmake/Findmctc-lib.cmake | 2 +- fpm.toml | 5 +++-- meson.build | 2 +- src/multicharge/version.f90 | 4 ++-- subprojects/mctc-lib.wrap | 2 +- subprojects/mstore.wrap | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fd224f5..97389b6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ get_directory_property(is-subproject PARENT_DIRECTORY) project( "multicharge" LANGUAGES "Fortran" - VERSION "0.2.0" + VERSION "0.3.0" DESCRIPTION "Molecular structure store for testing" ) diff --git a/config/cmake/Findcustom-blas.cmake b/config/cmake/Findcustom-blas.cmake index 7f71e627..d3760b00 100644 --- a/config/cmake/Findcustom-blas.cmake +++ b/config/cmake/Findcustom-blas.cmake @@ -22,7 +22,7 @@ if(WITH_ILP64) endif() if(NOT BLAS_FOUND) - find_package("BLAS") + find_package("BLAS" REQUIRED) if(NOT TARGET "BLAS::BLAS") add_library("BLAS::BLAS" INTERFACE IMPORTED) target_link_libraries("BLAS::BLAS" INTERFACE "${BLAS_LIBRARIES}") diff --git a/config/cmake/Findcustom-lapack.cmake b/config/cmake/Findcustom-lapack.cmake index 8cd9a6a6..0167a628 100644 --- a/config/cmake/Findcustom-lapack.cmake +++ b/config/cmake/Findcustom-lapack.cmake @@ -22,10 +22,10 @@ if(WITH_ILP64) endif() if(NOT LAPACK_FOUND) - find_package("LAPACK") + find_package("LAPACK" REQUIRED) if(NOT TARGET "BLAS::BLAS") - find_package("custom-blas") + find_package("custom-blas" REQUIRED) endif() if(NOT TARGET "LAPACK::LAPACK") diff --git a/config/cmake/Findmctc-lib.cmake b/config/cmake/Findmctc-lib.cmake index 931e2bd9..e554177f 100644 --- a/config/cmake/Findmctc-lib.cmake +++ b/config/cmake/Findmctc-lib.cmake @@ -16,7 +16,7 @@ set(_lib "mctc-lib") set(_pkg "MCTCLIB") set(_url "https://github.com/grimme-lab/mctc-lib") -set(_rev "v0.3.0") +set(_rev "v0.3.2") if(NOT DEFINED "${_pkg}_FIND_METHOD") if(DEFINED "${PROJECT_NAME}-dependency-method") diff --git a/fpm.toml b/fpm.toml index 5dccd623..4b84697f 100644 --- a/fpm.toml +++ b/fpm.toml @@ -1,5 +1,5 @@ name = "multicharge" -version = "0.2.0" +version = "0.3.0" license = "Apache-2.0" author = ["Sebastian Ehlert"] maintainer = ["@awvwgk"] @@ -10,7 +10,8 @@ link = ["lapack", "blas"] [dependencies] mctc-lib.git = "https://github.com/grimme-lab/mctc-lib.git" -mctc-lib.tag = "v0.3.0" +mctc-lib.tag = "v0.3.2" [dev-dependencies] mstore.git = "https://github.com/grimme-lab/mstore.git" +mstore.tag = "v0.3.0" diff --git a/meson.build b/meson.build index 6de70142..e4e30955 100644 --- a/meson.build +++ b/meson.build @@ -16,7 +16,7 @@ project( 'multicharge', 'fortran', - version: '0.2.0', + version: '0.3.0', license: 'Apache-2.0', meson_version: '>=0.55', default_options: [ diff --git a/src/multicharge/version.f90 b/src/multicharge/version.f90 index 644394b8..5a116c9d 100644 --- a/src/multicharge/version.f90 +++ b/src/multicharge/version.f90 @@ -23,10 +23,10 @@ module multicharge_version !> String representation of the multicharge version - character(len=*), parameter :: multicharge_version_string = "0.2.0" + character(len=*), parameter :: multicharge_version_string = "0.3.0" !> Numeric representation of the multicharge version - integer, parameter :: multicharge_version_compact(3) = [0, 2, 0] + integer, parameter :: multicharge_version_compact(3) = [0, 3, 0] contains diff --git a/subprojects/mctc-lib.wrap b/subprojects/mctc-lib.wrap index 5a16f50d..962f0040 100644 --- a/subprojects/mctc-lib.wrap +++ b/subprojects/mctc-lib.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = mctc-lib url = https://github.com/grimme-lab/mctc-lib -revision = v0.3.0 +revision = v0.3.2 diff --git a/subprojects/mstore.wrap b/subprojects/mstore.wrap index acf5df9d..0dfe716c 100644 --- a/subprojects/mstore.wrap +++ b/subprojects/mstore.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = mstore url = https://github.com/grimme-lab/mstore -revision = v0.2.0 +revision = v0.3.0 From 33a60ef32b28c8dd37a3f998535746daf86cc38f Mon Sep 17 00:00:00 2001 From: foxtran <39676482+foxtran@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:09:35 +0200 Subject: [PATCH 10/13] Use actions/cache@v4 and actions/upload-artifacts@v4 (#36) --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4c6915c7..ce963061 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -127,7 +127,7 @@ jobs: - name: Cache Intel install if: ${{ matrix.compiler == 'intel' }} id: cache-install - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: /opt/intel/oneapi key: install-${{ matrix.compiler }}-${{ matrix.version }}-${{ matrix.os }} @@ -275,7 +275,7 @@ jobs: - name: Upload package if: ${{ matrix.build == 'meson' && matrix.build-type != 'coverage' }} - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ${{ env.MCHRG_OUTPUT }} path: ${{ env.MCHRG_OUTPUT }} From 992b8bede760b00c138cd482898c8eecb41b595b Mon Sep 17 00:00:00 2001 From: foxtran <39676482+foxtran@users.noreply.github.com> Date: Mon, 28 Oct 2024 05:09:05 +0100 Subject: [PATCH 11/13] Update mctc-lib to latest (#35) --- subprojects/mctc-lib.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/mctc-lib.wrap b/subprojects/mctc-lib.wrap index 962f0040..71ad212d 100644 --- a/subprojects/mctc-lib.wrap +++ b/subprojects/mctc-lib.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = mctc-lib url = https://github.com/grimme-lab/mctc-lib -revision = v0.3.2 +revision = head From af762a6d5965121f5af3baafe40fc7731af70e5c Mon Sep 17 00:00:00 2001 From: Sebastian Ehlert <28669218+awvwgk@users.noreply.github.com> Date: Thu, 31 Oct 2024 09:16:15 +0100 Subject: [PATCH 12/13] Pin mctc-lib to 0.3.2 (#37) --- subprojects/mctc-lib.wrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/mctc-lib.wrap b/subprojects/mctc-lib.wrap index 71ad212d..962f0040 100644 --- a/subprojects/mctc-lib.wrap +++ b/subprojects/mctc-lib.wrap @@ -1,4 +1,4 @@ [wrap-git] directory = mctc-lib url = https://github.com/grimme-lab/mctc-lib -revision = head +revision = v0.3.2 From 2a3d67505e088819ec4ac613f75efd8c8ef54fd0 Mon Sep 17 00:00:00 2001 From: Thomas Froitzheim <92028749+thfroitzheim@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:25:10 +0100 Subject: [PATCH 13/13] Update cmake dependencies (#38) --- config/cmake/Findmstore.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/cmake/Findmstore.cmake b/config/cmake/Findmstore.cmake index fee80ce1..6afea0ab 100644 --- a/config/cmake/Findmstore.cmake +++ b/config/cmake/Findmstore.cmake @@ -16,6 +16,7 @@ set(_lib "mstore") set(_pkg "MSTORE") set(_url "https://github.com/grimme-lab/mstore") +set(_rev "v0.3.0") if(NOT DEFINED "${_pkg}_FIND_METHOD") if(DEFINED "${PROJECT_NAME}-dependency-method") @@ -28,7 +29,7 @@ endif() include("${CMAKE_CURRENT_LIST_DIR}/multicharge-utils.cmake") -multicharge_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}" "HEAD") +multicharge_find_package("${_lib}" "${${_pkg}_FIND_METHOD}" "${_url}" "${_rev}") if(DEFINED "_${_pkg}_FIND_METHOD") unset("${_pkg}_FIND_METHOD")