forked from MatthewRHermes/mrh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
1,482 additions
and
186 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
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,17 @@ | ||
from mrh.tests.lasscf.c2h4n4_struct import structure as struct | ||
from mrh.my_pyscf.mcscf.lasscf_async import LASSCF | ||
from pyscf.lib import logger | ||
from pyscf import scf | ||
|
||
mol = struct (0.0, 0.0, '6-31g', symmetry=False) | ||
mol.spin = 0 | ||
mol.verbose = logger.DEBUG | ||
mol.output = 'c2h4n4_equil_lasscf1010_631g.log' | ||
mol.build () | ||
mf = scf.RHF (mol).run () | ||
las = LASSCF (mf, (4,2,4), ((2,2),(1,1),(2,2)), spin_sub=(1,1,1)) | ||
mo_coeff = las.sort_mo ([7,8,16,18,22,23,24,26,33,34]) | ||
mo_coeff = las.set_fragments_([[0,1,2],[3,4,5,6],[7,8,9]], mo_coeff=mo_coeff) | ||
las.kernel (mo_coeff) | ||
|
||
|
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,15 @@ | ||
from mrh.tests.lasscf.c2h4n4_struct import structure as struct | ||
from mrh.my_pyscf.mcscf.lasscf_async import LASSCF | ||
from pyscf.lib import logger | ||
from pyscf import scf | ||
|
||
mol = struct (2.0, 2.0, '6-31g', symmetry=False) | ||
mol.spin = 8 | ||
mol.verbose = logger.DEBUG | ||
mol.output = 'c2h4n4_str_lasscf1010_631g.log' | ||
mol.build () | ||
mf = scf.RHF (mol).run () | ||
las = LASSCF (mf, (4,2,4), ((2,2),(1,1),(2,2)), spin_sub=(1,1,1)) | ||
mo_coeff = las.set_fragments_([[0,1,2],[3,4,5,6],[7,8,9]]) | ||
las.kernel (mo_coeff) | ||
|
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,17 @@ | ||
import numpy as np | ||
from scipy import linalg | ||
from pyscf import gto, scf, lib, mcscf | ||
from mrh.my_pyscf.mcscf.lasscf_async import LASSCF | ||
|
||
xyz = '''H 0.0 0.0 0.0 | ||
H 1.0 0.0 0.0 | ||
H 0.2 3.9 0.1 | ||
H 1.159166 4.1 -0.1''' | ||
mol = gto.M (atom = xyz, basis = '6-31g', output='h4_631g.log', | ||
verbose=lib.logger.DEBUG) | ||
mf = scf.RHF (mol).run () | ||
las = LASSCF (mf, (2,2), (2,2), spin_sub=(1,1)) | ||
frag_atom_list = ((0,1),(2,3)) | ||
mo_loc = las.set_fragments_(frag_atom_list, mf.mo_coeff) | ||
las.kernel (mo_loc) | ||
|
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,27 @@ | ||
from mrh.tests.lasscf.c2h4n4_struct import structure as struct | ||
from mrh.my_pyscf.mcscf.lasscf_async import LASSCF | ||
from pyscf.lib import logger | ||
from pyscf import scf | ||
|
||
mol = struct (0.0, 0.0, '6-31g', symmetry=False) | ||
mol.spin = 0 | ||
mol.verbose = logger.DEBUG | ||
mol.output = 'using_older_kernel.log' | ||
mol.build () | ||
mf = scf.RHF (mol).run () | ||
las = LASSCF (mf, (4,2,4), ((2,2),(1,1),(2,2)), spin_sub=(1,1,1)) | ||
mo_coeff = las.sort_mo ([7,8,16,18,22,23,24,26,33,34]) | ||
mo_coeff = las.set_fragments_([[0,1,2],[3,4,5,6],[7,8,9]], mo_coeff=mo_coeff) | ||
|
||
# Note that just importing the patch_kernel function doesn't do anything, unlike the gpu4pyscf | ||
# "patch_*" functions. I prefer not to do things in imports and I hate global variables, so | ||
# instead, patch_kernel is a function that returns a patched version of that specific method | ||
# instance. | ||
from mrh.my_pyscf.mcscf.lasscf_async import old_aa_sync_kernel | ||
las = old_aa_sync_kernel.patch_kernel (las) | ||
|
||
# This will take fewer macrocycles to converge than c2h4n4_equil_lasscf1010_631g, to which it is | ||
# otherwise identical. | ||
las.kernel (mo_coeff) | ||
|
||
|
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,76 @@ | ||
#include <stdint.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <assert.h> | ||
#include <math.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <omp.h> | ||
#include <time.h> | ||
#include "../fblas.h" | ||
|
||
#ifndef MINMAX | ||
#define MAX(x, y) (((x) > (y)) ? (x) : (y)) | ||
#define MIN(x, y) (((x) < (y)) ? (x) : (y)) | ||
#define MINMAX | ||
#endif | ||
|
||
/* | ||
# A C version of the below would need: | ||
# all args of _put_SD?_ | ||
# self.si, in some definite order | ||
# length of _put_SD?_ args, ncas, nroots_si, maybe nstates? | ||
# If I wanted to index down, I would also need | ||
# ncas_sub, nfrags, inv, len (inv) | ||
def _put_SD1_(self, bra, ket, D1, wgt): | ||
t0, w0 = logger.process_clock (), logger.perf_counter () | ||
si_dm = self.si[bra,:] * self.si[ket,:].conj () | ||
fac = np.dot (wgt, si_dm) | ||
self.rdm1s[:] += np.multiply.outer (fac, D1) | ||
dt, dw = logger.process_clock () - t0, logger.perf_counter () - w0 | ||
self.dt_s, self.dw_s = self.dt_s + dt, self.dw_s + dw | ||
def _put_SD2_(self, bra, ket, D2, wgt): | ||
t0, w0 = logger.process_clock (), logger.perf_counter () | ||
si_dm = self.si[bra,:] * self.si[ket,:].conj () | ||
fac = np.dot (wgt, si_dm) | ||
self.rdm2s[:] += np.multiply.outer (fac, D2) | ||
dt, dw = logger.process_clock () - t0, logger.perf_counter () - w0 | ||
self.dt_s, self.dw_s = self.dt_s + dt, self.dw_s + dw | ||
*/ | ||
|
||
void LASSIRDMdputSD (double * SDsum, double * SDterm, int SDlen, | ||
double * sivec, int sivec_nbas, int sivec_nroots, | ||
long * bra, long * ket, double * wgt, int nelem) | ||
{ | ||
const unsigned int i_one = 1; | ||
|
||
double fac = 0; | ||
double * sicol = sivec; | ||
double * SDtarget = SDsum; | ||
|
||
for (int iroot = 0; iroot < sivec_nroots; iroot++){ | ||
sicol = sivec + (iroot*sivec_nbas); | ||
SDtarget = SDsum + (iroot*SDlen); | ||
|
||
fac = 0; | ||
|
||
#pragma omp parallel for schedule(static) reduction(+:fac) | ||
for (int ielem = 0; ielem < nelem; ielem++){ | ||
fac += sicol[bra[ielem]] * sicol[ket[ielem]] * wgt[ielem]; | ||
} | ||
|
||
//daxpy_(&SDlen, &fac, SDterm, &i_one, SDtarget, &i_one); | ||
#pragma omp parallel | ||
{ | ||
int nblk = omp_get_num_threads (); | ||
nblk = (SDlen+nblk-1) / nblk; | ||
int toff = nblk * omp_get_thread_num (); | ||
nblk = MIN (SDlen, toff+nblk); | ||
nblk = nblk - toff; | ||
daxpy_(&nblk, &fac, SDterm+toff, &i_one, SDtarget+toff, &i_one); | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.