Commit 1d77c55e authored by Lauri Himanen's avatar Lauri Himanen
Browse files

Added support for the LibXC functional codes, now parsing energies and references.

parent d6b58204
LIB_XC_MAPPING = {
"001": "LDA_X",
"002": "LDA_C_WIGNER",
"003": "LDA_C_RPA",
"004": "LDA_C_HL",
"005": "LDA_C_GL",
"006": "LDA_C_XALPHA",
"007": "LDA_C_VWN",
"008": "LDA_C_VWN_RPA",
"009": "LDA_C_PZ",
"010": "LDA_C_PZ_MOD",
"011": "LDA_C_OB_PZ",
"012": "LDA_C_PW",
"013": "LDA_C_PW_MOD",
"014": "LDA_C_OB_PW",
"015": "LDA_C_2D_AMGB",
"016": "LDA_C_2D_PRM",
"017": "LDA_C_vBH",
"018": "LDA_C_1D_CSC",
"019": "LDA_X_2D",
"020": "LDA_XC_TETER93",
"021": "LDA_X_1D",
"101": "GGA_X_PBE",
"102": "GGA_X_PBE_R",
"103": "GGA_X_B86",
"104": "GGA_X_B86_R",
"105": "GGA_X_B86_MGC",
"106": "GGA_X_B88",
"107": "GGA_X_G96",
"108": "GGA_X_PW86",
"109": "GGA_X_PW91",
"110": "GGA_X_OPTX",
"111": "GGA_X_DK87_R1",
"112": "GGA_X_DK87_R2",
"113": "GGA_X_LG93",
"114": "GGA_X_FT97_A",
"115": "GGA_X_FT97_B",
"116": "GGA_X_PBE_SOL",
"117": "GGA_X_RPBE",
"118": "GGA_X_WC",
"119": "GGA_X_mPW91",
"120": "GGA_X_AM05",
"121": "GGA_X_PBEA",
"122": "GGA_X_MPBE",
"123": "GGA_X_XPBE",
"124": "GGA_X_2D_B86_MGC",
"125": "GGA_X_BAYESIAN",
"126": "GGA_X_PBE_JSJR",
"127": "GGA_X_2D_B88",
"128": "GGA_X_2D_B86",
"129": "GGA_X_2D_PBE",
"130": "GGA_C_PBE",
"131": "GGA_C_LYP",
"132": "GGA_C_P86",
"133": "GGA_C_PBE_SOL",
"134": "GGA_C_PW91",
"135": "GGA_C_AM05",
"136": "GGA_C_XPBE",
"137": "GGA_C_LM",
"138": "GGA_C_PBE_JRGX",
"139": "GGA_X_OPTB88_VDW",
"140": "GGA_X_PBEK1_VDW",
"141": "GGA_X_OPTPBE_VDW",
"160": "GGA_XC_LB",
"161": "GGA_XC_HCTH_93",
"162": "GGA_XC_HCTH_120",
"163": "GGA_XC_HCTH_147",
"164": "GGA_XC_HCTH_407",
"165": "GGA_XC_EDF1",
"166": "GGA_XC_XLYP",
"167": "GGA_XC_B97",
"168": "GGA_XC_B97_1",
"169": "GGA_XC_B97_2",
"170": "GGA_XC_B97_D",
"171": "GGA_XC_B97_K",
"172": "GGA_XC_B97_3",
"173": "GGA_XC_PBE1W",
"174": "GGA_XC_MPWLYP1W",
"175": "GGA_XC_PBELYP1W",
"176": "GGA_XC_SB98_1a",
"177": "GGA_XC_SB98_1b",
"178": "GGA_XC_SB98_1c",
"179": "GGA_XC_SB98_2a",
"180": "GGA_XC_SB98_2b",
"181": "GGA_XC_SB98_2c",
"401": "HYB_GGA_XC_B3PW91",
"402": "HYB_GGA_XC_B3LYP",
"403": "HYB_GGA_XC_B3P86",
"404": "HYB_GGA_XC_O3LYP",
"405": "HYB_GGA_XC_mPW1K",
"406": "HYB_GGA_XC_PBEH",
"407": "HYB_GGA_XC_B97",
"408": "HYB_GGA_XC_B97_1",
"410": "HYB_GGA_XC_B97_2",
"411": "HYB_GGA_XC_X3LYP",
"412": "HYB_GGA_XC_B1WC",
"413": "HYB_GGA_XC_B97_K",
"414": "HYB_GGA_XC_B97_3",
"415": "HYB_GGA_XC_mPW3PW",
"416": "HYB_GGA_XC_B1LYP",
"417": "HYB_GGA_XC_B1PW91",
"418": "HYB_GGA_XC_mPW1PW",
"419": "HYB_GGA_XC_mPW3LYP",
"420": "HYB_GGA_XC_SB98_1a",
"421": "HYB_GGA_XC_SB98_1b",
"422": "HYB_GGA_XC_SB98_1c",
"423": "HYB_GGA_XC_SB98_2a",
"424": "HYB_GGA_XC_SB98_2b",
"425": "HYB_GGA_XC_SB98_2c",
"201": "MGGA_X_LTA",
"202": "MGGA_X_TPSS",
"203": "MGGA_X_M06L",
"204": "MGGA_X_GVT4",
"205": "MGGA_X_TAU_HCTH",
"206": "MGGA_X_BR89",
"207": "MGGA_X_BJ06",
"208": "MGGA_X_TB09",
"209": "MGGA_X_RPP09",
"231": "MGGA_C_TPSS",
"232": "MGGA_C_VSXC",
"301": "LCA_OMC",
"302": "LCA_LCH",
}
......@@ -101,6 +101,16 @@ class TestSinglePoint(unittest.TestCase):
), "angstrom")
self.assertTrue(np.array_equal(atom_position, expected_position))
def test_atom_forces(self):
result = self.results["atom_forces"]
expected_result = convert_unit(np.array(
[
[-1.694065894509E-21, -3.388131789017E-21, 5.670554140677E-02],
[1.694065894509E-21, 3.388131789017E-21, -5.670554140677E-02],
]
), "hartree/bohr")
self.assertTrue(np.array_equal(result, expected_result))
def test_number_of_atoms(self):
n_atoms = self.results["number_of_atoms"]
self.assertEqual(n_atoms, 2)
......@@ -117,63 +127,45 @@ class TestSinglePoint(unittest.TestCase):
result = self.results["number_of_spin_channels"]
self.assertEqual(result, 1)
# def test_energy_total(self):
# result = self.results["energy_total"]
# expected_result = convert_unit(np.array(-76.436222730188), "hartree")
# self.assertTrue(np.array_equal(result, expected_result))
# def test_energy_x(self):
# result = self.results["energy_X"]
# expected_result = convert_unit(np.array(-9.025345841743), "hartree")
# self.assertTrue(np.array_equal(result, expected_result))
# def test_energy_c(self):
# result = self.results["energy_C"]
# expected_result = convert_unit(np.array(-0.328011552453), "hartree")
# self.assertTrue(np.array_equal(result, expected_result))
# def test_energy_total_scf_iteration(self):
# result = self.results["energy_total_scf_iteration"]
# # Test the first and last energies
# expected_result = convert_unit(np.array(
# [
# [-76.3916403957],
# [-76.4362227302],
# ]), "hartree")
# self.assertTrue(np.array_equal(np.array([[result[0]], [result[-1]]]), expected_result))
# def test_energy_change_scf_iteration(self):
# result = self.results["energy_change_scf_iteration"]
# expected_result = convert_unit(np.array(
# [
# [-8.55E+01],
# [-3.82E-07],
# ]), "hartree")
# self.assertTrue(np.array_equal(np.array([[result[0]], [result[-1]]]), expected_result))
def test_energy_total(self):
result = self.results["energy_total"]
expected_result = convert_unit(np.array(-1.98834837256869790E+01), "hartree")
self.assertTrue(np.array_equal(result, expected_result))
def test_energy_total_scf_iteration(self):
result = self.results["energy_total_scf_iteration"]
# Test the first and last energies
expected_result = convert_unit(np.array(
[
[-1.96096887307935432E+01],
[-1.98834837256869790E+01],
]), "hartree")
self.assertTrue(np.array_equal(np.array([[result[0]], [result[-1]]]), expected_result))
def test_energy_change_scf_iteration(self):
result = self.results["energy_change_scf_iteration"]
expected_result = convert_unit(np.array(
[
[-1.58E-03],
[-1.78E-09],
]), "hartree")
self.assertTrue(np.array_equal(np.array([[result[0]], [result[-1]]]), expected_result))
def test_scf_max_iteration(self):
result = self.results["scf_max_iteration"]
self.assertEqual(result, 50)
def test_scf_threshold_energy_change(self):
result = self.results["scf_threshold_energy_change"]
self.assertEqual(result, convert_unit(1.0E-04, "hartree"))
# def test_scf_dft_number_of_iterations(self):
# result = self.results["number_of_scf_iterations"]
# self.assertEqual(result, 6)
def test_scf_dft_number_of_iterations(self):
result = self.results["number_of_scf_iterations"]
self.assertEqual(result, 11)
# def test_spin_target_multiplicity(self):
# multiplicity = self.results["spin_target_multiplicity"]
# self.assertEqual(multiplicity, 1)
def test_single_configuration_to_calculation_method_ref(self):
result = self.results["single_configuration_to_calculation_method_ref"]
self.assertEqual(result, 0)
# def test_single_configuration_to_calculation_method_ref(self):
# result = self.results["single_configuration_to_calculation_method_ref"]
# self.assertEqual(result, 0)
# def test_single_configuration_calculation_to_system_description_ref(self):
# result = self.results["single_configuration_calculation_to_system_ref"]
# self.assertEqual(result, 0)
def test_single_configuration_calculation_to_system_description_ref(self):
result = self.results["single_configuration_calculation_to_system_ref"]
self.assertEqual(result, 0)
# def test_single_configuration_calculation_converged(self):
# result = self.results["single_configuration_calculation_converged"]
......@@ -185,10 +177,107 @@ class TestSinglePoint(unittest.TestCase):
# self.assertEqual(kind["method_atom_kind_label"][0], "H")
#===============================================================================
class TestPeriodicity(unittest.TestCase):
"""Tests that the parser can handle different boundary conditions.
"""
def test_periodic(self):
results = get_results("periodicity/periodic")
result = results["configuration_periodic_dimensions"]
self.assertTrue(np.array_equal(result, np.array([True, True, True])))
def test_surface(self):
results = get_results("periodicity/surface")
result = results["configuration_periodic_dimensions"]
self.assertTrue(np.array_equal(result, np.array([True, False, True])))
def test_free(self):
results = get_results("periodicity/free")
result = results["configuration_periodic_dimensions"]
self.assertTrue(np.array_equal(result, np.array([False, False, False])))
#===============================================================================
class TestXCFunctionals(unittest.TestCase):
"""Tests that the parser can handle different XC functional codes.
"""
def test_abinit_1(self):
results = get_results("xc_functionals/abinit_1")
result = results["XC_functional"]
self.assertEqual(result, "1.0*LDA_XC_TETER93")
def test_abinit_11(self):
results = get_results("xc_functionals/abinit_11")
result = results["XC_functional"]
self.assertEqual(result, "1.0*GGA_C_PBE_1.0*GGA_X_PBE")
def test_abinit_12(self):
results = get_results("xc_functionals/abinit_12")
result = results["XC_functional"]
self.assertEqual(result, "1.0*GGA_X_PBE")
# YAML parse error
# def test_abinit_15(self):
# results = get_results("xc_functionals/abinit_15")
# result = results["XC_functional"]
# self.assertEqual(result, "1.0*GGA_C_PBE_1.0*GGA_X_RPBE")
# Error
# def test_abinit_16(self):
# results = get_results("xc_functionals/abinit_16")
# result = results["XC_functional"]
# self.assertEqual(result, "1.0*GGA_XC_HCTH_93")
# Error
# def test_abinit_17(self):
# results = get_results("xc_functionals/abinit_17")
# result = results["XC_functional"]
# self.assertEqual(result, "1.0*GGA_XC_HCTH_120")
# Error
# def test_abinit_26(self):
# results = get_results("xc_functionals/abinit_26")
# result = results["XC_functional"]
# self.assertEqual(result, "1.0*GGA_XC_HCTH_147")
# Error
# def test_abinit_27(self):
# results = get_results("xc_functionals/abinit_27")
# result = results["XC_functional"]
# self.assertEqual(result, "1.0*GGA_XC_HCTH_407")
def test_abinit_100(self):
results = get_results("xc_functionals/abinit_100")
result = results["XC_functional"]
self.assertEqual(result, "1.0*HF_X")
def test_libxc_001(self):
results = get_results("xc_functionals/libxc_001")
result = results["XC_functional"]
self.assertEqual(result, "1.0*LDA_X")
def test_libxc_010(self):
results = get_results("xc_functionals/libxc_010")
result = results["XC_functional"]
self.assertEqual(result, "1.0*LDA_C_PZ_MOD")
def test_libxc_101(self):
results = get_results("xc_functionals/libxc_101")
result = results["XC_functional"]
self.assertEqual(result, "1.0*GGA_X_PBE")
def test_libxc_101130(self):
results = get_results("xc_functionals/libxc_101130")
result = results["XC_functional"]
self.assertEqual(result, "1.0*GGA_C_PBE_1.0*GGA_X_PBE")
#===============================================================================
if __name__ == '__main__':
suites = []
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestSinglePoint))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestPeriodicity))
suites.append(unittest.TestLoader().loadTestsFromTestCase(TestXCFunctionals))
alltests = unittest.TestSuite(suites)
unittest.TextTestRunner(verbosity=0).run(alltests)
2 angstroemd0 -1.98834837256870074E+01 (Ha) Geometry + metaData forces
free
N 0.00000000000000000E+00 0.00000000000000000E+00 0.00000000000000000E+00
N 0.00000000000000000E+00 0.00000000000000000E+00 1.11498999595642090E+00
forces
N 0.00000000000000000E+00 -1.69406589450860068E-21 5.67055414067754171E-02
N 0.00000000000000000E+00 1.69406589450860068E-21 -5.67055414067754171E-02
0.45 0.45 0.45 # hx,hy,hz: grid spacing in the three directions
5.0 8.0 # crmult, frmult: c(f)rmult*radii_cf(*,1(2)) gives the coarse (fine)radius around each atom
1 # ixc: exchange-correlation parameter (LDA=1,PBE=11)
0 0.0 0.0 0.0 # ncharge: charge of the system, Electric field
1 0 # nspin=1 non-spin polarization, mpol=total magnetic moment
1.E-04 # gnrm_cv: convergence criterion gradient
50 1 # itermax,nrepmax: maximum number of wavefunction optimizations and of re-diagonalised runs
6 6 # ncong, idsx: # CG iterations for the preconditioning equation, length of the diis history
0 # dispersion correction functional (values 1,2,3), 0=no correction
0 0 0 # InputPsiId, output_wf, output_denspot
0.0 30 # rbuf, ncongt: length of the tail (AU),# tail CG iterations
0 0 0 # davidson treatment, no. of virtual orbitals, no of plotted orbitals
F # disable the symmetry detection
#---------------------------------------------------------------------- Minimal input file
#This file indicates the minimal set of input variables which has to be given to perform
#the run. The code would produce the same output if this file is used as input.
posinp:
units: angstroem
positions:
- N: [0.0, 0.0, 0.0]
- N: [0.0, 0.0, 1.114989995956421]
properties:
format: xyz
source: posinp.xyz
psolver:
environment:
gammaS: water
alphaS: water
betaV: water
---
INIT: # % , Time (s)
Classes:
Flib LowLevel : [ 13.9, 9.38E-02]
Communications : [ 0.0, 1.81E-05]
BLAS-LAPACK : [ 0.8, 5.23E-03]
PS Computation : [ 36.3, 0.24]
Potential : [ 6.2, 4.18E-02]
Convolutions : [ 13.4, 9.06E-02]
Other : [ 0.1, 8.84E-04]
Initialization : [ 5.3, 3.55E-02]
Total : [ 76.0, 0.67]
Categories: #Ordered by time consumption
PSolver Kernel Creation:
Data : [ 20.5, 0.14]
Class : PS Computation
Info : ISF operations and creation of the kernel
PSolver Computation:
Data : [ 15.8, 0.11]
Class : PS Computation
Info : 3D SG_FFT and related operations
Init to Zero:
Data : [ 9.2, 6.22E-02]
Class : Flib LowLevel
Info : Memset of storage space
ApplyLocPotKin:
Data : [ 7.4, 4.99E-02]
Class : Convolutions
Info : OpenCL ported
Exchange-Correlation:
Data : [ 6.2, 4.18E-02]
Class : Potential
Info : Operations needed to construct local XC potential
Rho_comput:
Data : [ 6.0, 4.08E-02]
Class : Convolutions
Info : OpenCL ported
wavefunction:
Data : [ 4.4, 2.96E-02]
Class : Initialization
Info : Miscellaneous
Array allocations:
Data : [ 2.8, 1.89E-02]
Class : Flib LowLevel
Info : Heap storage allocation and associated profiling
Vector copy:
Data : [ 1.3, 8.73E-03]
Class : Flib LowLevel
Info : Memory copy of arrays (excluded allocations)
Blas (d-s-c-z)GeMM:
Data : [ 0.8, 5.23E-03]
Class : BLAS-LAPACK
Info : Blas General Matrix-Matrix multiplications of any float type
Routine Profiling:
Data : [ 0.6, 4.04E-03]
Class : Flib LowLevel
Info : Profiling performances for debugging
CrtLocPot:
Data : [ 0.4, 2.93E-03]
Class : Initialization
Info : Miscellaneous
Input_comput:
Data : [ 0.2, 1.52E-03]
Class : Initialization
Info : Miscellaneous
CrtDescriptors:
Data : [ 0.2, 1.41E-03]
Class : Initialization
Info : RMA Pattern
ApplyProj:
Data : [ 0.1, 7.33E-04]
Class : Other
Info : RMA pattern
ionic_energy:
Data : [ 0.0, 7.53E-05]
Class : Other
Info : Miscellaneous
calc_bounds:
Data : [ 0.0, 3.89E-05]
Class : Other
Info : Miscellaneous
Un-TransSwitch:
Data : [ 0.0, 2.88E-05]
Class : Other
Info : RMA pattern
Allreduce, Large Size:
Data : [ 0.0, 1.22E-05]
Class : Communications
Info : Allreduce operations for more than 5 elements
Pot_after_comm:
Data : [ 0.0, 7.63E-06]
Class : Other
Info : global_to_loca
Pot_commun:
Data : [ 0.0, 4.53E-06]
Class : Communications
Info : AllGathrv grid
Allreduce, Small Size:
Data : [ 0.0, 1.43E-06]
Class : Communications
Info : Allreduce operations for less than 5 elements
WFN_OPT: # % , Time (s)
Classes:
Flib LowLevel : [ 15.1, 0.33]
Communications : [ 0.0, 5.51E-05]
BLAS-LAPACK : [ 0.4, 9.36E-03]
PS Computation : [ 18.8, 0.41]
Potential : [ 18.0, 0.40]
Convolutions : [ 34.7, 0.77]
Linear Algebra : [ 0.4, 8.93E-03]
Other : [ 10.3, 0.23]
Total : [ 97.6, 2.2]
Categories: #Ordered by time consumption
PSolver Computation:
Data : [ 18.8, 0.41]
Class : PS Computation
Info : 3D SG_FFT and related operations
Exchange-Correlation:
Data : [ 18.0, 0.40]
Class : Potential
Info : Operations needed to construct local XC potential
ApplyLocPotKin:
Data : [ 13.5, 0.30]
Class : Convolutions
Info : OpenCL ported
Rho_comput:
Data : [ 11.7, 0.26]
Class : Convolutions
Info : OpenCL ported
Precondition:
Data : [ 9.5, 0.21]
Class : Convolutions
Info : OpenCL ported
ApplyProj:
Data : [ 9.2, 0.20]
Class : Other
Info : RMA pattern
Init to Zero:
Data : [ 8.3, 0.18]
Class : Flib LowLevel
Info : Memset of storage space
Array allocations:
Data : [ 2.8, 6.08E-02]
Class : Flib LowLevel
Info : Heap storage allocation and associated profiling
Routine Profiling:
Data : [ 2.3, 5.09E-02]
Class : Flib LowLevel
Info : Profiling performances for debugging
Vector copy:
Data : [ 1.7, 3.75E-02]
Class : Flib LowLevel
Info : Memory copy of arrays (excluded allocations)
Diis:
Data : [ 1.0, 2.29E-02]
Class : Other
Info : Other
Blas (d-s-c-z)GeMM:
Data : [ 0.4, 9.36E-03]
Class : BLAS-LAPACK
Info : Blas General Matrix-Matrix multiplications of any float type
Chol_comput:
Data : [ 0.4, 8.80E-03]
Class : Linear Algebra
Info : ALLReduce orbs
Un-TransSwitch:
Data : [ 0.0, 2.60E-04]
Class : Other
Info : RMA pattern
LagrM_comput:
Data : [ 0.0, 1.28E-04]
Class : Linear Algebra
Info : DGEMM
Pot_after_comm:
Data : [ 0.0, 9.35E-05]
Class : Other
Info : global_to_loca
Pot_commun:
Data : [ 0.0, 5.51E-05]
Class : Communications
Info : AllGathrv grid
LAST: # % , Time (s)
Classes: