-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from lcmd-epfl/sad_fix
Fix SPAHM[SAD] for open-shell systems #32
- Loading branch information
Showing
6 changed files
with
62 additions
and
27 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
Binary file not shown.
Binary file not shown.
This file was deleted.
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
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,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import numpy as np | ||
from qstack import compound | ||
from qstack.spahm.rho import atom | ||
|
||
|
||
def test_water(): | ||
path = os.path.dirname(os.path.realpath(__file__)) | ||
mol = compound.xyz_to_mol(path+'/data/H2O.xyz', 'minao', charge=0, spin=None) | ||
|
||
X = atom.get_repr(mol, ["H", "O"], 0, None, dm=None, | ||
guess='LB', model='lowdin-long-x', auxbasis='ccpvdzjkfit') | ||
|
||
X_true = np.load(path+'/data/SPAHM_a_H2O/X_H2O.npy', allow_pickle=True) | ||
assert(X.shape == X_true.shape) | ||
for a, a_true in zip(X, X_true): | ||
assert(a[0] == a_true[0]) # atom type | ||
assert(np.linalg.norm(a[1]-a_true[1]) < 1e-08) # atom representations | ||
|
||
def test_water_SAD_guess_open_shell(): | ||
path = os.path.dirname(os.path.realpath(__file__)) | ||
mol = compound.xyz_to_mol(path+'/data/H2O.xyz', 'sto3g', charge=1, spin=1) ## test breaks when effective open-shell caluclation is needed | ||
|
||
Xsad = atom.get_repr(mol, ["H", "O"], 1, 1, dm=None, | ||
xc = 'hf', guess='sad', model='lowdin-long-x', auxbasis='ccpvdzjkfit') | ||
Xtrue = np.load(path+'/data/SPAHM_a_H2O/X_H2O-RC_SAD.npy', allow_pickle=True) | ||
assert(Xsad.shape == Xtrue.shape) | ||
for a, a_true in zip(Xsad, Xtrue): | ||
assert(a[0] == a_true[0]) # atom type | ||
assert(np.linalg.norm(a[1]-a_true[1]) < 1e-08) # atom representations | ||
|
||
def test_water_SAD_guess_close_shell(): | ||
path = os.path.dirname(os.path.realpath(__file__)) | ||
mol = compound.xyz_to_mol(path+'/data/H2O.xyz', 'sto3g', charge=0, spin=0) ## test breaks when effective open-shell caluclation is needed | ||
|
||
Xsad = atom.get_repr(mol, ["H", "O"], 0, None, dm=None, | ||
xc = 'hf', guess='sad', model='lowdin-long-x', auxbasis='ccpvdzjkfit') | ||
Xtrue = np.load(path+'/data/SPAHM_a_H2O/X_H2O_SAD.npy', allow_pickle=True) | ||
assert(Xsad.shape == Xtrue.shape) | ||
for a, a_true in zip(Xsad, Xtrue): | ||
assert(a[0] == a_true[0]) # atom type | ||
assert(np.linalg.norm(a[1]-a_true[1]) < 1e-08) # atom representations | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
test_water() | ||
test_water_SAD_guess_close_shell() | ||
test_water_SAD_guess_open_shell() |