Exemple #1
0
 def energy_gradient(self, new_coords):
     #Defining molecule
     molecule = Structure(coordinates=[[0.0, 0.0, 0.0],
                                       [0.0, 0.0, 0.9],
                                       [0.0, 0.0, -0.9]],
                          symbols=['O', 'H', 'H'],
                          charge=0,
                          multiplicity=1)
     
     #Preparing QCHEM input
     qc_input1 = QchemInput(molecule,
                           jobtype='force',
                           exchange='hf',
                           basis='6-31G')
Exemple #2
0
from pyqchem import get_output_from_qchem
from pyqchem.parsers.basic import basic_parser_qchem
import numpy as np

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

#Preparing QCHEM input
qc_input1 = QchemInput(molecule,
                      jobtype='force',
                      exchange='hf',
                      basis='6-31G',
                      extra_rem_keywords={'multipole_field': 'x 0.001'},
                      extra_sections=['$multipole_field \n x 0.001 \n $end'])
                        

string = '$multipole_field \n   x 0.001 \n$end'
print(string)
exit()
print(type(qc_input1))
inp = qc_input1.get_txt()
qc_input_test = 
print(inp)
exit()

qc_input2 = QchemInput(molecule,
                      jobtype='freq',
Exemple #3
0
# molecule
ethene = [[0.0, 0.0000, 0.65750], [0.0, 0.0000, -0.65750],
          [0.0, 0.92281, 1.22792], [0.0, -0.92281, 1.22792],
          [0.0, -0.92281, -1.22792], [0.0, 0.92281, -1.22792]]

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

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

# create Q-Chem input
qc_input = QchemInput(molecule, jobtype='sp', exchange='hf', basis='sto-3g')

print(qc_input.get_txt())

# get data from Q-Chem calculation
output = get_output_from_qchem(qc_input,
                               processors=1,
                               force_recalculation=True,
                               remote=remote_data_pc,
                               scratch='/Users/abel/Scratch/export/',
                               parser=basic_parser_qchem)

# Get data
print('OUTPUT')
print(output)
Exemple #4
0
symbols = ['C', 'O', 'C', 'C', 'C', 'C', 'C', 'H', 'C', 'H', 'H', 'H',
           'C', 'C', 'C', 'C', 'C', 'H', 'C', 'H', 'H', 'H', 'C', 'H', 'H']

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

basis_custom_repo = get_basis_from_ccRepo(molecule, 'cc-pVDZ')

qc_input = QchemInput(molecule,
                      jobtype='opt',
                      exchange='b3lyp',
                      basis='sto-3g',
                      geom_opt_tol_gradient=300,
                      geom_opt_tol_energy=100,
                      geom_opt_tol_displacement=1200,
                      geom_opt_max_cycles=50,
                      # n_frozen_core=0,
                      )

try:
    parsed_data, electronic_structure = get_output_from_qchem(qc_input,
                                                              processors=4,
                                                              parser=basic_optimization,
                                                              read_fchk=True,
                                                              store_full_output=True
                                                              )
except OutputError as e:
    print(e.error_lines)
    exit()
Exemple #5
0
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)

# Initial calculation with STO-3G basis
qc_input = QchemInput(
    molecule,
    jobtype='opt',
    exchange='hf',
    basis='sto-3g',
)

parsed_data, ee = get_output_from_qchem(qc_input,
                                        processors=4,
                                        parser=basic_optimization,
                                        force_recalculation=False,
                                        read_fchk=True)

opt_molecule = parsed_data['optimized_molecule']

print('Optimized structure')
print(opt_molecule)
print('Final energy:', parsed_data['energy'])
Exemple #6
0
               [ 0.3711605704,    1.0377672206,    0.0000000000],
               [-0.5903438458,   -0.0311449516,    0.0000000000]]

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

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

# Transition state optimization
qc_input = QchemInput(molecule,
                      jobtype='ts',
                      exchange='hf',
                      basis='sto-3g',
                      geom_opt_tol_gradient=300,
                      geom_opt_tol_energy=100,
                      geom_opt_tol_displacement=1200,
                      geom_opt_max_cycles=50,  # reduce this number to test not convergence case
                      )

opt_data, ee = get_output_from_qchem(qc_input,
                                     processors=4,
                                     parser=basic_optimization,
                                     force_recalculation=False,
                                     read_fchk=True,
                                     store_full_output=True)


print('Transition state')
print(opt_data['optimized_molecule'])
Exemple #7
0
                [ 1.2321, -0.9289,  0.0000],
                [-1.2321,  0.9289,  0.0000],
                [-1.2321, -0.9289,  0.0000]]

