コード例 #1
0
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
'''

from mrh.my_dmet import localintegrals
import mrh.my_dmet.rhf
from mrh.util.rdm import get_1RDM_from_OEI_in_subspace
from mrh.util.basis import represent_operator_in_basis, project_operator_into_subspace
import numpy as np
import ctypes
from mrh.lib.helper import load_library
lib_qcdmet = load_library('libqcdmet')


class qcdmethelper:
    def __init__(self, theLocalIntegrals, list_H1, altcf, minFunc):

        self.locints = theLocalIntegrals
        assert (self.locints.nelec_tot % 2 == 0)
        self.numPairs = int(self.locints.nelec_tot / 2)
        self.altcf = altcf
        self.minFunc = None

        if self.altcf:
            assert (minFunc == 'OEI' or minFunc == 'FOCK_INIT')
            self.minFunc = minFunc
コード例 #2
0
import numpy as np
import time, ctypes, math
from scipy import linalg, optimize
from mrh.lib.helper import load_library
from itertools import combinations
from pyscf import lib, ao2mo

libfsucc = load_library ('libfsucc')

# "sym0" means no spin or number symmetry at all: the full fock space,
# with a single flat CI vector corresponding to determinant strings
# identical to CI vector index numbers in a 64-bit unsigned integer format

'''
    fn(vv.ctypes.data_as(ctypes.c_void_p),
       ao.ctypes.data_as(ctypes.c_void_p),
       mo.ctypes.data_as(ctypes.c_void_p),
       ctypes.c_int(nao), ctypes.c_int (nmo),
       ctypes.c_int(ngrids), ctypes.c_int(mol.nbas),
       pnon0tab, pshls_slice, pao_loc)
'''

def _op1u_(norb, aidx, iidx, amp, psi, transpose=False, deriv=0):
    ''' Evaluates U|Psi> = e^(amp * [a0'a1'...i1'i0' - h.c.])|Psi>

        Args:
            norb : integer
                number of orbitals in the fock space
            aidx : list of len (na)
                lists +cr,-an operators
            iidx : list of len (ni)
コード例 #3
0
# MRH 05/18/2020: An annoying convention in pyscf.dft.numint that I have to comply with is that the
# AO grid-value arrays and all their derivatives are in NEITHER column-major NOR row-major order;
# they all have ndim = 3 and strides of (8*ngrids*nao, 8, 8*ngrids). Here, for my ndim > 3 objects,
# I choose to generalize this so that a cyclic transpose to the left, ao.transpose (1,2,3,...,0),
# places the array in column-major (FORTRAN-style) order. I have to comply with this awkward convention
# in order to take full advantage of the code in pyscf.dft.numint and libdft.so. The ngrids dimension,
# which is by far the largest, almost always benefits from having the smallest stride.

# MRH 05/19/2020: Actually, I really should just turn the deriv component part of all of these arrays into
# lists and keep everything in col-major order otherwise, because ndarrays have to have regular strides,
# but lists can just be references and less copying is involved. The copying is more expensive and less
# transparently parallel-scalable than the actual math! (The parallel-scaling part of that is stupid but it
# is what it is.

SWITCH_SIZE = getattr(__config__, 'dft_numint_SWITCH_SIZE', 800)
libpdft = load_library('libpdft')


class _ERIS(object):
    def __init__(self,
                 mol,
                 mo_coeff,
                 ncore,
                 ncas,
                 method='incore',
                 paaa_only=False,
                 aaaa_only=False,
                 verbose=0,
                 stdout=None):
        self.mol = mol
        self.mo_coeff = mo_coeff
コード例 #4
0
ファイル: csfstring.py プロジェクト: hebrewsnabla/mrh
import numpy as np
import sys, os, time
import ctypes
from mrh.my_pyscf.fci import csdstring
from pyscf.fci import cistring
from pyscf.fci.spin_op import spin_square0
from pyscf import lib
from pyscf.lib import numpy_helper
from scipy import special, linalg
from mrh.util.io import prettyprint_ndarray
from functools import reduce
from mrh.lib.helper import load_library
from pyscf.fci.direct_spin1_symm import _gen_strs_irrep
libcsf = load_library ('libcsf')

class CSFTransformer (lib.StreamObject):
    def __init__(self, norb, neleca, nelecb, smult, orbsym=None, wfnsym=None):
        self._norb = self._neleca = self._nelecb = self._smult = self._orbsym = None
        self.wfnsym = wfnsym
        self._update_spin_cache (norb, neleca, nelecb, smult)
        self.orbsym = orbsym

    def project_civec (self, detarr, order='C', normalize=True, return_norm=False):
        pass

    def vec_det2csf (self, civec, order='C', normalize=True, return_norm=False):
        vec_on_cols = (order.upper () == 'F')
        civec, norm = transform_civec_det2csf (civec, self._norb, self._neleca, 
            self._nelecb, self._smult, csd_mask=self.csd_mask, do_normalize=normalize,
            vec_on_cols=vec_on_cols)
        civec = self.pack_csf (civec, order=order)
コード例 #5
0
from pyscf import lib
import numpy as np
from scipy import linalg
from mrh.lib.helper import load_library
import ctypes, time
libsint = load_library('libsint')


class sparsedf_array(np.ndarray):
    def __new__(cls, inp, nmo=None):
        assert (inp.flags['C_CONTIGUOUS'] or inp.flags['F_CONTIGUOUS'])
        self = np.asarray(inp).view(cls)
        self.naux = self.shape[0]
        self.nmo = nmo
        if self.nmo is None:
            if self.ndim == 2:
                nmo1 = 1
                off = 0
                for self.nmo1 in range(1, self.shape[1]):
                    off += nmo1
                    if off == self.shape[1]: break
                    nmo1 += 1
                self.nmo = (nmo1, nmo1)
            else:
                self.nmo = self.shape[1:]
        return self

    def __array_finalize__(self, obj):
        if obj is None: return
        self.naux = getattr(obj, 'naux', None)
        self.nmo = getattr(obj, 'nmo', None)