コード例 #1
0
    def _init_upcast_C(self, oldcalc, calc):
        # type: (calcid, calcid)
        # Initialize a new namespace for `calc` with an opcast from `oldcalc`.
        assert oldcalc.V == calc.V and oldcalc.B == calc.B
        core.set_local_option('SCF', 'GUESS', 'READ')
        new_data = self._basis_projection(oldcalc, calc)
        newfn = self._fmt_mo_fn(calc)
        np.savez(newfn, **new_data)

        psi_scratch = core.IOManager.shared_object().get_default_path()
        extras.register_numpy_file(os.path.join(psi_scratch, newfn))
コード例 #2
0
    def _init_addghost_C(self, oldcalc, calc):
        # print('Adding ghost %s->%s' % (oldcalc, calc))

        old_filename = self._fmt_mo_fn(oldcalc)

        wfn = core.Wavefunction.from_file(old_filename)

        Ca_occ = wfn.Ca_subset('SO', 'OCC')
        Cb_occ = wfn.Cb_subset('SO', 'OCC')

        m1_nso = self.wfn_cache[('m1', 'm', oldcalc.Z)].nso()
        m2_nso = self.wfn_cache[('m2', 'm', oldcalc.Z)].nso()
        m1_nalpha = self.wfn_cache[('m1', 'm', oldcalc.Z)].nalpha()
        m2_nalpha = self.wfn_cache[('m2', 'm', oldcalc.Z)].nalpha()
        m1_nbeta = self.wfn_cache[('m1', 'm', oldcalc.Z)].nbeta()
        m2_nbeta = self.wfn_cache[('m2', 'm', oldcalc.Z)].nbeta()

        Ca_d = np.zeros((m1_nso + m2_nso, m1_nso + m2_nso))
        Cb_d = np.zeros((m1_nso + m2_nso, m1_nso + m2_nso))
        if calc.V == 'm1':
            Ca_d[:m1_nso, :m1_nalpha] = Ca_occ
            Cb_d[:m1_nso, :m1_nbeta] = Cb_occ
        elif calc.V == 'm2':
            Ca_d[-m2_nso:, :m2_nalpha] = Ca_occ
            Cb_d[-m2_nso:, :m2_nbeta] = Cb_occ

        wfn_new = wfn.to_file()
        wfn_new['matrix']['Ca'] = Ca_d
        wfn_new['matrix']['Cb'] = Cb_d
        wfn_new['dimension']['nsopi'] = (m1_nso + m2_nso, )
        wfn_new['dimension']['nmopi'] = (m1_nso + m2_nso, )
        wfn_new['int']['nso'] = m1_nso + m2_nso
        wfn_new['int']['nmo'] = m1_nso + m2_nso

        wfn_new = core.Wavefunction.from_file(wfn_new)

        psi_scratch = core.IOManager.shared_object().get_default_path()
        write_filename = os.path.join(
            psi_scratch,
            os.path.split(
                os.path.abspath(core.get_writer_file_prefix(
                    self.fmt_ns(calc))))[1] + ".180.npy")
        wfn_new.to_file(write_filename)
        extras.register_numpy_file(write_filename)
        core.set_local_option('SCF', 'GUESS', 'READ')
コード例 #3
0
    def _init_addghost_C(self, oldcalc, calc):
        # print('Adding ghost %s->%s' % (oldcalc, calc))

        old_filename = self._fmt_mo_fn(oldcalc)
        data = np.load(old_filename)
        Ca_occ = core.Matrix.np_read(data, "Ca_occ")
        Cb_occ = core.Matrix.np_read(data, "Cb_occ")

        m1_nso = self.wfn_cache[('m1', 'm', oldcalc.Z)].nso()
        m2_nso = self.wfn_cache[('m2', 'm', oldcalc.Z)].nso()
        m1_nalpha = self.wfn_cache[('m1', 'm', oldcalc.Z)].nalpha()
        m2_nalpha = self.wfn_cache[('m2', 'm', oldcalc.Z)].nalpha()
        m1_nbeta = self.wfn_cache[('m1', 'm', oldcalc.Z)].nbeta()
        m2_nbeta = self.wfn_cache[('m2', 'm', oldcalc.Z)].nbeta()

        if calc.V == 'm1':
            Ca_occ_d = core.Matrix('Ca_occ', (m1_nso + m2_nso), m1_nalpha)
            Ca_occ_d.np[:m1_nso, :] = Ca_occ.np[:, :]
            Cb_occ_d = core.Matrix('Cb_occ', (m1_nso + m2_nso), m1_nbeta)
            Cb_occ_d.np[:m1_nso, :] = Cb_occ.np[:, :]
        elif calc.V == 'm2':
            Ca_occ_d = core.Matrix('Ca_occ', (m1_nso + m2_nso), m2_nalpha)
            Ca_occ_d.np[-m2_nso:, :] = Ca_occ.np[:, :]

            Cb_occ_d = core.Matrix('Cb_occ', (m1_nso + m2_nso), m2_nbeta)
            Cb_occ_d.np[-m2_nso:, :] = Cb_occ.np[:, :]

        data_dict = dict(data)
        data_dict.update(Ca_occ_d.np_write(prefix='Ca_occ'))
        data_dict.update(Cb_occ_d.np_write(prefix='Cb_occ'))

        psi_scratch = core.IOManager.shared_object().get_default_path()
        write_filename = os.path.join(
            psi_scratch,
            os.path.split(
                os.path.abspath(core.get_writer_file_prefix(
                    self.fmt_ns(calc))))[1] + ".180.npz")
        np.savez(write_filename, **data_dict)
        extras.register_numpy_file(write_filename)
        core.set_local_option('SCF', 'GUESS', 'READ')