Skip to content

Commit

Permalink
Merge pull request #554 from m-a-d-n-e-s-s/pr-add-mpi-test
Browse files Browse the repository at this point in the history
added test running moldft with 2 mpi processes
  • Loading branch information
fbischoff authored Oct 16, 2024
2 parents f76b84a + 0bfaef3 commit 6df817e
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/apps/moldft/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
37 changes: 37 additions & 0 deletions src/apps/moldft/test_energy_mpi_parallel.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 6df817e

Please sign in to comment.