forked from oimeitei/quemb
-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
145 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
This script tests the correlation energies of sample restricted molecular BE calculations from density matching | ||
Author(s): Minsik Cho | ||
""" | ||
|
||
import os, unittest | ||
from pyscf import cc, gto, scf | ||
from molbe import fragpart, BE | ||
|
||
class TestBE_restricted(unittest.TestCase): | ||
# TODO: Add test against known values (molecular_restrict_test) | ||
def test_h8_sto3g_ben_trustRegion(self): | ||
# Test consistency between two QN methods | ||
mol = gto.M() | ||
mol.atom = [['H', (0.,0.,i)] for i in range(7)]; mol.atom.append(['H', (0.,0.,4.2)]) | ||
mol.basis = 'sto-3g' | ||
mol.charge = 0.; mol.spin = 0. | ||
mol.build() | ||
self.molecular_QN_test(mol, 'be2', 'H8 (BE2)', 'hchain_simple', only_chem = False) | ||
|
||
def molecular_QN_test(self, mol, be_type, test_name, frag_type, delta = 1e-6, only_chem = True): | ||
mf = scf.RHF(mol); mf.max_cycle = 100; mf.kernel() | ||
fobj = fragpart(frag_type=frag_type, be_type=be_type, mol = mol) | ||
mybe1 = BE(mf, fobj) | ||
mybe1.optimize(solver='CCSD', method='QN', trust_region=False, only_chem=only_chem) | ||
mybe2 = BE(mf, fobj) | ||
mybe2.optimize(solver='CCSD', method='QN', trust_region=True, only_chem=only_chem) | ||
self.assertAlmostEqual(mybe1.ebe_tot, mybe2.ebe_tot, | ||
msg = "BE Correlation Energy (DM) for " + test_name | ||
+ " does not return comparable results from two QN optimization!", delta = delta) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |