示例#1
0
    def setUp(self):
        self.assertDictEqual.__self__.maxDiff = None

        # generate molecule
        molecule = Structure(coordinates=[[0.0, 1.0, 0.0], [0.0, 0.0, 1.0],
                                          [0.0, 0.0, -1.0]],
                             symbols=['O', 'H', 'H'],
                             charge=0,
                             multiplicity=1)

        # optimization
        txt_input = create_qchem_input(molecule,
                                       jobtype='opt',
                                       exchange='hf',
                                       basis='sto-3g',
                                       geom_opt_tol_gradient=300,
                                       geom_opt_tol_energy=100,
                                       geom_opt_coords=-1,
                                       geom_opt_tol_displacement=1200)

        parsed_data = get_output_from_qchem(txt_input,
                                            processors=4,
                                            parser=basic_optimization,
                                            force_recalculation=recalculate,
                                            store_full_output=True)

        self.molecule = parsed_data['optimized_molecule']
示例#2
0
    def test_eth_00_ras22(self):

        rasci = dict(self.rem)
        if do_alpha_beta:
            rasci.update({'ras_elec_alpha': 1,
                          'ras_elec_beta': 1})

        # create qchem input
        txt_input = create_qchem_input(self.molecule, **rasci)

        # calculate and parse qchem output
        output = get_output_from_qchem(txt_input,
                                       processors=4,
                                       store_full_output=True,
                                       force_recalculation=recalculate)
        data = parser_rasci(output)

        filename = self.__class__.__name__ + '_ras22.yaml'

        # create reference file
        if ctrl_print:
            with open(filename, 'w') as outfile:
                yaml.dump(data, outfile, default_flow_style=False, allow_unicode=True)

        with open(filename, 'r') as stream:
            data_loaded = yaml.load(stream, Loader=yaml.Loader)

        data = standardize_dictionary(data, decimal=2)

        #print(data)

        print(data_loaded)
        data_loaded = standardize_dictionary(data_loaded, decimal=2)

        self.assertDictEqual(data, data_loaded)
示例#3
0
    def test_srdft(self):

        # create qchem input
        qc_input = create_qchem_input(
            self.molecule,
            jobtype='sp',
            exchange='hf',
            correlation='rasci',
            basis='6-31G(d,p)',
            ras_act=2,
            ras_elec=2,
            ras_spin_mult=0,
            ras_roots=2,
            ras_do_hole=True,
            ras_sts_tm=True,
            # rasci sr-dft
            ras_omega=400,
            ras_srdft_cor='srpw92',
            ras_srdft_exc='srpbe',
            ras_natorb=False,
            set_iter=30,
            ras_srdft_damp=0.5)

        #from pyqchem.cache import SqlCache as CacheSystem

        #cache = CacheSystem()
        #cache.list_database()
        #output = cache.retrieve_calculation_data(qc_input, 'fullout')
        #print(output)

        # calculate and parse qchem output
        output = get_output_from_qchem(qc_input,
                                       processors=4,
                                       force_recalculation=recalculate,
                                       store_full_output=True)
        print(output)
        data = parser_rasci(output)

        filename = dir_path + '/' + self.__class__.__name__ + '_srdft.yaml'

        if remake_tests:
            with open(filename, 'w') as outfile:
                yaml.dump(data,
                          outfile,
                          default_flow_style=False,
                          allow_unicode=True)

        data = standardize_dictionary(data, decimal=2)

        with open(filename, 'r') as stream:
            data_loaded = yaml.load(stream, Loader=yaml.Loader)

        print(data_loaded)
        data_loaded = standardize_dictionary(data_loaded, decimal=2)

        self.assertDictEqual(data, data_loaded)
示例#4
0
    def test_srdft(self):

        # create qchem input
        txt_input = create_qchem_input(
            self.molecule,
            jobtype='sp',
            exchange='hf',
            correlation='rasci',
            basis='6-31G(d,p)',
            ras_act=4,
            ras_elec=4,
            ras_spin_mult=0,
            ras_roots=6,
            ras_do_hole=True,
            ras_sts_tm=True,
            # rasci sr-dft
            ras_omega=300,
            ras_srdft_cor='srpbe',
            ras_srdft_exc='srlsda',
            ras_natorb=False,
            set_iter=30,
            ras_srdft_damp=0.5)

        print(txt_input.get_txt())

        # calculate and parse qchem output
        output = get_output_from_qchem(txt_input,
                                       processors=4,
                                       force_recalculation=recalculate,
                                       store_full_output=True)

        print(output)
        data = parser_rasci(output)

        print(data)

        filename = dir_path + '/' + self.__class__.__name__ + '_srdft.yaml'

        if remake_tests:
            with open(filename, 'w') as outfile:
                yaml.dump(data,
                          outfile,
                          default_flow_style=False,
                          allow_unicode=True)

        data = standardize_dictionary(data)

        with open(filename, 'r') as stream:
            data_loaded = yaml.load(stream, Loader=yaml.Loader)

        print(data_loaded)
        data_loaded = standardize_dictionary(data_loaded)

        self.assertDictEqual(data, data_loaded)