symbols_monomer = ['C', 'C', 'H', 'H', 'H', 'H']

monomer = Structure(coordinates=coor_monomer,
                    symbols=symbols_monomer,
                    charge=0,
                    multiplicity=1)

# optimization qchem input
qc_input = QchemInput(monomer,
                      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(qc_input,
                                    processors=4,
                                    parser=basic_optimization)

opt_monomer = parsed_data['optimized_molecule']

print('Optimized monomer structure')
print(opt_monomer)

# Build dimer from monomer
coor_monomer2 = np.array(opt_monomer.get_coordinates())
Exemple #8
0
                 [-0.53741536, -3.05918866, 0.04995793],
                 [-2.14073783, -2.12969357, 0.04016267],
                 [-0.39112115, -0.95974916, 0.00012984],
                 [0.67884827, -0.96181542, -0.00769025],
                 [-1.15875076, 0.37505495, -0.02522296],
                 [-0.62213437, 1.30041753, -0.05065831],
                 [-2.51391203, 0.37767199, -0.01531698],
                 [-3.04726506, 1.30510083, -0.03293196],
                 [-3.05052841, -0.54769055, 0.01011971]],
    symbols=['C', 'H', 'H', 'C', 'H', 'C', 'H', 'C', 'H', 'H'])

# create qchem input
qc_input = QchemInput(
    molecule_cis,
    jobtype='sp',
    exchange='hf',
    basis='sto-3g',
    #sym_ignore=True
)

# calculate and parse qchem output
data_cis, ee_cis = get_output_from_qchem(qc_input,
                                         read_fchk=True,
                                         processors=4,
                                         parser=basic_parser_qchem)

molecule_trans = Structure(
    coordinates=[[-1.06908233, -2.13352097, -0.00725330],
                 [-0.53502155, -3.05996561, -0.04439369],
                 [-2.13778918, -2.13379901, 0.04533562],
                 [-0.39193053, -0.95978774, -0.02681816],
Exemple #9
0
        self._conn.close()

        return self._calculation_data

    @calculation_data.setter
    def calculation_data(self, calculation_data):

        self._conn = sqlite3.connect(self._calculation_data_filename)

        for key, value in calculation_data.items():
            self._conn.execute(
                "INSERT or REPLACE into DATA_TABLE (input_hash, parser, qcdata)  VALUES (?, ?, ?)",
                (key[0], key[1], pickle.dumps(value, protocol=2)))

        self._conn.commit()
        self._conn.close()


if __name__ == '__main__':
    a = SqlCache()
    b = SqlCache()

    #b.redefine_calculation_data_filename('calculation_data2.db')

    from pyqchem import QchemInput, Structure

    input = QchemInput(Structure(coordinates=[[0, 0, 0]], symbols=['X']))

    b.store_calculation_data(input, 'key1', {'entry1': 454, 'entry2': 2323})
    data = b.retrieve_calculation_data(input, 'key1')
    print(data)
Exemple #10
0
                [ 1.2321, -0.9289,  0.0000],
                [-1.2321,  0.9289,  0.0000],
                [-1.2321, -0.9289,  0.0000]]

symbols_monomer = ['C', 'C', 'H', 'H', 'H', 'H']

monomer = Structure(coordinates=coor_monomer,
                    symbols=symbols_monomer,
                    charge=0,
                    multiplicity=1)

# optimization qchem input
qc_input = QchemInput(monomer,
                      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(qc_input,
                                    processors=4,
                                    parser=basic_optimization)

opt_monomer = parsed_data['optimized_molecule']

print('Optimized monomer structure')
print(opt_monomer)

# Build dimer from monomer
coor_monomer2 = np.array(opt_monomer.get_coordinates())
Exemple #11
0
# Simple single point calculation
from pyqchem import get_output_from_qchem, QchemInput, Structure
from pyqchem.parsers.basic import basic_parser_qchem
import numpy as np

molecule = Structure(coordinates=[[0.0, 0.0, 0.0],
                                  [0.0, 0.0, 0.9]],
                     symbols=['O', 'H'],
                     charge=-1,
                     multiplicity=1)

# create qchem input
qc_input = QchemInput(molecule,
                      jobtype='sp',
                      exchange='hf',
                      basis='6-31G',
                      unrestricted=True)

# calculate and parse qchem output

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


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

print('Orbital energies (H)')
print('  {:^10} {:^10}'.format('alpha', 'beta'))
Exemple #12
0
for x_dist in scan_range:

    water = [[x_dist, 0.00000000e+00, 2.40297090e-01],
             [-1.43261539e+00, -1.75444785e-16, -9.61188362e-01],
             [1.43261539e+00, 1.75444785e-16, -9.61188362e-01]]
    water = np.array(water) * 0.529177249

    molecule_water = Structure(coordinates=water,
                               symbols=['O', 'H', 'H'],
                               charge=0,
                               multiplicity=1)

    qc_input = QchemInput(
        molecule_water,
        jobtype='freq',
        exchange='hf',
        basis='6-31G',
        sym_ignore=True,
    )

    parsed_data, ee = get_output_from_qchem(qc_input,
                                            parser=basic_frequencies,
                                            read_fchk=True)

    molecule_coor = np.array(ee['structure'].get_coordinates())
    molecule_symbols = np.array(ee['structure'].get_symbols())

    # print(' structure')
    print('Final energy:', parsed_data['scf_energy'])
    energies.append(parsed_data['scf_energy'])
    modes = [np.array(m['displacement']) for m in parsed_data['modes']]
Exemple #13
0
symbols = ['O', 'H', 'H']

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

print('Initial structure')
print(molecule)

# optimization
qc_input = QchemInput(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 = QchemInput(opt_molecule,
                      jobtype='freq',
Exemple #14
0
    }, {
        'atoms': [1, 3],
        'value': 0.9
    }],
    'bend': [{
        'atoms': [2, 1, 3],
        'value': 110.0
    }]
}

qc_input = QchemInput(
    molecule,
    jobtype='opt',
    exchange='hf',
    basis='sto-3g',
    geom_opt_tol_gradient=300,
    geom_opt_tol_energy=100,
    geom_opt_tol_displacement=1200,
    geom_opt_max_cycles=50,  # reduce this number to test not convergence case
    geom_opt_constrains=
    constrains  # comment/uncomment this line to use or not constrains
)

try:
    parsed_data = get_output_from_qchem(qc_input,
                                        processors=4,
                                        parser=basic_optimization,
                                        force_recalculation=False)

    opt_molecule = parsed_data['optimized_molecule']

    print('Optimized structure')
Exemple #15
0
]

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

