Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be6ca4f
Example for embedding potential on a grid. Needs cleaning.
crisely09 Oct 28, 2019
c6f1a0b
Added PySCF classes, only rks finished, none tested.
crisely09 Nov 14, 2019
1792ec7
Added re-ordering functions.
crisely09 Dec 6, 2019
721a0d1
TD-DFT working on PySCF, only RKS.
crisely09 Jan 14, 2020
0527a4c
Changed QcWrap to ScfWrap to be able to add PostScfWrap objects.
crisely09 Jan 14, 2020
97365e2
Changed kinetic functional name.
crisely09 Jan 14, 2020
4d31b27
Missing change for TF functional.
crisely09 Jan 14, 2020
a92e4e5
First steps adding Post-SCF embedding.
crisely09 Jan 14, 2020
becfa1c
Removed default taco function and test.
crisely09 Jan 14, 2020
e9e1343
Rearrangement to add PostSCF wrappers. Test updated.
crisely09 Jan 20, 2020
562f8dc
Some fixes and cleaning.
crisely09 Jan 20, 2020
8bf2915
Molcas HF-in-HF test working.
crisely09 Jan 24, 2020
fc33708
Merge pull request #1 from crisely09/progress
crisely09 Jan 27, 2020
cd4d244
Added function to compute kernel terms.
crisely09 Jan 27, 2020
da3f8fd
Added basis file for test.
crisely09 Jan 27, 2020
b7bbb62
Check two different ways to compute the kernel terms.
crisely09 Jan 28, 2020
6ceed50
Some printing in tddft.
crisely09 Mar 2, 2020
0c41051
Install PySCF with conda.
crisely09 Mar 2, 2020
20e991b
Little experiment.
crisely09 Mar 2, 2020
662d4ed
Added GGA's to PySCF embedding potential.
crisely09 Mar 20, 2020
4308531
Forgot files for tests.
crisely09 Mar 20, 2020
18783eb
Trying to solve not passed test.
crisely09 Mar 20, 2020
bff4719
Proper format for MGGA functional, and other fixes.
crisely09 Mar 20, 2020
9db4c5c
Letting Kinetic functionals also to be GGA.
crisely09 Mar 20, 2020
b522c59
Added example of ADC2 and new function for coulomb repulsion on a grid.
crisely09 Apr 20, 2020
a44f718
Fixed small bugs.
crisely09 Apr 20, 2020
84c420b
Some changes
crisely09 Jun 13, 2020
f9bad04
modified before_install
crisely09 Jun 13, 2020
5a19329
missed one line.
crisely09 Jun 13, 2020
2190893
Fixed small problems.
crisely09 Jun 16, 2020
590c76e
changed filenames
crisely09 Jun 22, 2020
430f662
Changed name in test files.
crisely09 Jun 22, 2020
cfa1fa1
Some smal modifications.
crisely09 Sep 2, 2020
faf2b7e
Small changes.
crisely09 Sep 4, 2020
b9bc0ca
Fixed the get_charge_and_coords function.
crisely09 Oct 1, 2020
d83bee5
Resolve unit issues.
crisely09 Oct 1, 2020
c32dece
Fix get_charges_and_coordinates to avoid ghost atoms.
crisely09 Oct 23, 2020
4229f22
Take out the external packages for now.
crisely09 Oct 26, 2020
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
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ language: python
matrix:
include:
# Extra includes for OSX since python language is not available by default on OSX
- os: osx
language: generic
env: PYTHON_VER=3.6
# - os: osx
# language: generic
# env: PYTHON_VER=3.6
- os: osx
language: generic
env: PYTHON_VER=3.7
Expand Down Expand Up @@ -45,7 +45,9 @@ install:
# Activate the test environment
- conda activate test
# install pyscf
- pip install pyscf
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then conda config --append channels pyscf ; fi
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then conda install pyscf ; fi
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then pip install pyscf ; fi
# install QCElemental
- pip install qcelemental
# install pandas
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Taco
==============================
[//]: # (Badges)
[![Travis Build Status](https://travis-ci.com/maxscheurer/taco.svg?token=Xyntx2ELmeydq8pgqs8t&branch=master)](https://travis-ci.com/maxscheurer/taco)
[![codecov](https://codecov.io/gh/maxscheurer/Taco/branch/master/graph/badge.svg)](https://codecov.io/gh/maxscheurer/Taco/branch/master)
[![Travis Build Status](https://travis-ci.com/crisely09/taco.svg?branch=master)](https://travis-ci.com/crisely09/taco)
[![codecov](https://codecov.io/gh/crisely09/taco/branch/master/graph/badge.svg)](https://codecov.io/gh/crisely09/taco)

FDE wrapper library

Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codecov:
token: 40b8d2d2-b267-41c7-abd4-82cfe23a570b
24 changes: 16 additions & 8 deletions devtools/travis-ci/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pushd .
cd $HOME
# Make sure some level of pip is installed
python -m ensurepip

# Install Miniconda
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
# Make OSX md5 mimic md5sum from linux, alias does not work
Expand All @@ -12,11 +11,12 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
}
MINICONDA=Miniconda3-latest-MacOSX-x86_64.sh
else
export CXX=g++-4.8 CC=gcc-4.8
MINICONDA=Miniconda3-latest-Linux-x86_64.sh
fi
MINICONDA_HOME=$HOME/miniconda
MINICONDA_MD5=$(curl -s https://repo.continuum.io/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p')
wget -q https://repo.continuum.io/miniconda/$MINICONDA
MINICONDA_MD5=$(wget -qO- https://repo.anaconda.com/miniconda/ | grep -A3 $MINICONDA | sed -n '4p' | sed -n 's/ *<td>\(.*\)<\/td> */\1/p')
wget -q https://repo.anaconda.com/miniconda/$MINICONDA
if [[ $MINICONDA_MD5 != $(md5sum $MINICONDA | cut -d ' ' -f 1) ]]; then
echo "Miniconda MD5 mismatch"
exit 1
Expand All @@ -29,13 +29,21 @@ export PIP_ARGS="-U"
echo ". $MINICONDA_HOME/etc/profile.d/conda.sh" >> ~/.bashrc # Source the profile.d file
echo "conda activate" >> ~/.bashrc # Activate conda
source ~/.bashrc # source file to get new commands
#export PATH=$MINICONDA_HOME/bin:$PATH # Old way, should not be needed anymore

conda config --add channels conda-forge

conda config --set always_yes yes
conda install conda conda-build jinja2 anaconda-client
conda update --quiet --all

if [ "$TRAVIS_OS_NAME" == "osx" ]; then
HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade pyenv
# Pyenv requires minor revision, get the latest
PYENV_VERSION=$(pyenv install --list |grep $PYTHON_VER | sed -n "s/^[ \t]*\(${PYTHON_VER}\.*[0-9]*\).*/\1/p" | tail -n 1)
# Install version
pyenv install -f $PYENV_VERSION
# Use version for this
pyenv global $PYENV_VERSION
# Setup up path shims
eval "$(pyenv init -)"
fi
pip install --upgrade pip setuptools
{% endif %}
# Restore original directory
popd
23 changes: 23 additions & 0 deletions examples/embedding/co_h2o_adcc.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
converged SCF energy = -111.225169473797
converged SCF energy = -74.9646931916275
converged SCF energy = -111.408077919059
Starting adc2 singlet Jacobi-Davidson ...
Niter n_ss max_residual time Ritz values
1 6 0.092177 821ms [0.4008882 0.40092934 0.4494298 ]
2 12 0.0059539 976ms [0.33879721 0.33883308 0.4095161 ]
3 18 0.00061796 695ms [0.33503654 0.33510021 0.40951458]
4 24 2.1679e-06 710ms [0.33407691 0.33411293 0.40951457]
5 30 5.3286e-09 1.6s [0.33407553 0.33411179 0.40951457]
=== Converged ===
Number of matrix applies: 30
Total solver time: 4s 860ms
+--------------------------------------------------------------+
| adc2 singlet , converged |
+--------------------------------------------------------------+
| # excitation energy osc str |v1|^2 |v2|^2 |
| (au) (eV) |
| 0 0.3340755 9.090658 0.0282 0.9659 0.03412 |
| 1 0.3341118 9.091645 0.0282 0.9659 0.03412 |
| 2 0.4095146 11.14346 0.0000 0.974 0.02602 |
+--------------------------------------------------------------+

32 changes: 32 additions & 0 deletions examples/embedding/pyscf_vemb_adc2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""Compute the embedding potential and export it."""
from qcelemental.models import Molecule

import adcc
from taco.embedding.pyscf_wrap import PyScfWrap

# Define Molecules with QCElemental
co = Molecule.from_data("""C -3.6180905689 1.3768035675 -0.0207958979
O -4.7356838533 1.5255563000 0.1150239130""")
h2o = Molecule.from_data("""O -7.9563726699 1.4854060709 0.1167920007
H -6.9923165534 1.4211335985 0.1774706091
H -8.1058463545 2.4422204631 0.1115993752""")
# Define arguments
with open("/home/users/g/gonzalcr/projects/tests/fdeta/2water/cc-pvdz-segopt.nwchem", 'r') as fb:
basis = fb.read()
basis = 'sto-3g'
method = 'hf'
xc_code = 'LDA,VWN'
args0 = {"mol": co, "basis": basis, "method": method}
args1 = {"mol": h2o, "basis": basis, "method": method}
embs = {"mol": co, "basis": basis, "method": 'hf',
"xc_code": xc_code, "t_code": 'LDA_K_TF,'}
# Make a wrap
wrap = PyScfWrap(args0, args1, embs)
wrap.emb_method.scf_object.conv_tol = 1e-12
wrap.run_embedding()
# Get SCF object
scfres = wrap.emb_method.scf_object

# Call adcc
state = adcc.adc2(scfres, n_singlets=3)
print(state.describe())
67 changes: 67 additions & 0 deletions examples/embedding/pyscf_vemb_grid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
"""Compute the embedding potential on a grid and export it."""
import numpy as np
from qcelemental.models import Molecule

from pyscf import gto
from pyscf.dft import gen_grid
from pyscf.dft.numint import eval_ao, eval_rho
from taco.methods.scf_pyscf import get_pyscf_molecule
from taco.embedding.pyscf_wrap import PyScfWrap, get_charges_and_coords
from taco.embedding.pyscf_wrap_single import get_density_from_dm, get_dft_grid_stuff
from taco.embedding.cc_gridfns import coulomb_potential_grid, nuclear_attraction_energy

# Define Molecules with QCElemental
co = Molecule.from_data("""C -3.6180905689 1.3768035675 -0.0207958979
O -4.7356838533 1.5255563000 0.1150239130""")
h2o = Molecule.from_data("""O -7.9563726699 1.4854060709 0.1167920007
H -6.9923165534 1.4211335985 0.1774706091
H -8.1058463545 2.4422204631 0.1115993752""")
# Define arguments
basis = 'cc-pvdz'
method = 'dft'
xc_code = 'LDA,VWN'
args0 = {"mol": co, "basis": basis, "method": method, "xc_code": xc_code}
args1 = {"mol": h2o, "basis": basis, "method": method, "xc_code": xc_code}
embs = {"mol": co, "basis": basis, "method": 'dft',
"xc_code": xc_code, "t_code": 'XC_LDA_K_TF'}
# Make a wrap
wrap = PyScfWrap(args0, args1, embs)

# Make molecule in pyscf
co_mol = get_pyscf_molecule(co, basis)
h2o_mol = get_pyscf_molecule(h2o, basis)
dm0 = wrap.method0.get_density()
dm1 = wrap.method1.get_density()
# Create supersystem
newatom = '\n'.join([co_mol.atom, h2o_mol.atom])
system = gto.M(atom=newatom, basis=basis)
# Construct grid for integration
grids = gen_grid.Grids(system)
grids.level = 4
grids.build()
# Grid for plot
points = np.array([[0., 0., z] for z in np.arange(-10., 10., 0.1)])
rho0 = get_density_from_dm(wrap.mol0, dm0, points)
rho1 = get_density_from_dm(wrap.mol1, dm1, points)
rho1_grid = get_density_from_dm(wrap.mol1, dm1, grids.coords)
# Coulomb repulsion potential
v_coul = coulomb_potential_grid(points, grids.coords, grids.weights, rho1_grid)
# Nuclear-electron attraction potential
mol1_charges, mol1_coords = get_charges_and_coords(h2o_mol)
v1_nuc0 = np.zeros(rho0.shape)
for i in range(len(mol1_charges)):
v1_nuc0 += - mol1_charges[i]*rho0/np.linalg.norm(points-mol1_coords[i])
# DFT nad potential
xc_code = embs["xc_code"]
t_code = embs["t_code"]
rho_both = rho0 + rho1
excs, vxcs = get_dft_grid_stuff(xc_code, rho_both, rho0, rho1)
ets, vts = get_dft_grid_stuff(t_code, rho_both, rho0, rho1)
vxc_emb = vxcs[0][0] - vxcs[1][0]
vt_emb = vts[0][0] - vts[1][0]

vemb_tot = v_coul + v1_nuc0 + vxc_emb + vt_emb


# Save it to use it later
np.save('vemb_co_h2o.npy', vemb_tot)
Binary file added examples/embedding/vemb_co_h2o.npy
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __str__(self):
license='LGPLv3',

# External modules
ext_modules=ext_modules,
# ext_modules=ext_modules,

# Which Python importable modules should be included when your package is installed
# Handled automatically by setuptools. Use 'exclude' to prevent some specific
Expand Down
3 changes: 0 additions & 3 deletions taco/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
FDE wrapper library
"""

# Add imports here
from .taco import *

# Handle versioneer
from ._version import get_versions
versions = get_versions()
Expand Down
30 changes: 30 additions & 0 deletions taco/data/cache.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import glob

from taco.testdata.cache import fullfile


# TODO: will be refactored
class DataCache():
@property
def files(self):
thisdir = os.path.dirname(__file__)
fnames = glob.glob(os.path.join(thisdir, "*.txt"))
ret = {}
for f in fnames:
bname = os.path.splitext(os.path.basename(f))[0]
ret[bname] = fullfile(f)
return ret

@property
def jfiles(self):
thisdir = os.path.dirname(__file__)
fnames = glob.glob(os.path.join(thisdir, "*.json"))
ret = {}
for f in fnames:
bname = os.path.splitext(os.path.basename(f))[0]
ret[bname] = fullfile(f)
return ret


data = DataCache()
44 changes: 44 additions & 0 deletions taco/data/translation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{ "pyscf2molcas":
{"cc-pvdz":
{"first": [0, 1, 2, 3, 4],
"second": [0, 1, 2, 3, 6, 4, 7, 5, 8, 9, 10, 11, 12, 13]
}
},
"qchem2pyscf":
{"aug-cc-pvdz":
{"first": [0, 1, 5, 2, 3, 4, 6, 7, 8],
"second": [0, 1, 2, 14, 3, 4, 5, 6, 7, 8, 15, 16, 17, 9, 10,
11, 12, 13, 18, 19, 20, 21, 22],
},
"cc-pvdz":
{"first": [0, 1, 2, 3, 4],
"second": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
"third": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
},
"cc-pvtz":
{"first": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
"second": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, 26, 27, 28, 29],
"third": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 33]
}
},
"pyscf2qchem":
{"6-31g":
{"first": [0, 1],
"second": [0, 1, 2, 3, 6, 4, 7, 5, 8]
},
"aug-cc-pvdz":
{"first": [],
"second": []
}
},
"molcas2pyscf":
{"cc-pvdz":
{"first": [0, 1, 2, 3, 4],
"second": [0, 1, 2, 3, 5, 7, 4, 6, 8, 9, 10, 11, 12, 13]
}
}
}
56 changes: 56 additions & 0 deletions taco/embedding/density.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""Tools to handle densities."""

import re
import numpy as np
from taco.translate.tools import parse_matrices


def transform_density_matrix(dm, coeffs):
"""Transform the Density Metrix into a different orbital representation.

Parameters
----------
dm : np.ndarray
Density matrix to be transformed.
coeffs : np.ndarray
Set of orbital coefficients used for transformation, as follows:

.. math::
\gamma_{fin} = \sum_{ij} \chi_i \gamma_{ij} \chi^*_j

Returns
-------
dm_fin : np.ndarray
Transformed density matrix
"""
dm_fin = np.einsum('ij,ki,lj->kl', dm, coeffs, coeffs)
return dm_fin


def prepare_omolcas_density(fname, mo_repr=False):
"""Prepare density to be read from OpenMolcas.

Parameters
----------
fname : str
Name of file from where the density is taken.
mo_repr : bool
Whether the density matrix to be read is in MO basis.

Returns
-------
dm : np.ndarray
Density matrix in AO or MO representation.
"""
if "RUNASCII" in fname:
if mo_repr:
hook = {'1dm': re.compile(r'\<(D1mo.)')}
else:
hook = {'1dm': re.compile(r'\<(D1ao.)')}
parsed = parse_matrices(fname, hook, software='molcas')
return parsed['1dm']
elif fname.endswith('.h5'):
pass
else:
raise ValueError("""Please specify correctly the name of file,"""
""" either containing `RUNASCII` or use a `.h5`""")
Loading