Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 19, 2024
1 parent 287fa94 commit 2388993
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 42 deletions.
104 changes: 82 additions & 22 deletions gbasis/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,88 @@


CONVENTIONS_LIBCINT = {
(5, 'p'): ['s5','s4', 's3', 's2', 's1', 'c0', 'c1', 'c2', 'c3', 'c4','c5'],
(4, 'p'): ['s4','s3', 's2', 's1', 'c0', 'c1', 'c2', 'c3', 'c4'],
(3, 'p'): ['s3', 's2', 's1', 'c0', 'c1', 'c2', 'c3'],
(2, 'p'): ['s2', 's1', 'c0', 'c1', 'c2'],
(0, 'c'): ['1'],
(1, 'c'): ['x', 'y', 'z'],
(2, 'c'): ['xx', 'xy', 'xz', 'yy', 'yz', 'zz'],
(3, 'c'): ['xxx', 'xxy', 'xxz', 'xyy', 'xyz', 'xzz', 'yyy', 'yyz', 'yzz', 'zzz'],
(4, 'c'): ['xxxx', 'xxxy', 'xxxz', 'xxyy', 'xxyz', 'xxzz', 'xyyy', 'xyyz', 'xyzz',
'xzzz', 'yyyy', 'yyyz', 'yyzz', 'yzzz', 'zzzz'],
(5, 'c'): ['xxxxx', 'xxxxy', 'xxxxz', 'xxxyy', 'xxxyz', 'xxxzz', 'xxyyy', 'xxyyz', 'xxyzz',
'xxzzz', 'xyyyy', 'xyyyz', 'xyyzz', 'xyzzz', 'xzzzz', 'yyyyy', 'yyyyz', 'yyyzz',
'yyzzz', 'yzzzz', 'zzzzz'],
(6, 'c'): ['xxxxxx', 'xxxxxy', 'xxxxxz', 'xxxxyy', 'xxxxyz', 'xxxxzz', 'xxxyyy',
'xxxyyz', 'xxxyzz', 'xxxzzz', 'xxyyyy', 'xxyyyz', 'xxyyzz', 'xxyzzz',
'xxzzzz', 'xyyyyy', 'xyyyyz', 'xyyyzz', 'xyyzzz', 'xyzzzz', 'xzzzzz',
'yyyyyy', 'yyyyyz', 'yyyyzz', 'yyyzzz', 'yyzzzz', 'yzzzzz', 'zzzzzz'],
(5, "p"): ["s5", "s4", "s3", "s2", "s1", "c0", "c1", "c2", "c3", "c4", "c5"],
(4, "p"): ["s4", "s3", "s2", "s1", "c0", "c1", "c2", "c3", "c4"],
(3, "p"): ["s3", "s2", "s1", "c0", "c1", "c2", "c3"],
(2, "p"): ["s2", "s1", "c0", "c1", "c2"],
(0, "c"): ["1"],
(1, "c"): ["x", "y", "z"],
(2, "c"): ["xx", "xy", "xz", "yy", "yz", "zz"],
(3, "c"): ["xxx", "xxy", "xxz", "xyy", "xyz", "xzz", "yyy", "yyz", "yzz", "zzz"],
(4, "c"): [
"xxxx",
"xxxy",
"xxxz",
"xxyy",
"xxyz",
"xxzz",
"xyyy",
"xyyz",
"xyzz",
"xzzz",
"yyyy",
"yyyz",
"yyzz",
"yzzz",
"zzzz",
],
(5, "c"): [
"xxxxx",
"xxxxy",
"xxxxz",
"xxxyy",
"xxxyz",
"xxxzz",
"xxyyy",
"xxyyz",
"xxyzz",
"xxzzz",
"xyyyy",
"xyyyz",
"xyyzz",
"xyzzz",
"xzzzz",
"yyyyy",
"yyyyz",
"yyyzz",
"yyzzz",
"yzzzz",
"zzzzz",
],
(6, "c"): [
"xxxxxx",
"xxxxxy",
"xxxxxz",
"xxxxyy",
"xxxxyz",
"xxxxzz",
"xxxyyy",
"xxxyyz",
"xxxyzz",
"xxxzzz",
"xxyyyy",
"xxyyyz",
"xxyyzz",
"xxyzzz",
"xxzzzz",
"xyyyyy",
"xyyyyz",
"xyyyzz",
"xyyzzz",
"xyzzzz",
"xzzzzz",
"yyyyyy",
"yyyyyz",
"yyyyzz",
"yyyzzz",
"yyzzzz",
"yzzzzz",
"zzzzzz",
],
}

def from_iodata(mol, tol=1e-20, overlap=False):