示例#5
0
    def test_rasci(self):
        # create qchem input
        txt_input = create_qchem_input(self.molecule,
                                       jobtype='sp',
                                       exchange='hf',
                                       correlation='rasci',
                                       basis='sto-3g',
                                       ras_act=4,
                                       ras_elec=4,
                                       ras_spin_mult=1,
                                       ras_roots=6,
                                       ras_print=5,
                                       ras_do_hole=True,
                                       ras_sts_tm=True)

        # calculate and parse qchem output
        output = get_output_from_qchem(txt_input,
                                       processors=4,
                                       force_recalculation=recalculate,
                                       store_full_output=True)
        print(output)
        data = parser_rasci(output)

        print(data)

        filename = dir_path + '/' + self.__class__.__name__ + '_rasci.yaml'

        if remake_tests:
            with open(filename, 'w') as outfile:
                yaml.dump(data,
                          outfile,
                          default_flow_style=False,
                          allow_unicode=True)

        data = standardize_dictionary(data, decimal=2)

        with open(filename, 'r') as stream:
            data_loaded = yaml.load(stream, Loader=yaml.Loader)

        print(data_loaded)
        data_loaded = standardize_dictionary(data_loaded, decimal=2)

        self.assertDictEqual(data, data_loaded)
示例#6
0
    def test_eth_00_ras44(self):

        rasci = dict(self.rem)
        rasci.update({'ras_act': 4,
                      'ras_elec': 4,
                      'ras_occ': 6})
        if do_alpha_beta:
            rasci.update({'ras_elec_alpha': 2,
                          'ras_elec_beta': 2})


        # create qchem input
        txt_input = create_qchem_input(self.molecule, **rasci)

        # calculate and parse qchem output
        output = get_output_from_qchem(txt_input, processors=4)
        print(output)
        data = basic_rasci(output)

        print(data)

        filename = self.__class__.__name__ + '_ras44.yaml'

        # creat reference file
        if ctrl_print:
            with open(filename, 'w') as outfile:
                yaml.dump(data, outfile, default_flow_style=False, allow_unicode=True)

        with open(filename, 'r') as stream:
            data_loaded = yaml.safe_load(stream)

        data = standardize_dictionary(data)

        print(data_loaded)
        data_loaded = standardize_dictionary(data_loaded)

        self.assertDictEqual(data, data_loaded)
示例#7
0
    'H', 'H', 'H'
]

molecule = Structure(coordinates=coordinates,
                     symbols=symbols,
                     charge=0,
                     multiplicity=1)

molecule.get_coordinates()

print('optimize molecule')

txt_input = create_qchem_input(molecule,
                               jobtype='opt',
                               method='b3lyp',
                               basis='cc-pVDZ',
                               geom_opt_tol_gradient=50,
                               geom_opt_coords=-1,
                               geom_opt_tol_displacement=800)

parsed_data = get_output_from_qchem(txt_input,
                                    processors=4,
                                    use_mpi=True,
                                    parser=basic_optimization,
                                    force_recalculation=False)

#parsed_data = basic_optimization(data)
opt_molecule = parsed_data['optimized_molecule']

print(opt_molecule)
示例#8
0
                           [0.00000, -2.49029, 0.00000],
                           [1.21479, -0.70136, 0.00000],
                           [2.15666, -1.24515, 0.00000],
                           [1.21479, 0.70136, 0.00000],
                           [2.15666, 1.24515, 0.00000]]

    symbols = ['C', 'H', 'C', 'H', 'C', 'H', 'C', 'H', 'C', 'H', 'C', 'F']

    benzene_coordinates = np.array(benzene_coordinates)
    molecule = Structure(coordinates=benzene_coordinates,
                         symbols=symbols,
                         charge=0)

    parameters = {'jobtype': 'sp', 'exchange': 'hf', 'basis': '6-31G'}

    qc_input = create_qchem_input(molecule, **parameters)

    _, _, fchk_data = get_output_from_qchem(qc_input,
                                            processors=4,
                                            force_recalculation=True,
                                            read_fchk=True)

    from pyqchem.file_io import build_fchk
    open('test.fchk', 'w').write(build_fchk(fchk_data))

    mo_coeff = _set_zero_to_coefficients(fchk_data['basis'],
                                         fchk_data['coefficients'],
                                         range(6, 12))
    fchk_data['coefficients'] = mo_coeff

    structure = fchk_data['structure']
