예제 #1
0
파일: uhf.py 프로젝트: armunoz/pyscf
def dip_moment(mol, dm, unit_symbol='Debye', verbose=logger.NOTE):
    r''' Dipole moment calculation

    .. math::

        \mu_x = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|x|\mu) + \sum_A Q_A X_A\\
        \mu_y = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|y|\mu) + \sum_A Q_A Y_A\\
        \mu_z = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|z|\mu) + \sum_A Q_A Z_A

    where :math:`\mu_x, \mu_y, \mu_z` are the x, y and z components of dipole
    moment

    Args:
         mol: an instance of :class:`Mole`

         dm : a list of 2D ndarrays
              a list of density matrices

    Return:
        A list: the dipole moment on x, y and z component
    '''
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        return hf.dip_moment(mol, dm, unit_symbol, verbose)
    else:
        return hf.dip_moment(mol, dm[0] + dm[1], unit_symbol, verbose)
예제 #2
0
파일: uhf.py 프로젝트: eronca/pyscf
def dip_moment(mol, dm, unit_symbol='Debye', verbose=logger.NOTE):
    r''' Dipole moment calculation

    .. math::

        \mu_x = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|x|\mu) + \sum_A Q_A X_A\\
        \mu_y = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|y|\mu) + \sum_A Q_A Y_A\\
        \mu_z = -\sum_{\mu}\sum_{\nu} P_{\mu\nu}(\nu|z|\mu) + \sum_A Q_A Z_A

    where :math:`\mu_x, \mu_y, \mu_z` are the x, y and z components of dipole
    moment

    Args:
         mol: an instance of :class:`Mole`

         dm : a list of 2D ndarrays
              a list of density matrices

    Return:
        A list: the dipole moment on x, y and z component
    '''
    if isinstance(dm, numpy.ndarray) and dm.ndim == 2:
        return hf.dip_moment(mol, dm, unit_symbol, verbose)
    else:
        return hf.dip_moment(mol, dm[0]+dm[1], unit_symbol, verbose)
예제 #3
0
파일: ase.py 프로젝트: theorychemyang/pyscf
 def calculate(self,
               atoms=None,
               properties=['energy', 'forces', 'dipole'],
               system_changes=[
                   'positions', 'numbers', 'cell', 'pbc', 'charges',
                   'magmoms'
               ]):
     Calculator.calculate(self, atoms, properties, system_changes)
     mol = gto.Mole()
     atoms = self.atoms.get_chemical_symbols()
     positions = self.atoms.get_positions()
     atom_pyscf = []
     for i in range(len(atoms)):
         if atoms[i] == 'D':
             atom_pyscf.append(['H@2', tuple(positions[i])])
         else:
             atom_pyscf.append(['%s' % (atoms[i]), tuple(positions[i])])
     mol.build(atom=atom_pyscf,
               basis=self.parameters.basis,
               charge=self.parameters.charge,
               spin=self.parameters.spin)
     if self.parameters.spin != 0:
         mf = dft.UKS(mol)
     else:
         mf = dft.RKS(mol)
     mf.xc = self.parameters.xc
     self.results['energy'] = mf.scf() * Hartree
     g = mf.Gradients()
     self.results['forces'] = -g.grad() * Hartree / Bohr
     self.results['dipole'] = dip_moment(mol, mf.make_rdm1())
예제 #4
0
파일: ase.py 프로젝트: theorychemyang/pyscf
    def calculate(self,
                  atoms=None,
                  properties=['energy', 'forces', 'dipole'],
                  system_changes=[
                      'positions', 'numbers', 'cell', 'pbc', 'charges',
                      'magmoms'
                  ]):
        Calculator.calculate(self, atoms, properties, system_changes)
        mol = neo.Mole()
        atoms = self.atoms.get_chemical_symbols()
        positions = self.atoms.get_positions()
        atom_pyscf = []
        for i in range(len(atoms)):
            if atoms[i] == 'Mu':
                atom_pyscf.append(['H@0', tuple(positions[i])])
            elif atoms[i] == 'D':
                atom_pyscf.append(['H@2', tuple(positions[i])])
            else:
                atom_pyscf.append(
                    ['%s%i' % (atoms[i], i),
                     tuple(positions[i])])
        mol.build(quantum_nuc=self.parameters.quantum_nuc,
                  atom=atom_pyscf,
                  basis=self.parameters.basis,
                  charge=self.parameters.charge,
                  spin=self.parameters.spin)
        if self.parameters.spin == 0:
            mf = neo.CDFT(mol)
        else:
            mf = neo.CDFT(mol, unrestricted=True)
        mf.mf_elec.xc = self.parameters.xc
        self.results['energy'] = mf.scf() * Hartree
        g = mf.Gradients()
        self.results['forces'] = -g.grad() * Hartree / Bohr

        dip_elec = dip_moment(
            mol.elec,
            mf.mf_elec.make_rdm1())  # dipole of electrons and classical nuclei
        dip_nuc = 0
        for i in range(len(mf.mf_nuc)):
            ia = mf.mf_nuc[i].mol.atom_index
            dip_nuc += mol.atom_charge(
                ia) * mf.mf_nuc[i].nuclei_expect_position * nist.AU2DEBYE

        self.results['dipole'] = dip_elec + dip_nuc
예제 #5
0
def dip_moment(mol, dm, unit_symbol='Debye', verbose=logger.NOTE):
    nao = mol.nao_nr()
    dma = dm[:nao, :nao]
    dmb = dm[nao:, nao:]
    return hf.dip_moment(mol, dma + dmb, unit_symbol, verbose)