예제 #1
0
파일: qc_base.py 프로젝트: akpc/margarita
    def do_make_molecule(self, *args, **kwargs):
        """

        Parameters
        ----------
        args
        kwargs

        Returns
        -------

        """
        # integrals need to be passed in base class
        assert ("one_body_integrals" in kwargs)
        assert ("two_body_integrals" in kwargs)
        assert ("nuclear_repulsion" in kwargs)
        assert ("n_orbitals" in kwargs)

        molecule = MolecularData(**self.parameters.molecular_data_param)

        molecule.one_body_integrals = kwargs["one_body_integrals"]
        molecule.two_body_integrals = kwargs["two_body_integrals"]
        molecule.nuclear_repulsion = kwargs["nuclear_repulsion"]
        molecule.n_orbitals = kwargs["n_orbitals"]
        molecule.save()
        return molecule
예제 #2
0
파일: qc_base.py 프로젝트: akpc/margarita
    def make_molecule(self, *args, **kwargs) -> MolecularData:
        """Creates a molecule in openfermion format by running psi4 and extracting the data
        Will check for previous outputfiles before running
        Will not recompute if a file was found

        Parameters
        ----------
        parameters :
            An instance of ParametersQC, which also holds an instance of ParametersPsi4 via parameters.psi4
            The molecule will be saved in parameters.filename, if this file exists before the call the molecule will be imported from the file

        Returns
        -------
        type
            the molecule in openfermion.MolecularData format

        """
        molecule = MolecularData(**self.parameters.molecular_data_param)
        # try to load

        do_compute = True
        try:
            import os
            if os.path.exists(self.parameters.filename):
                molecule.load()
                do_compute = False
        except OSError:
            do_compute = True

        if do_compute:
            molecule = self.do_make_molecule(*args, **kwargs)

        molecule.save()
        return molecule
예제 #3
0
def create_molecule():

    geometry = make_geometry()
    basis = 'sto-3g'
    charge = 0
    multiplicity = 1
    moleculefilename = '/app/moleculefile.hdf5'

    molecule = MolecularData(geometry,
                             basis,
                             multiplicity,
                             charge,
                             description,
                             filename=moleculefilename)

    # openfermion's run_psi4
    molecule = run_psi4(molecule,
                        run_scf=1,
                        run_mp2=1,
                        run_cisd=0,
                        run_ccsd=0,
                        run_fci=0,
                        verbose=1,
                        tolerate_error=1)
    molecule.save()
예제 #4
0
def generate_and_save(geometry, basis, multiplicity, charge, description,
                      mfilename):
    # initialize the molecule
    molecule = MolecularData(geometry,
                             basis,
                             multiplicity,
                             charge,
                             description=description,
                             filename=mfilename)
    molecule.save()

    # compute the active space integrals
    print('-computing integrals-')
    molecule = run_psi4(molecule,
                        run_mp2=True,
                        run_cisd=True,
                        run_ccsd=True,
                        run_fci=True)

    print(molecule.filename)
    print(molecule.two_body_integrals)
    print(molecule.canonical_orbitals)
    molecule.save()
    print('Successful generation')
예제 #5
0
    # Add points for a full dissociation curve from 0.1 to 3.0 angstroms
    spacings += [0.1 * r for r in range(1, 30)]

    # Set run options
    run_scf = 1
    run_mp2 = 1
    run_cisd = 1
    run_ccsd = 1
    run_fci = 1
    verbose = 1
    tolerate_error = 1

    # Run Diatomic Curve
    for spacing in spacings:
        description = "{:.2f}".format(spacing)
        geometry = [['Be', [0, 0, 0]], ['H', [0, 0, spacing]],
                    ['H', [0, 0, -spacing]]]
        molecule = MolecularData(geometry, basis, multiplicity, charge,
                                 description)

        molecule = run_psi4(molecule,
                            run_scf=run_scf,
                            run_mp2=run_mp2,
                            run_cisd=run_cisd,
                            run_ccsd=run_ccsd,
                            run_fci=run_fci,
                            verbose=verbose,
                            tolerate_error=tolerate_error)
        molecule.save()