diff --git a/src/apps/moldft/CMakeLists.txt b/src/apps/moldft/CMakeLists.txt index c13f89baa1a..a42343eb984 100644 --- a/src/apps/moldft/CMakeLists.txt +++ b/src/apps/moldft/CMakeLists.txt @@ -13,6 +13,7 @@ add_mad_executable(testperiodicdft testperiodicdft.cc MADchem) if(BUILD_TESTING) add_scripted_tests(test_energy.py moldft "short;applications") + add_scripted_tests(test_energy_mpi_parallel.py moldft "short;applications") endif() diff --git a/src/apps/moldft/mad_moldft_test_energy_mpi_parallel.py.calc_info.ref.json b/src/apps/moldft/mad_moldft_test_energy_mpi_parallel.py.calc_info.ref.json new file mode 100644 index 00000000000..d1e6e1f8147 --- /dev/null +++ b/src/apps/moldft/mad_moldft_test_energy_mpi_parallel.py.calc_info.ref.json @@ -0,0 +1,101 @@ +{ + "calcinfo_nalpha": 1, + "calcinfo_natom": 1, + "calcinfo_nbeta": 1, + "calcinfo_nmo": 2, + "k": 8, + "parameters": { + "charge": 0.0, + "conv_only_dens": false, + "dconv": 0.001, + "derivatives": false, + "dipole": false, + "econv": 0.0001, + "ginitial_hessian": false, + "gmaxiter": 20, + "gopt": false, + "gprec": 0.0001, + "gtest": false, + "gtol": 0.0001, + "gval": 1e-05, + "k": -1, + "l": 50.0, + "lo": 0.013396, + "loadbalparts": 2, + "maxiter": 1, + "maxrotn": 0.25, + "maxsub": 10, + "nalpha": 1, + "nbeta": 1, + "nio": 1, + "nmo_alpha": 1, + "nmo_beta": 1, + "no_compute": false, + "nopen": 0, + "npt_plot": 101, + "nv_factor": 1, + "nvalpha": 0, + "nvbeta": 0, + "orbitalshift": 0.0, + "plotcoul": false, + "plotdens": false, + "plothi": -1, + "plotlo": 0, + "print_level": 3, + "psp_calc": false, + "pure_ae": true, + "restart": false, + "restartao": false, + "save": true, + "smear": 0.0, + "spin_restricted": true, + "vnucextra": 2 + }, + "return_energy": -2.861353410011521, + "scf_e_data": { + "e_coulomb": [ + 2.018645448166965, + 2.04048235799564 + ], + "e_kinetic": [ + 2.7628170728201096, + 2.8227846011865667 + ], + "e_local": [ + 0.0, + 0.0 + ], + "e_nrep": [ + 0.0, + 0.0 + ], + "e_nuclear": [ + -6.626451864301439, + -6.704379191630678 + ], + "e_pcm": [ + 0.0, + 0.0 + ], + "e_tot": [ + -2.8543126357346864, + -2.861353410011521 + ], + "e_xc": [ + -1.0093232924203221, + -1.0202411775630498 + ], + "iterations": 2 + }, + "scf_eigenvalues_a": { + "dims": [ + 1 + ], + "size": 1, + "vals": [ + -0.5563790539362039 + ] + }, + "time": "2023-01-13 23:48:06", + "wall_time": 1.9541189670562744 +} \ No newline at end of file diff --git a/src/apps/moldft/test_energy_mpi_parallel.py b/src/apps/moldft/test_energy_mpi_parallel.py new file mode 100755 index 00000000000..4dce126f2a0 --- /dev/null +++ b/src/apps/moldft/test_energy_mpi_parallel.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +import sys +import subprocess +sys.path.append("@CMAKE_SOURCE_DIR@/bin") +from madjsoncompare import madjsoncompare + +if __name__ == "__main__": + + # some user output + print("Testing @BINARY@/@TESTCASE@") + print(" reference files found in directory: @SRCDIR@") + + prefix='mad_@BINARY@_@TESTCASE@' + outputfile=prefix+'.calc_info.json' + referencefile="@SRCDIR@/"+prefix+".calc_info.ref.json" + + # run test + global_arguments=' --geometry=he' + dft_arguments=' --dft="maxiter=1; econv=1.e-4; dconv=1.e-3; prefix='+prefix+'"' + other_arguments='' + cmd='rm '+outputfile+'; MAD_NUM_THREADS=1 mpirun -np 2 ./@BINARY@ '+global_arguments + dft_arguments + other_arguments + print("executing \n ",cmd) +# p=subprocess.run(cmd,shell=True,capture_output=True, text=True) + p=subprocess.run(cmd,shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE , universal_newlines=True) + + print("finished with run") + print(p.stdout) + exitcode=p.returncode + print("exitcode ",exitcode) + + # compare results + cmp=madjsoncompare(outputfile,referencefile) + cmp.compare(["return_energy"],1.e-4) + print("final success: ",cmp.success) + + sys.exit(p.returncode + exitcode) \ No newline at end of file