# set dimer geometry coor_monomer2 = np.array(coor_monomer1).copy() coor_monomer2[:, 2] += 4.0 # coor_monomer2[:, 1] -= 5.0 coor_monomer2 = list(coor_monomer2) symbols_monomer = [ 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H' ] coordinates = coor_monomer1 + coor_monomer2 symbols_dimer = symbols_monomer * 2 dimer = Structure(coordinates=coordinates, symbols=symbols_dimer, charge=0, multiplicity=1) 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',
from pyqchem import Structure from pyqchem import QchemInput 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()
from pyqchem import get_output_from_qchem, Structure, QchemInput from pyqchem.parsers.parser_optimization import basic_optimization import matplotlib.pyplot as plt from pyqchem.errors import OutputError # 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) # Optimization constrains definition constrains = { 'stre': [{ 'atoms': [1, 2], 'value': 0.9 }, { 'atoms': [1, 3], 'value': 0.9 }], 'bend': [{ 'atoms': [2, 1, 3], 'value': 110.0 }]
[-1.21479, 0.70136, 0.00000], [-2.15666, 1.24515, 0.00000], [-1.21479, -0.70136, 0.00000], [-2.15666, -1.24515, 0.00000], [0.00000, -1.40272, 0.00000], [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'],
def get_symmetry_le(electronic_structure, data_rasci, fragment_atoms=(0), tol=0.1, group='D2h'): # This only works for singlets on close shell calculations types = classify_diabatic_states_of_fragment( data_rasci['diabatization']['diabatic_states'], fragment_atoms, tol=0.1) functions_range = get_basis_functions_ranges_by_atoms( electronic_structure['basis'], atoms_range=fragment_atoms) coordinates_frag = np.array( electronic_structure['structure'].get_coordinates())[fragment_atoms] labels_frag = electronic_structure['structure'].get_symbols( )[fragment_atoms] inertia_moments, inertia_axis = get_inertia( Structure(coordinates=coordinates_frag, symbols=labels_frag)) center_frag, normal_frag = get_plane(coordinates_frag) # print(np.array(inertia_axis)) # print(inertia_moments) # print(inertia_axis[0]) # print(inertia_axis[1]) # print(inertia_axis[2]) if 'LE' in types: indices = [i for i, x in enumerate(types) if x == "LE"] symmetry_labels = [] for index in indices: print('\nLE state found at diabat {}!'.format(index + 1)) coefficients = electronic_structure['nato_coefficients_multi'][ index + 1] occupation = electronic_structure['nato_occupancies_multi'][index + 1] overlap_matrix = np.array(electronic_structure['overlap']) functions_indices = _indices_from_ranges(functions_range) overlap_matrix = np.array([ ovm[functions_indices] for ovm in overlap_matrix[functions_indices] ]) c_alpha = np.array(coefficients['alpha']) oc_alpha = np.array(occupation['alpha']) orbitals = [] alpha = 0 beta = 0 coefficients_new = {'alpha': [], 'beta': []} for i, (va, o) in enumerate(zip(c_alpha, oc_alpha)): va_frag = va[functions_indices] frag_dot = np.dot(va_frag, np.dot(overlap_matrix, va_frag)) if np.abs(frag_dot - 0.5) > tol: if frag_dot > 0.5: orbitals.append((i, np.round(o))) orbital = np.zeros(len(c_alpha)) for j, val in zip(functions_indices, va_frag): orbital[j] = val / np.sqrt(frag_dot) if np.abs(o - 1) < tol and o < 2 - tol: if alpha == beta: alpha += 1 coefficients_new['alpha'].append(list(orbital)) else: beta += 1 coefficients_new['beta'].append(list(orbital)) else: pass if alpha == beta: multiplicity = 1 else: multiplicity = 3 n_electrons = alpha + beta try: # This only works for singlets molsym = get_wf_symmetry(electronic_structure['structure'], electronic_structure['basis'], coefficients_new, center=center_frag, orientation=inertia_axis[0], orientation2=inertia_axis[1], group=group) #molsym.print_alpha_mo_IRD() #molsym.print_beta_mo_IRD() molsym.print_wf_mo_IRD() symmetry_labels.append(molsym.IRLab[np.argmax(molsym.wf_IRd)]) except: pass return symmetry_labels return None
[-3.2670227933, 1.2176289251, -0.0251089819]] # set dimer geometry coor_monomer2 = np.array(coor_monomer1).copy() coor_monomer2[:, 2] += 4.5 coor_monomer2[:, 1] -= 5.0 coor_monomer2 = list(coor_monomer2) symbols_monomer = ['C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H', 'C', 'C', 'C', 'C', 'C', 'H', 'H', 'H', 'H'] coordinates = coor_monomer1 + coor_monomer2 symbols_dimer = symbols_monomer * 2 dimer = Structure(coordinates=coordinates, symbols=symbols_dimer, charge=0, multiplicity=1) 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',
else: angles = [43.22189286, 43.86797247, 103.83908054] rotmol = R.from_euler('zyx', angles, degrees=True) #print(optimization_function(res.x)) #rotmol = R.from_euler('zyx', res.x, degrees=True) #operation = Rotation(label='C3', axis=[0, 0, 1], order=3) #rotmol = R.from_euler('zyx', [0, 0, 0], degrees=True) #mode_m, coor_m = operation.get_measure(np.array(coordinates), modes, symbols, orientation=rotmol) #print('measure', coor_m) #rotmol = R.from_euler('zyx', [360./3, 0, 0], degrees=True) #print('---') print(Structure(coordinates, symbols)) # rotations rotated_axis = rotmol.apply([0, 0, 1]) operation = rotation(2 * np.pi / 2, rotated_axis) print('axis', rotated_axis) # reflection #rotated_axis_r = rotmol.apply([0, 1, 0]) #operation = reflection(rotated_axis_r) #print('axis_r', rotated_axis_r) # C2 rotation # rotated_axis_i = rotmol.apply([(np.sqrt(8 / 9))/2, 0, (1-1 / 3)/2]) # S4 rotation
import matplotlib.pyplot as plt import pandas as pd # define monomer coor_monomer = [[ 0.6695, 0.0000, 0.0000], [-0.6695, 0.0000, 0.0000], [ 1.2321, 0.9289, 0.0000], [ 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)
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)
measures_m0 = [] measures_m1 = [] measures_m2 = [] energies = [] frequencies = [] scan_range = np.arange(-0.2, 0.21, 0.01) 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())
# Simple single point calculation from pyqchem import get_output_from_qchem, QchemInput, Structure from pyqchem.parsers.basic import basic_parser_qchem from posym import SymmetryFunction, SymmetryBase import posym.algebra as al import numpy as np import matplotlib.pyplot as plt molecule_cis = Structure( coordinates=[[-1.07076839, -2.13175980, 0.03234382], [-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
from pyqchem.tools import get_geometry_from_pubchem import numpy as np import posym.algebra as al sh6_coor = [[ 0.16290727, -0.36340852, 0.00000000], [ 1.47290727, -0.36340852, 0.00000000], [ 0.16290727, 0.94659148, 0.00000000], [ 0.16290727, -0.36340852, 1.31000000], [-1.14709273, -0.36340852, 0.00000000], [ 0.16290727, -1.67340852, 0.00000000], [ 0.16290727, -0.36340852, -1.31000000]] sh6_sym = ['S', 'H', 'H', 'H', 'H', 'H', 'H'] sh6_mol = Structure(coordinates=sh6_coor, symbols=sh6_sym, charge=0, multiplicity=1) dicloro_coor = [[ 2.1437, 0.1015, -0.0002], [-2.1439, -0.1011, -0.0002], [ 0.5135, -0.4232, 0.0002], [-0.5132, 0.4227, 0.0002], [ 0.4242, -1.5014, 0.0001], [-0.4237, 1.5009, 0.0001]] dcl_symbols = ['Cl', 'Cl', 'C', 'C', 'H', 'H'] # from scipy.spatial.transform import Rotation as R # angles = [100, 200, 300] # rotmol = R.from_euler('zyx', angles, degrees=True) # dicloro_coor = rotmol.apply(dicloro_coor)