Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

#FIXME: workflow dependency not working on non-default branch?
#on:
# workflow_run:
# workflows:
# - Lint
# types:
# - completed
on:
- push
- pull_request

jobs:
linux-build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10","3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install
run: ./.github/workflows/run_ci.sh
- name: Test with pytest
run: ./.github/workflows/test.sh
15 changes: 15 additions & 0 deletions .github/workflows/run_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -e

sudo apt-get -qq install \
gcc \
libblas-dev \
cmake \
curl

python -m pip install --upgrade pip
pip install pytest
pip install .


6 changes: 6 additions & 0 deletions .github/workflows/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

set -e

cd pyscf/prop/nmr
pytest .
15 changes: 15 additions & 0 deletions pyscf/prop/nmr/test/test_hf_msc.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
def finger(mat):
return abs(mat).sum()

def proc_nmr_tensor(tsr):
tsr = (tsr + tsr.T) / 2
eigs = numpy.linalg.eigvalsh(tsr)
eigs.sort()
nmr_iso = eigs.sum() / 3
nmr_ani = eigs[2] - (eigs[0] + eigs[1]) / 2
return nmr_iso, nmr_ani

class KnowValues(unittest.TestCase):
def test_nr_common_gauge_ucpscf(self):
m = nmr.RHF(nrhf)
Expand Down Expand Up @@ -137,6 +145,13 @@ def test_make_h10(self):
h1 = nmr.dhf.make_h10(mol, dm0, gauge_orig=(0,0,0), mb='RKB')
self.assertAlmostEqual(numpy.linalg.norm(h1), 7.3636964305440609, 8)

def test_nr_giao_uhf(self):
mol_spin2 = mol.copy().set(spin=2)
nruhf = mol_spin2.UHF().set(conv_tol=1e-12).run()
m = nmr.UHF(nruhf)
msc = m.shielding()
self.assertAlmostEqual(proc_nmr_tensor(msc[1])[0], -13739.422178310575, 4)



if __name__ == "__main__":
Expand Down
7 changes: 5 additions & 2 deletions pyscf/prop/nmr/uhf.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,11 @@ def vind(mo1):
v1ao = vresp(dm1)
v1a = [reduce(numpy.dot, (mo_coeff[0].T.conj(), x, orboa)) for x in v1ao[0]]
v1b = [reduce(numpy.dot, (mo_coeff[1].T.conj(), x, orbob)) for x in v1ao[1]]
v1mo = numpy.hstack((numpy.asarray(v1a),
numpy.asarray(v1b)))
nset = mo1a.shape[0]
v1mo = numpy.hstack((numpy.asarray(v1a).reshape(nset,-1),
numpy.asarray(v1b).reshape(nset,-1)))
# v1mo = numpy.hstack((numpy.asarray(v1a),
# numpy.asarray(v1b)))
return v1mo.ravel()
return vind

Expand Down
5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
addopts =
-k "not _high_cost and not _skip"
--ignore=examples
--ignore-glob="*_slow*.py"