Skip to content

Commit

Permalink
Added unit tests.
Browse files Browse the repository at this point in the history
Reached 100% coverage for unit tests.
When using no cover, usually a small explanation of why it is disabled
for coverage is provided.
For testing the testing framework (in particular, the run_itest
function), nothing is tested on dryrun or generation capabilities.
  • Loading branch information
davidwaroquiers committed Mar 14, 2024
1 parent 6c7208d commit 4e1e9bf
Show file tree
Hide file tree
Showing 60 changed files with 3,427 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/turbomoleio/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,10 +924,10 @@ def run_itest(
)
)

if out_parser:
if out_parser: # pragma: no branch
# for jobex the outputs are not in the stdout but in
# the job.last file.
if executable == "jobex":
if executable == "jobex": # pragma: no cover
out = out_parser.from_file("job.last").as_dict()
else:
out = out_parser.from_string(program_std_out).as_dict()
Expand Down Expand Up @@ -963,7 +963,7 @@ def run_itest(
/ "energy"
/ "{}_{}.json".format(control_reference_filename, executable)
)
if opt_generate_ref:
if opt_generate_ref: # pragma: no cover
dumpfn(e, e_ref_path)
e_ref = loadfn(e_ref_path)
if opt_dryrun: # pragma: no cover
Expand Down
62 changes: 62 additions & 0 deletions tests/test_data/integration/control/testing_dscf_h2o_std
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
$title
dscf
$symmetry c1
$user-defined bonds file=coord
$coord file=coord
$optimize
internal off
redundant off
cartesian on
global off
basis off
$atoms
o 1 \
basis =o def-SV(P)
h 2-3 \
basis =h def-SV(P)
$basis file=basis
$scfmo file=mos
$closed shells
a 1-5 ( 2 )
$scfiterlimit 200
$thize 0.10000000E-04
$thime 5
$scfdamp start=0.300 step=0.050 min=0.100
$scfdump
$scfintunit
unit=30 size=0 file=twoint
$scfdiis
$maxcor 500 MiB per_core
$scforbitalshift automatic=.1
$drvopt
cartesian on
basis off
global off
hessian on
dipole on
nuclear polarizability
$interconversion off
qconv=1.d-7
maxiter=25
$coordinateupdate
dqmax=0.3
interpolate on
statistics 5
$forceupdate
ahlrichs numgeo=0 mingeo=3 maxgeo=4 modus=<g|dq> dynamic fail=0.3
threig=0.005 reseig=0.005 thrbig=3.0 scale=1.00 damping=0.0
$forceinit on
diag=default
$energy file=energy
$grad file=gradient
$forceapprox file=forceapprox
$dft
functional b-p
gridsize m3
$scfconv 7
$rundimensions
natoms=3
nbf(CAO)=19
nbf(AO)=18
$last step define
$end
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
$title
ridft_escf
$symmetry c2v
$redundant file=coord
$user-defined bonds file=coord
$coord file=coord
$intdef file=coord
$optimize
internal on
redundant on
cartesian off
global off
basis off
$atoms
o 1 \
basis =o def-SV(P) \
jbas =o def-SV(P)
h 2-3 \
basis =h def-SV(P) \
jbas =h def-SV(P)
$basis file=basis
$scfmo file=mos
$closed shells
a1 1-3 ( 2 )
b1 1 ( 2 )
b2 1 ( 2 )
$scfiterlimit 200
$thize 0.10000000E-04
$thime 5
$scfdamp start=0.300 step=0.050 min=0.100
$scfdump
$scfintunit
unit=30 size=0 file=twoint
$scfdiis
$scforbitalshift automatic=.1
$drvopt
cartesian on
basis off
global off
hessian on
dipole on
nuclear polarizability
$interconversion off
qconv=1.d-7
maxiter=25
$coordinateupdate
dqmax=0.3
interpolate on
statistics 5
$forceupdate
ahlrichs numgeo=0 mingeo=3 maxgeo=4 modus=<g|dq> dynamic fail=0.3
threig=0.005 reseig=0.005 thrbig=3.0 scale=1.00 damping=0.0
$forceinit on
diag=default
$energy file=energy
$grad file=gradient
$forceapprox file=forceapprox
$scfinstab rpas
$soes
a1 1
$denconv 1d-7
$dft
functional b-p
gridsize m3
$scfconv 7
$ricore 500
$rij
$jbas file=auxbasis
$rundimensions
natoms=3
nbf(CAO)=19
nbf(AO)=18
$last step define
$end
76 changes: 76 additions & 0 deletions tests/test_data/integration/control/testing_ridft_escf_h2o_std
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
$title
ridft_escf
$symmetry c2v
$user-defined bonds file=coord
$coord file=coord
$intdef file=coord
$optimize
internal on
redundant off
cartesian off
global off
basis off
$atoms
o 1 \
basis =o def-SV(P) \
jbas =o def-SV(P)
h 2-3 \
basis =h def-SV(P) \
jbas =h def-SV(P)
$basis file=basis
$scfmo file=mos
$closed shells
a1 1-3 ( 2 )
b1 1 ( 2 )
b2 1 ( 2 )
$scfiterlimit 200
$thize 0.10000000E-04
$thime 5
$scfdamp start=0.300 step=0.050 min=0.100
$scfdump
$scfintunit
unit=30 size=0 file=twoint
$scfdiis
$scforbitalshift automatic=.1
$drvopt
cartesian on
basis off
global off
hessian on
dipole on
nuclear polarizability
$interconversion off
qconv=1.d-7
maxiter=25
$coordinateupdate
dqmax=0.3
interpolate on
statistics 5
$forceupdate
ahlrichs numgeo=0 mingeo=3 maxgeo=4 modus=<g|dq> dynamic fail=0.3
threig=0.005 reseig=0.005 thrbig=3.0 scale=1.00 damping=0.0
$forceinit on
diag=default
$energy file=energy
$grad file=gradient
$forceapprox file=forceapprox
$scfinstab rpas
$soes
a1 12
a2 9
b1 12
b2 12
$denconv 1d-7
$dft
functional b-p
gridsize m3
$scfconv 7
$ricore 500
$rij
$jbas file=auxbasis
$rundimensions
natoms=3
nbf(CAO)=19
nbf(AO)=18
$last step define
$end
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.4.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.3427621525]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.98646113665]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.32922328915]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.5.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.34300618267]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.9869558]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.329962]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.5.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.34300618267]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.98695583759]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.32996202025]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.5.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.34300618267]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.9869558]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.329962]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.4.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.34300618267]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.98695583759]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.32996202025]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Energy", "@version": "1.4.0", "scf": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-76.34300618267]}, "scfkin": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [75.98695583759]}, "scfpot": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-152.32996202025]}, "mp2": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Gradient", "@version": "1.5.0", "gradients": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [[[0.0, 0.0, 0.023859200081468], [-0.11070393517652, 0.0, -0.011921608506109], [0.11070393517652, 0.0, -0.011921608506109]]]}, "energies": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-75.9867015467]}, "molecules": [{"@module": "turbomoleio.core.molecule", "@class": "MoleculeSystem", "molecule": {"@module": "pymatgen.core.structure", "@class": "Molecule", "charge": 0.0, "spin_multiplicity": 1, "sites": [{"name": "O", "species": [{"element": "O", "occu": 1}], "xyz": [0.0, 0.0, -0.3839598313210911], "properties": {}, "label": "O"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [0.7499151281524303, 0.0, 0.1919799156605482], "properties": {}, "label": "H"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [-0.7499151281524303, 0.0, 0.1919799156605482], "properties": {}, "label": "H"}], "properties": {}}, "int_def": [], "frozen_indices": [], "user_defined_bonds": []}], "periodicity": 0, "lattice_vectors": null, "lattice_gradients": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.core.control", "@class": "Gradient", "@version": "1.5.0", "gradients": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [[[0.0, 0.0, 0.023859200081468], [-0.11070393517652, 0.0, -0.011921608506109], [0.11070393517652, 0.0, -0.011921608506109]]]}, "energies": {"@module": "numpy", "@class": "array", "dtype": "float64", "data": [-75.9867015467]}, "molecules": [{"@module": "turbomoleio.core.molecule", "@class": "MoleculeSystem", "molecule": {"@module": "pymatgen.core.structure", "@class": "Molecule", "charge": 0.0, "spin_multiplicity": 1, "sites": [{"name": "O", "species": [{"element": "O", "occu": 1}], "xyz": [0.0, 0.0, -0.3839598313210911], "properties": {}, "label": "O"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [0.7499151281524303, 0.0, 0.1919799156605482], "properties": {}, "label": "H"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [-0.7499151281524303, 0.0, 0.1919799156605482], "properties": {}, "label": "H"}], "properties": {}}, "int_def": [], "frozen_indices": [], "user_defined_bonds": []}], "periodicity": 0, "lattice_vectors": null, "lattice_gradients": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.output.files", "@class": "ScfOutput", "@version": "1.4.0", "dft": {"@module": "turbomoleio.output.data", "@class": "DFTData", "@version": "1.4.0", "functional": {"@module": "turbomoleio.output.data", "@class": "FunctionalData", "@version": "1.4.0", "msg": "B-P86 functional\n exchange: LDA + Becke (B88)\n correlation: LDA (VWN) + Perdew (P86)", "name": "b-p", "func_type": "GGA", "xcfun": null}, "ri": null, "spherical_gridsize": 3, "gridpoints": 302, "dispersion_correction": null}, "scf": {"@module": "turbomoleio.output.data", "@class": "ScfData", "@version": "1.4.0", "iterations": {"@module": "turbomoleio.output.data", "@class": "ScfIterationData", "@version": "1.4.0", "energies": [-76.1438086669, -76.317603169263, -76.33740429508, -76.342251381088, -76.34247669495, -76.342484142411, -76.342484303361, -76.342762152502], "first_index": 1, "n_steps": 8, "dampings": [0.3, 0.25, 0.2, 0.25, 0.3, 0.15, 0.1, 0.15], "converged": true}, "diis": true, "diis_error_vect": "FDS-SDF", "conv_tot_en": 1e-07, "conv_one_e_en": 0.0001, "virtual_orbital_shift_on": true, "virtual_orbital_shift_limit": 0.1, "orbital_characterization": "expanded", "restart_file": "mos", "n_occupied_orbitals": 5}, "energies": {"@module": "turbomoleio.output.data", "@class": "ScfEnergiesData", "@version": "1.4.0", "total_energy": -76.3427621525, "kinetic_energy": 75.98646113665, "potential_energy": -152.32922328915, "virial_theorem": 1.99533287759, "wavefunction_norm": 1.0, "coulomb_energy": null, "xc_energy": null, "ts_energy": null, "free_energy": null, "sigma0_energy": null}, "electrostatic": {"@module": "turbomoleio.output.data", "@class": "ElectrostaticMomentsData", "@version": "1.4.0", "charge": -0.0, "unrestricted_electrons": null, "dipole_vector": [-0.0, 0.0, 0.833584], "dipole_norm": 0.8336, "quadrupole_tensor": [[-3.238827, -0.0, -0.0], [-0.0, -5.264554, 0.0], [-0.0, 0.0, -4.333449]], "quadrupole_trace": -12.836829, "quadrupole_anisotropy": 1.756235}, "geometry": {"@module": "turbomoleio.output.data", "@class": "GeometryData", "@version": "1.4.0", "center_of_mass": [0.0, 0.0, -0.0], "center_of_charge": [0.0, 0.0, 0.09588384], "molecule": {"@module": "pymatgen.core.structure", "@class": "Molecule", "charge": 0.0, "spin_multiplicity": 1, "sites": [{"name": "O", "species": [{"element": "O", "occu": 1}], "xyz": [0.0, 0.0, -0.06444840784752262], "properties": {}, "label": "O"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [0.7499151287230262, 0.0, 0.5114913412076659], "properties": {}, "label": "H"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [-0.7499151287230262, 0.0, 0.5114913412076659], "properties": {}, "label": "H"}]}}, "basis": {"@module": "turbomoleio.output.data", "@class": "BasisData", "@version": "1.4.0", "basis_per_specie": {"o": "def-SV(P)", "h": "def-SV(P)"}, "aux_basis_per_specie": {}, "number_scf_basis_func": 18, "number_scf_aux_basis_func": null}, "run": {"@module": "turbomoleio.output.data", "@class": "RunData", "@version": "1.4.0", "host": "fedora", "start_time": {"@module": "datetime", "@class": "datetime", "string": "2024-02-22 17:03:40.954000"}, "end_time": {"@module": "datetime", "@class": "datetime", "string": "2024-02-22 17:03:41.028000"}, "cpu_time": 0.08, "wall_time": 0.08}, "tm": {"@module": "turbomoleio.output.data", "@class": "TurbomoleData", "@version": "1.4.0", "version": "7.7.1", "build": null, "executable": "dscf"}, "cosmo": null, "spin": {"@module": "turbomoleio.output.data", "@class": "SpinData", "@version": "1.4.0", "unrestricted": false, "s2": null}, "integral": {"@module": "turbomoleio.output.data", "@class": "IntegralData", "@version": "1.4.0", "integral_neglect_threshold": 1.8e-10, "thize": 1e-05, "thime": 5}, "smearing": null, "symmetry": {"@module": "turbomoleio.output.data", "@class": "SymmetryData", "@version": "1.4.0", "symbol": "c1", "n_reps": 1, "reps": ["a"]}, "periodicity": null}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"@module": "turbomoleio.output.files", "@class": "EgradOutput", "@version": "1.5.0", "gradients": [[0.0, 0.0, 0.0238592], [-0.1107039, 0.0, -0.01192161], [0.1107039, 0.0, -0.01192161]], "dielectric": [[-0.313765, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, -0.025962]], "dft": {"@module": "turbomoleio.output.data", "@class": "DFTData", "@version": "1.5.0", "functional": {"@module": "turbomoleio.output.data", "@class": "FunctionalData", "@version": "1.5.0", "msg": "B-P86 functional\n exchange: LDA + Becke (B88)\n correlation: LDA (VWN) + Perdew (P86)", "name": "b-p", "func_type": "GGA", "xcfun": null}, "ri": {"@module": "turbomoleio.output.data", "@class": "RiData", "@version": "1.5.0", "ricore": 500, "marij": false, "rij_memory": 1, "rik": false}, "spherical_gridsize": 3, "gridpoints": 302, "dispersion_correction": null}, "escf": {"@module": "turbomoleio.output.data", "@class": "EscfData", "@version": "1.5.0", "calc_type": "RPA SINGLET-EXCITATION", "iterations": {"@module": "turbomoleio.output.data", "@class": "EscfIterationData", "@version": "1.5.0", "steps": [[["a1", 0, 0.1171207678382341]], [["a1", 0, 0.02842384421661671]], [["a1", 0, 0.002048234724753847]], [["a1", 0, 0.0003443920881340498]], [["a1", 0, 2.432028598166631e-05]], [["a1", 1, 4.927959260747763e-07]]], "converged": true}, "residuum_convergence_criterium": 1e-05, "n_occupied_orbitals": 5, "orbital_characterization": "scfconv=7", "max_davidson_iter": 35, "machine_precision": 2.22e-16, "max_core_mem": 500.0, "max_cao_basis_vectors": 151353, "max_treated_vectors": 2, "irrep_data": {"a1": {"tensor_space_dim": 24, "n_roots": 1}}, "gs_tot_en": -76.34300618267, "excitations": {"a1": [{"@module": "turbomoleio.output.data", "@class": "SingleExcitation", "@version": "1.5.0", "tot_en": -75.98670154669637, "osc_stre": 0.07848247395696697, "rot_stre": 0.0, "dominant_contributions": [{"occ_orb": {"index": 3, "irrep": "a1", "energy": -8.44, "spin": null}, "virt_orb": {"index": 4, "irrep": "a1", "energy": 0.92, "spin": null}, "coeff": 99.2}], "moments_columns": [{"electric_dipole": [0.0, 0.0, 0.574806], "magnetic_dipole": [0.0, 0.0, 0.0], "electric_quadrupole": {"trace": 0.436188, "anisotropy": 0.673134, "moment": [[0.558475, 0.0, 0.0], [0.0, 0.090715, 0.0], [0.0, 0.0, -0.213002]]}}]}]}}, "geometry": {"@module": "turbomoleio.output.data", "@class": "GeometryData", "@version": "1.5.0", "center_of_mass": [0.0, 0.0, -0.60378908], "center_of_charge": [0.0, 0.0, -0.50790525], "molecule": {"@module": "pymatgen.core.structure", "@class": "Molecule", "charge": 0.0, "spin_multiplicity": 1, "sites": [{"name": "O", "species": [{"element": "O", "occu": 1}], "xyz": [0.0, 0.0, -0.38395982917561094], "properties": {}, "label": "O"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [0.7499151287230262, 0.0, 0.19197991458780547], "properties": {}, "label": "H"}, {"name": "H", "species": [{"element": "H", "occu": 1}], "xyz": [-0.7499151287230262, 0.0, 0.19197991458780547], "properties": {}, "label": "H"}], "properties": {}}}, "basis": {"@module": "turbomoleio.output.data", "@class": "BasisData", "@version": "1.5.0", "basis_per_specie": {"o": "def-SV(P)", "h": "def-SV(P)"}, "aux_basis_per_specie": {}, "number_scf_basis_func": 18, "number_scf_aux_basis_func": 47}, "run": {"@module": "turbomoleio.output.data", "@class": "RunData", "@version": "1.5.0", "host": "fedora", "start_time": {"@module": "datetime", "@class": "datetime", "string": "2024-03-14 00:11:12.384000"}, "end_time": {"@module": "datetime", "@class": "datetime", "string": "2024-03-14 00:11:12.473000"}, "cpu_time": 0.1, "wall_time": 0.1}, "tm": {"@module": "turbomoleio.output.data", "@class": "TurbomoleData", "@version": "1.5.0", "version": "7.7.1", "build": null, "executable": "egrad"}, "cosmo": null, "integral": {"@module": "turbomoleio.output.data", "@class": "IntegralData", "@version": "1.5.0", "integral_neglect_threshold": 3.3e-11, "thize": 1e-05, "thime": 5}, "ex_state": 1}
Loading

0 comments on commit 4e1e9bf

Please sign in to comment.