Skip to content

Commit

Permalink
fixed bug with occs when nbasis!=nfn_indep
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Chan committed Nov 19, 2018
1 parent 64e661d commit b47b497
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 3 additions & 3 deletions iodata/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def load_dm(label):
result['orb_alpha_coeffs'] = np.copy(
fchk['Alpha MO coefficients'].reshape(nbasis_indep, nbasis).T)
result['orb_alpha_energies'] = np.copy(fchk['Alpha Orbital Energies'])
aoccs = np.zeros(nbasis)
aoccs = np.zeros(nbasis_indep)
aoccs[:nalpha] = 1.0
result['orb_alpha_occs'] = aoccs
if 'Beta Orbital Energies' in fchk:
Expand All @@ -457,7 +457,7 @@ def load_dm(label):
result['orb_beta_coeffs'] = np.copy(
fchk['Beta MO coefficients'].reshape(nbasis_indep, nbasis).T)
result['orb_beta_energies'] = np.copy(fchk['Beta Orbital Energies'])
boccs = np.zeros(nbasis)
boccs = np.zeros(nbasis_indep)
boccs[:nbeta] = 1.0
result['orb_beta_occs'] = boccs

Expand All @@ -466,7 +466,7 @@ def load_dm(label):
result['orb_beta'] = (nbasis, nbasis_indep)
result['orb_beta_coeffs'] = fchk['Alpha MO coefficients'].reshape(nbasis_indep, nbasis).T
result['orb_beta_energies'] = fchk['Alpha Orbital Energies']
boccs = np.zeros(nbasis)
boccs = np.zeros(nbasis_indep)
boccs[:nbeta] = 1.0
result['orb_beta_occs'] = boccs

Expand Down
6 changes: 6 additions & 0 deletions iodata/test/test_gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ def test_load_fchk_lih_321g_hf():
assert abs(orb_beta_occs.sum() - 1) == 0.0
assert orb_beta_occs.min() == 0.0
assert orb_beta_occs.max() == 1.0

assert orb_alpha_occs.shape[0] == orb_alpha_coeffs.shape[0]
assert orb_beta_occs.shape[0] == orb_beta_coeffs.shape[0]

energy = fields['energy']
assert energy == -7.687331212191968E+00

Expand Down Expand Up @@ -271,6 +275,8 @@ def test_load_fchk_ch3_rohf_g03():
orb_alpha_occs = fields['orb_alpha_occs']
orb_beta_coeffs = fields['orb_beta_coeffs']
orb_beta_occs = fields['orb_beta_occs']
assert orb_alpha_occs.shape[0] == orb_alpha_coeffs.shape[0]
assert orb_beta_occs.shape[0] == orb_beta_coeffs.shape[0]
assert orb_alpha_occs.sum() == 5
orb_beta = fields['orb_beta']
assert orb_beta_occs.sum() == 4
Expand Down

0 comments on commit b47b497

Please sign in to comment.