#print(molecule.get_xyz())
# draw_molecule(molecule)

print('Initial structure')
print(molecule)

qc_input_hf = QchemInput(molecule,
                         unrestricted=True,
                         jobtype='sp',
                         exchange='hf',
                         basis='sto-3g')

#print(qc_input.get_txt())
parsed_data, electronic_structure = get_output_from_qchem(
    qc_input_hf,
    processors=4,
    force_recalculation=False,
    # parser=rasci,
    read_fchk=True,
    store_full_output=True,
)

# create qchem input
qc_input = QchemInput(
Exemple #16
0
range_f1 = range(len(coor_monomer1))
range_f2 = range(len(coor_monomer1), len(coordinates))

print('Dimer structure')
print(dimer)

# RASCI qchem input
qc_input = QchemInput(
    dimer,
    unrestricted=False,
    jobtype='sp',
    exchange='hf',
    correlation='rasci',
    basis='sto-3g',
    ras_act=4,
    ras_elec=4,
    # ras_occ=66,
    ras_spin_mult=1,  # singlets only
    ras_roots=10,  # calculate 8 states
    ras_do_hole=True,
    ras_do_part=True,
    # ras_srdft_cor='srpbe',
    # ras_srdft_exc='srpbe',
    # ras_omega=300,
    set_iter=60)

parsed_data, electronic_structure = get_output_from_qchem(
    qc_input,
    processors=4,
    force_recalculation=False,
    parser=rasci_parser,
    read_fchk=True,
Exemple #17
0
                         charge=0,
                         multiplicity=1)

methane_mol = get_geometry_from_pubchem('methane')
ammonia_mol = get_geometry_from_pubchem('ammonia')
water_mol = get_geometry_from_pubchem('water')
h2o2_mol = get_geometry_from_pubchem('h2o2')


for molecule, group in zip([h2o2_mol, sh6_mol, water_mol, dichloro_mol, methane_mol, ammonia_mol],
                           ['c2',      'Oh',     'c2v',       'c2h',       'Td',        'c3v']):

    qc_input = QchemInput(molecule,
                          jobtype='opt',
                          exchange='hf',
                          basis='sto-3g',
                          #geom_opt_tol_gradient=1,
                          #geom_opt_tol_energy=1,
                          #geom_opt_max_cycles=500,
                          )

    parsed_data = get_output_from_qchem(qc_input, parser=basic_optimization, processors=6)

    qc_input = QchemInput(parsed_data['optimized_molecule'],
                          jobtype='freq',
                          exchange='hf',
                          basis='sto-3g',
                          #sym_ignore=True,
                          )

    print(molecule)
    parsed_data, ee = get_output_from_qchem(qc_input, parser=basic_frequencies,