def from_iodata(mol, tol=1e-20, overlap=False):
"""Return basis set stored within the `IOData` instance in `iodata`.
Parameters
Expand Down Expand Up @@ -154,10 +215,10 @@ def permutation_libcint(self):

angmom = self.angmom
if self.coord_type == "cartesian":
coord_type = 'c'
coord_type = "c"
iodata_shell_convention = cart_conventions[angmom]
elif self.coord_type == 'spherical':
coord_type = 'p'
elif self.coord_type == "spherical":
coord_type = "p"
iodata_shell_convention = sph_conventions[angmom]

# Get libcint convention
Expand All @@ -167,7 +228,6 @@ def permutation_libcint(self):

return permutation


if molbasis.primitive_normalization != "L2": # pragma: no cover
raise ValueError(
"Only L2 normalization scheme is supported in `gbasis`. Given `IOData` instance uses "
Expand Down
16 changes: 8 additions & 8 deletions tests/h2o_hf_ccpv5z_cart.fchk
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
SP RHF CC-pV5Z
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
SP RHF CC-pV5Z
Number of atoms I 3
Info1-9 I N= 9
12 12 0 0 0 110
1 1 2
Full Title C N= 5
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
Route C N= 10
#p hf/cc-pv5z 6d/10f scf=tight scf=(maxcycle=900,xqc,fermi)
integral=grid=ultrafine symmetry=None density=current
#p hf/cc-pv5z 6d/10f scf=tight scf=(maxcycle=900,xqc,fermi)
integral=grid=ultrafine symmetry=None density=current
Charge I 0
Multiplicity I 1
Number of electrons I 10
Expand All @@ -30,7 +30,7 @@ Int Atom Types I N= 3
0 0 0
Force Field I 0
Atom Types C N= 3

MM charges R N= 3
0.00000000E+00 0.00000000E+00 0.00000000E+00
Integer atomic weights I N= 3
Expand Down Expand Up @@ -21541,7 +21541,7 @@ Int Atom Modified Types I N= 3
0 0 0
Force Field I 0
Atom Modified Types C N= 3

Link Atoms I N= 3
0 0 0
Atom Modified MM Charges R N= 3
Expand Down Expand Up @@ -22418,4 +22418,4 @@ ClPar Real Params R N= 3200
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
Gaussian Version C N= 2
ES64L-G16RevC.01
ES64L-G16RevC.01
14 changes: 7 additions & 7 deletions tests/h2o_hf_ccpv5z_sph.fchk
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
Force RHF CC-pV5Z
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
Force RHF CC-pV5Z
Number of atoms I 3
Info1-9 I N= 9
13 9 0 0 0 100
5 1 2
Full Title C N= 5
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
0015_H2O/0015_q000_m01_k00_opt_hf_ccpv5z opt-stable
Route C N= 15
#p hf/cc-pv5z 5d/7f force guess=read geom=check scf=(maxcycl
e=900,verytightlineq,xqc) integral=grid=ultrafine symmetry=N
one density=current pop=(cm5,hlygat,mbs,npa) output=wfx
one density=current pop=(cm5,hlygat,mbs,npa) output=wfx
Charge I 0
Multiplicity I 1
Number of electrons I 10
Expand All @@ -31,7 +31,7 @@ Int Atom Types I N= 3
0 0 0
Force Field I 0
Atom Types C N= 3

MM charges R N= 3
0.00000000E+00 0.00000000E+00 0.00000000E+00
Integer atomic weights I N= 3
Expand Down Expand Up @@ -20512,7 +20512,7 @@ Int Atom Modified Types I N= 3
0 0 0
Force Field I 0
Atom Modified Types C N= 3

Link Atoms I N= 3
0 0 0
Atom Modified MM Charges R N= 3
Expand Down Expand Up @@ -21389,4 +21389,4 @@ ClPar Real Params R N= 3200
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00
Gaussian Version C N= 2
ES64L-G16RevC.01
ES64L-G16RevC.01
12 changes: 7 additions & 5 deletions tests/test_libcint.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,23 +159,25 @@ def test_integral(basis, atsyms, atcoords, coord_type, integral):
npt.assert_allclose(lc_int, py_int, atol=atol, rtol=rtol)



TEST_SYSTEMS_IODATA = [
pytest.param("h2o_hf_ccpv5z_cart.fchk", ["O", "H", "H"], "Cartesian", id="h2o_cart"),
pytest.param("h2o_hf_ccpv5z_sph.fchk", ["O", "H", "H"], "Spherical", id="h2o_sph"),
]
]

TEST_INTEGRALS_IODATA = [
pytest.param("overlap", id="Overlap"),
pytest.param("kinetic_energy", id="KineticEnergy"),
pytest.param("nuclear_attraction", id="NuclearAttraction"),
pytest.param("momentum", id="Momentum"),
pytest.param("angular_momentum", id="AngularMomentum"),
pytest.param("electron_repulsion", marks=pytest.mark.skip(reason='TOO SLOW'), id="ElectronRepulsion"),
pytest.param(
"electron_repulsion", marks=pytest.mark.skip(reason="TOO SLOW"), id="ElectronRepulsion"
),
pytest.param("point_charge", id="PointCharge"),
pytest.param("moment", id="Moment"),
]


@pytest.mark.parametrize("fname, elements, coord_type", TEST_SYSTEMS_IODATA)
@pytest.mark.parametrize("integral", TEST_INTEGRALS_IODATA)
def test_integral_iodata(fname, elements, coord_type, integral):
Expand All @@ -184,8 +186,8 @@ def test_integral_iodata(fname, elements, coord_type, integral):

atol, rtol = 1e-4, 1e-4

mol=load_one(find_datafile(fname))
py_basis=from_iodata(mol)
mol = load_one(find_datafile(fname))
py_basis = from_iodata(mol)

lc_basis = CBasis(py_basis, elements, mol.atcoords, coord_type=coord_type)

Expand Down

0 comments on commit 2388993

Please sign in to comment.