def read_gtsfiles(self, dimasses={}): # initialize variables self._lpg = [] self._lV0 = [] self._molecules = [] # get list of gts files gtsfiles = self.gtsfiles() if len(gtsfiles) == 0: return # read and save for idx, gts in enumerate(gtsfiles): # no gts file if not os.path.exists(gts): self.molecules.append(None) self._lpg.append(None) self._lV0.append(None) continue # isotopic modification? itc, weight = self._itcs[idx] if itc in self._diso.keys(): imods = self._diso[itc] elif "*" in self._diso.keys(): imods = self._diso["*"] else: imods = {} # create molecule molecule = Molecule() molecule.set_from_gts(gts) molecule.apply_imods(imods, dimasses) molecule.setup() # save molecule self._molecules.append(molecule) # complete CTC data self._lV0.append(float(molecule._V0)) self._lpg.append(str(molecule._pgroup))
def get_mass_ch(target, dctc, dimasses): ''' target may be a compound or a list of compounds. If a list ==> returns the sum ''' # initialize tot_mass = 0.0 tot_ch = 0 # target to list target = target2list(target) if target is None: return None, None # get mass and charge! for ctc in target: ctc = ctc.split(".")[0] if ctc in dctc.keys(): # generate instance of Molecule molecule = Molecule() # gts files associated to this ctc itc, weight = dctc[ctc]._itcs[0] gtsfile = dctc[ctc].gtsfile(itc) # isotopic modification diso = dctc[ctc]._diso if itc in diso.keys(): imod = diso[itc] elif "*" in diso.keys(): imod = diso["*"] else: imod = None # read gts molecule.set_from_gts(gtsfile) # apply iso molecule.apply_imods(imod, dimasses) # mass and charge tot_mass += float(molecule._mass) tot_ch += int(molecule._ch) else: tot_mass, tot_ch = None, None return tot_mass, tot_ch
def prepare_qrc(self,dchem,dctc,dimasses): ''' also modifies self._qrccase: self._qrccase == 0: everything is ok / qrc is not activated self._qrccase == 1: no reaction is associated to the TS self._qrccase == 2: reaction is not unimolecular self._qrccase == 3: ctc for reactant not defined self._qrccase == 4: gts file for reactant not found self._qrccase == 5: unable to get energy of products ''' # Will qrc be used? if self._qrc is None: return if self._reaction is None: self._qrccase = 1; return # assert unimolecular reactants = dchem[self._reaction][0] products = dchem[self._reaction][2] if self._exorgic: if len(reactants) != 1: self._qrccase = 2; return self._qrcname = reactants[0] else: if len(products ) != 1: self._qrccase = 2; return self._qrcname = products[0] if self._V1P is None: self._qrccase = 5; return #---------------------------------# # Now, generate Molecule instance # #---------------------------------# ctc, itc = PN.name2data(self._qrcname) if ctc not in dctc.keys(): self._qrccase = 3; return cluster = dctc[ctc] if itc is None: itc = cluster._itcs[0][0] if itc in cluster._diso.keys(): imods = cluster._diso[itc] elif "*" in cluster._diso.keys(): imods = cluster._diso["*"] else : imods = None gtsfile = dctc[ctc].gtsfile(itc) if not os.path.exists(gtsfile): self._qrccase = 4; return # Generate Molecule instance molecule = Molecule() molecule.set_from_gts(gtsfile) # apply fscal molecule.setvar(fscal=cluster._fscal) # apply isotopic masses if imods is not None: molecule.apply_imods(imods,dimasses) # calculate frequencies molecule.setup() #------------------------------# # Prepare list of QRC energies # #------------------------------# mode , nE = self._qrc self._qrcafreq = molecule._ccfreqs[mode] self._qrclE = [n*HBAR*self._qrcafreq for n in range(nE)]
def get_masses(target, dctc, dimasses): ctc, itc = PN.name2data(target) diso = dctc[ctc]._diso if itc in diso.keys(): imod = diso[itc] elif "*" in diso.keys(): imod = diso["*"] else: imod = None if imod is None: return None gtsTS = dctc[ctc].gtsfile(itc) TS = Molecule() TS.set_from_gts(gtsTS) TS.apply_imods(imod, dimasses) masses = list(TS._masses) return masses
def molecule_prep(gts, eslist=[], tiso=None, fscal=1.0): # generate instance of Molecule molecule = Molecule() # read gts molecule.set_from_gts(gts) # masses if tiso is not None: imods, imasses = tiso molecule.apply_imods(imods, imasses) # electronic states molecule.setvar(les=eslist) # set frequency scaling molecule.setvar(fscal=fscal) # setup molecule.setup() molecule.ana_freqs("cc") return molecule
def return_itcdata(self,ctc,itc): # generate instance of Molecule molecule = Molecule() # gts files associated to this ctc gtsfile = self._dctc[ctc].gtsfile(itc) # isotopic modification diso = self._dctc[ctc]._diso if itc in diso.keys(): imod = diso[itc] elif "*" in diso.keys(): imod = diso["*"] else : imod = None # read gts molecule.set_from_gts(gtsfile) # apply iso molecule.apply_imods(imod,self._dimasses) # mass, charge, V0 mass = float(molecule._mass) charge = int(molecule._ch) V0 = float(molecule._V0) return mass, charge, V0
def get_masses_charges(self, dimasses={}): for ctc, itcs, ms in self._itcs.values(): # select first itc itc, weight = itcs[0] # generate instance of Molecule molecule = Molecule() # read gts gtsfile = self._gtsfile[(ctc, itc)] molecule.set_from_gts(gtsfile) # isotopic modification diso = self._disos[ctc] if itc in diso.keys(): imod = diso[itc] elif "*" in diso.keys(): imod = diso["*"] else: imod = None molecule.apply_imods(imod, dimasses) # data to save: mass & charge mass = float(molecule._mass) charge = int(molecule._ch) # save data self._massch[ctc] = (mass, charge)
def prepare_qrc(self, dchem, dctc, dimasses): # Will qrc be used? if self._reaction is None: return if self._qrc is None: return reactants = dchem[self._reaction][0] if len(reactants) != 1: return # generate Molecule instance reactant = reactants[0] ctc, itc = PN.name2data(reactant) if ctc not in dctc.keys(): return cluster = dctc[ctc] if itc is None: itc = cluster._itcs[0][0] if itc in cluster._diso.keys(): imods = cluster._diso[itc] elif "*" in cluster._diso.keys(): imods = cluster._diso["*"] else: imods = None gtsfile = PN.get_gts(ctc, itc) if not os.path.exists(gtsfile): raise Exception # Generate Molecule instance reactant = Molecule() reactant.set_from_gts(gtsfile) # apply fscal reactant.set_fscal(fscal=cluster._fscal) # apply isotopic masses if imods is not None: reactant.apply_imods(imods, dimasses) # calculate frequencies reactant.setup() mode, nE = self._qrc Vadi = reactant._V0 for idx, afreq in enumerate(reactant._ccfreqs): if idx == mode: continue Vadi += afreq2zpe(afreq) afreq = reactant._ccfreqs[mode] listE = [ Vadi + (n + 0.5) * HBAR * afreq - self._eref for n in range(nE) ] self._qrclE = listE self._qrcafreq = afreq