-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
337 additions
and
82 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
__all__ = [ | ||
"DerivOnceSCF", "DerivOnceNCDFT", # deriv_once_scf | ||
"GradSCF", "GradNCDFT", # grad_scf | ||
"DerivOnceMP2", "DerivOnceXDH", # deriv_once_mp2 | ||
"GradSCF", "GradNCDFT", # grad_scf | ||
"GradMP2", "GradXDH", # grad_mp2 | ||
"DipoleSCF", "DipoleNCDFT", # dipole_scf | ||
"DipoleMP2", "DipoleXDH", # dipole_mp2 | ||
"DerivOnceUSCF", # deriv_once_uscf | ||
|
||
"DerivOnceUSCF", "DerivOnceUNCDFT", # deriv_once_uscf | ||
"GradUSCF", "GradUNCDFT", # grad_uscf | ||
] | ||
|
||
from pyxdh.DerivOnce.deriv_once_scf import DerivOnceSCF, DerivOnceNCDFT | ||
from pyxdh.DerivOnce.grad_scf import GradSCF, GradNCDFT | ||
from pyxdh.DerivOnce.deriv_once_mp2 import DerivOnceMP2, DerivOnceXDH | ||
from pyxdh.DerivOnce.grad_scf import GradSCF, GradNCDFT | ||
from pyxdh.DerivOnce.grad_mp2 import GradMP2, GradXDH | ||
from pyxdh.DerivOnce.dipole_scf import DipoleSCF, DipoleNCDFT | ||
from pyxdh.DerivOnce.dipole_mp2 import DipoleMP2, DipoleXDH | ||
from pyxdh.DerivOnce.deriv_once_uscf import DerivOnceUSCF | ||
|
||
from pyxdh.DerivOnce.deriv_once_uscf import DerivOnceUSCF, DerivOnceUNCDFT | ||
from pyxdh.DerivOnce.grad_uscf import GradUSCF, GradUNCDFT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
54 changes: 54 additions & 0 deletions
54
pyxdh/Validation/numerical_deriv/ncdft_derivonce_uhf_ub3lyp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import pickle | ||
from pyscf import scf | ||
import numpy as np | ||
|
||
from pyxdh.Utilities.test_molecules import Mol_CH3 | ||
from pyxdh.Utilities import NumericDiff, NucCoordDerivGenerator, DipoleDerivGenerator | ||
from pyxdh.DerivOnce import GradUNCDFT | ||
|
||
|
||
def mol_to_grad_helper(mol): | ||
CH3 = Mol_CH3(mol=mol) | ||
CH3.hf_eng.kernel() | ||
config = { | ||
"scf_eng": CH3.hf_eng, | ||
"nc_eng": CH3.gga_eng | ||
} | ||
helper = GradUNCDFT(config) | ||
return helper | ||
|
||
|
||
def dipole_generator(component, interval): | ||
CH3 = Mol_CH3() | ||
mol = CH3.mol | ||
|
||
def get_hcore(mol=mol): | ||
return scf.rhf.get_hcore(mol) - interval * mol.intor("int1e_r")[component] | ||
|
||
CH3.hf_eng.get_hcore = get_hcore | ||
CH3.gga_eng.get_hcore = get_hcore | ||
|
||
config = { | ||
"scf_eng": CH3.hf_eng, | ||
"nc_eng": CH3.gga_eng | ||
} | ||
helper = GradUNCDFT(config) | ||
return helper | ||
|
||
|
||
if __name__ == '__main__': | ||
result_dict = {} | ||
CH3 = Mol_CH3() | ||
mol = CH3.mol | ||
|
||
num_obj = NucCoordDerivGenerator(CH3.mol, mol_to_grad_helper) | ||
num_dif = NumericDiff(num_obj, lambda helper: helper.eng) | ||
result_dict["grad"] = num_dif.derivative | ||
|
||
num_obj = DipoleDerivGenerator(dipole_generator) | ||
num_dif = NumericDiff(num_obj, lambda helper: helper.eng) | ||
dip_nuc = np.einsum("A, At -> t", mol.atom_charges(), mol.atom_coords()) | ||
result_dict["dipole"] = num_dif.derivative + dip_nuc | ||
|
||
with open("ncdft_derivonce_uhf_ub3lyp.dat", "wb") as f: | ||
pickle.dump(result_dict, f, pickle.HIGHEST_PROTOCOL) |