示例#9
0
# define molecule
coordinates = [[0.0, 1.0, 0.0], [0.0, 0.0, 1.0], [0.0, 0.0, -1.0]]

symbols = ['O', 'H', 'H']

molecule = Structure(coordinates=coordinates,
                     symbols=symbols,
                     charge=0,
                     multiplicity=1)

print('Initial structure')
print(molecule)

# calculation
qc_input = create_qchem_input(molecule,
                              jobtype='freq',
                              exchange='hf',
                              basis='sto-3g')

out, electronic_structure = get_output_from_qchem(
    qc_input,
    processors=4,
    read_fchk=True,
    force_recalculation=True,
    remote=remote_data,  # Set remote data
    parser=basic_frequencies)

# Show output
print(out)

# Show Electronic structure data
print(electronic_structure)
示例#10
0
symbols = ['O', 'H', 'H']

molecule = Structure(coordinates=coordinates,
                     symbols=symbols,
                     charge=0,
                     multiplicity=1)

print('Initial structure')
print(molecule)

# optimization
qc_input = create_qchem_input(molecule,
                              jobtype='opt',
                              exchange='hf',
                              basis='sto-3g',
                              geom_opt_tol_gradient=300,
                              geom_opt_tol_energy=100,
                              geom_opt_coords=-1,
                              geom_opt_tol_displacement=1200)

parsed_data, electronic_structure = get_output_from_qchem(
    qc_input, processors=4, parser=basic_optimization, read_fchk=True)

opt_molecule = parsed_data['optimized_molecule']

print('Optimized structure')
print(opt_molecule)

# frequencies calculation
qc_input = create_qchem_input(opt_molecule,
                              jobtype='freq',
示例#11
0
                         charge=0,
                         multiplicity=1)

    # print(molecule)

    for x in range(len(geom_opt_max_cycles_l)):

        # create_qchem_input is the function responsible for creating the input file for the calculation
        # This should mostly be left unchanged as the Job object takes care of passing in the correct parameters and if a
        # change is required it should be done using the input_variation function in the job class

        txt_input = create_qchem_input(
            molecule,
            jobtype=Test.jobtype,
            gui=Test.gui,
            basis=Test.basis,
            method=Test.method,
            max_scf_cycles=Test.max_scf_cycles,
            geom_opt_max_cycles=Test.geom_opt_max_cycles,
            scf_convergence=Test.scf_convergence)

        txt_input_freq = create_qchem_input(
            molecule,
            jobtype='freq',
            gui=Test.gui,
            basis=Test.basis,
            method=Test.method,
            max_scf_cycles=Test.max_scf_cycles,
            geom_opt_max_cycles=Test.geom_opt_max_cycles,
            scf_convergence=Test.scf_convergence)
示例#12
0
                [3.7, -0.92281, -1.22792], [3.7, 0.92281, -1.22792]]

symbols = ['C', 'C', 'H', 'H', 'H', 'H', 'C', 'C', 'H', 'H', 'H', 'H']

range_f1 = range(0, 6)
range_f2 = range(6, 12)

# create molecule
molecule = Structure(coordinates=dimer_ethene,
                     symbols=symbols,
                     charge=0,
                     multiplicity=1)

# create Q-Chem input
qc_input = create_qchem_input(molecule,
                              jobtype='sp',
                              exchange='hf',
                              basis='6-31G')

print(qc_input.get_txt())
# get data from Q-Chem calculation
output, electronic_structure = get_output_from_qchem(qc_input,
                                                     processors=4,
                                                     force_recalculation=False,
                                                     read_fchk=True,
                                                     fchk_only=True)

# store original fchk info in file
open('test.fchk', 'w').write(build_fchk(electronic_structure))

# get symmetry classification
electronic_structure_f1 = crop_electronic_structure(electronic_structure,
示例#13
0
molecule = Structure(coordinates=coordinates,
                     symbols=symbols,
                     charge=0,
                     multiplicity=1)

print('Initial structure')
print(molecule)

# optimization
qc_input = create_qchem_input(molecule,
                              jobtype='sp',
                              exchange='hf',
                              basis='sto-3g',
                              unrestricted=True,
                              solvent_method='pcm',
                              solvent_params={'Dielectric': 8.93},  # Cl2CH2
                              pcm_params={'Theory': 'CPCM',
                                          'Method': 'SWIG',
                                          'Solver': 'Inversion',
                                          'Radii': 'Bondi'}
                              )


data, electronic_structure = get_output_from_qchem(qc_input,
                                                   force_recalculation=True,
                                                   processors=4,
                                                   parser=basic_parser_qchem,
                                                   read_fchk=True)


print('scf energy', data['scf_energy'], 'H')