Skip to content

Commit

Permalink
add QChem SCF convergence method pseudo-Fractional Occupation Number
Browse files Browse the repository at this point in the history
  • Loading branch information
xhqu1981 committed Nov 17, 2015
1 parent 4753cb7 commit 06355ac
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
12 changes: 12 additions & 0 deletions custodian/qchem/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ def fix_scf(self):
self.fix_step.set_scf_algorithm_and_iterations(
algorithm="gdm", iterations=self.scf_max_cycles)
self.set_scf_initial_guess("core")
elif method == "fon":
self.fix_step.set_scf_algorithm_and_iterations(
algorithm="diis", iterations=self.scf_max_cycles)
self.set_scf_initial_guess("sad")
natoms = len(od["molecules"][-1])
self.fix_step.params["rem"]["occupations"] = 2
self.fix_step.params["rem"]["fon_norb"] = int(natoms * 0.618)
self.fix_step.params["rem"]["fon_t_start"] = 300
self.fix_step.params["rem"]["fon_t_end"] = 300
self.fix_step.params["rem"]["fon_e_thresh"] = 6
self.fix_step.set_integral_threshold(14)
self.fix_step.set_scf_convergence_threshold(7)
else:
raise ValueError("fix method " + method + " is not supported")
strategy_text = "<SCF Fix Strategy>"
Expand Down
23 changes: 23 additions & 0 deletions custodian/qchem/tests/test_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,29 @@ def test_scf_rca(self):
'Molecular charge is not found'],
'actions': None})


def test_scf_fon(self):
shutil.copyfile(os.path.join(test_dir, "hf_rca_hit_5.inp"),
os.path.join(scr_dir, "hf_rca_hit_5.inp"))
shutil.copyfile(os.path.join(test_dir, "hf_rca.out"),
os.path.join(scr_dir, "hf_rca.out"))
h = QChemErrorHandler(input_file="hf_rca_hit_5.inp",
output_file="hf_rca.out")
has_error = h.check()
self.assertTrue(has_error)
d = h.correct()
self.assertEqual(d, {'errors': ['Bad SCF convergence',
'Geometry optimization failed',
'Molecular charge is not found'],
'actions': ['fon']})
with open(os.path.join(test_dir, "hf_rca_hit_5_fon.inp")) as f:
ref = [line.strip() for line in f.readlines()]
with open(os.path.join(scr_dir, "hf_rca_hit_5.inp")) as f:
ans = [line.strip() for line in f.readlines()]
ans = self._revert_scf_fix_strategy_to_version(ans, fix_version="2.0")
self.assertEqual(ref, ans)


def test_negative_eigen(self):
shutil.copyfile(os.path.join(test_dir, "negative_eigen.qcinp"),
os.path.join(scr_dir, "negative_eigen.qcinp"))
Expand Down
33 changes: 33 additions & 0 deletions test_files/qchem/hf_rca_hit_5.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$comment
<SCF Fix Strategy>{
"current_method_id": 5,
"methods": [
"increase_iter",
"rca_diis",
"gwh",
"gdm",
"rca",
"core+rca",
"fon"
],
"version": 2.0
}</SCF Fix Strategy>
$end


$molecule
0 1
H 0.00000000 0.00000000 -0.86267400
F 0.00000000 0.00000000 0.04381300
$end


$rem
jobtype = opt
exchange = b3lyp
basis = 6-31g*
max_scf_cycles = 200
scf_algorithm = rca
scf_guess = core
$end

40 changes: 40 additions & 0 deletions test_files/qchem/hf_rca_hit_5_fon.inp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
$comment
<SCF Fix Strategy>{
"current_method_id": 6,
"methods": [
"increase_iter",
"rca_diis",
"gwh",
"gdm",
"rca",
"core+rca",
"fon"
],
"version": 2.0
}</SCF Fix Strategy>
$end


$molecule
0 1
H 0.00000000 0.00000000 -0.86267400
F 0.00000000 0.00000000 0.04381300
$end


$rem
jobtype = opt
exchange = b3lyp
basis = 6-31g*
fon_e_thresh = 6
fon_norb = 1
fon_t_end = 300
fon_t_start = 300
max_scf_cycles = 200
occupations = 2
scf_algorithm = diis
scf_convergence = 7
scf_guess = sad
thresh = 14
$end

0 comments on commit 06355ac

Please sign in to comment.