def calc_Vcoeffs(self): from Converter import Constants from FourierExpansions import calc_cos_coefs, calc_4cos_coefs print("Using DFT for all potentials...") dvr_energies = self.DVRresults["energies"] # [degrees vOH=0 ... vOH=6] dvr_energies[:, 1:] = Constants.convert(dvr_energies[:, 1:], "wavenumbers", to_AU=True) coeff_dict = dict() # build coeff dict rad = np.radians(dvr_energies[:, 0]) coeff_dict["Vel"] = self.Velcoeffs if "Vexpansion" in self.PORparams: if self.PORparams["Vexpansion"] == "fourth": print("Expaning potential coefficients to four tau") for i in np.arange( 1, dvr_energies.shape[1]): # loop through saved energies energies = np.column_stack((rad, dvr_energies[:, i])) coeff_dict[f"V{i - 1}"] = calc_4cos_coefs(energies) elif self.PORparams["Vexpansion"] == "sixth": print("Expaning potential coefficients to six tau") for i in np.arange( 1, dvr_energies.shape[1]): # loop through saved energies energies = np.column_stack((rad, dvr_energies[:, i])) coeff_dict[f"V{i - 1}"] = calc_cos_coefs(energies) else: raise Exception( f"Can not expand to {self.PORparams['Vexpansion']}") return coeff_dict
def calc_scaled_Vcoeffs(energy_dat, Vcoeffs, ens_to_calc, barrier_height, scaling_factor, order): from FourierExpansions import calc_cos_coefs, calc_4cos_coefs scaling_factor, scaled_energies = scale_barrier(energy_dat, barrier_height, scaling_factor) if order == 6: newVel = calc_cos_coefs(scaled_energies) elif order == 4: newVel = calc_4cos_coefs(scaled_energies) else: raise Exception(f"{order}th order expansions not currently supported") scaled_coeffs = dict() scaled_coeffs["Vel"] = newVel for i in np.arange(len(Vcoeffs.keys())-1): # loop through saved energies scaled_coeffs[f"V{i}"] = newVel + Vcoeffs[f"V{i}"] return scaled_coeffs
def calc_Mixed1_Vcoeffs(self): from Converter import Constants from FourierExpansions import calc_4cos_coefs print("Using CCSD Vel and DFT VOH for potentials...") dvr_energies = self.DVRresults["energies"] # [degrees vOH=0 ... vOH=6] dvr_energies[:, 1:] = Constants.convert(dvr_energies[:, 1:], "wavenumbers", to_AU=True) rad = np.radians(dvr_energies[:, 0]) coeff_dict = dict() coeff_dict["Vel"] = self.Velcoeffs for i in np.arange( 1, dvr_energies.shape[1]): # loop through saved energies energies = np.column_stack((rad, dvr_energies[:, i])) coeff_dict[f"V{i-1}"] = calc_4cos_coefs(energies) return coeff_dict
def calc_Emil_Vcoeffs(self): from Converter import Constants from FourierExpansions import calc_4cos_coefs print("Using CCSD for all potentials...") all_data = self.PORparams["EmilEnergies"] tor_angles = all_data[0, :] rad = np.radians(tor_angles) ZPE = all_data[1, :] ens = all_data[2:, :] + ZPE ens = Constants.convert(ens, "wavenumbers", to_AU=True) coeff_dict = dict() coeff_dict["Vel"] = self.Velcoeffs for i in np.arange(len(ens)): dat = np.column_stack((rad, ens[i, :])) coeff_dict[f"V{i}"] = calc_4cos_coefs(dat) return coeff_dict
def calculate_VelwZPE(self): from Converter import Constants from FourierExpansions import calc_cos_coefs, calc_4cos_coefs, fourier_coeffs, calc_curves degree_vals = np.linspace(0, 360, len(self.MoleculeInfo.TorFiles)) norm_grad = self.RxnPathResults["norm_grad"] idx = np.where(norm_grad[:, 1] > 4E-4) new_degree = degree_vals[idx] Vel = self.RxnPathResults["electronicE"][:, 1] Vel_ZPE_dict = dict() ZPE_dict = dict() for i, j in enumerate(degree_vals): freqs = self.RxnPathResults[j]["freqs"] # in hartree # print(np.column_stack((j, freqs[-1]))) nonzero_freqs = freqs[ 7:-1] # throw out translations/rotations and OH frequency nonzero_freqs_har = Constants.convert(nonzero_freqs, "wavenumbers", to_AU=True) ZPE = np.sum(nonzero_freqs_har) / 2 if j in new_degree: if self.PORparams["twoD"]: # "twoD" in self.PORparams and Vel_ZPE_dict[j] = Vel[i] else: Vel_ZPE_dict[j] = Vel[i] + ZPE ZPE_dict[j] = ZPE else: pass if "EmilData" in self.PORparams or "MixedData1" in self.PORparams: # put together ZPE print("CCSD Vel") ZPE = np.array([(d, v) for d, v in ZPE_dict.items()]) sort_idxZ = np.argsort(ZPE[:, 0]) ZPE = ZPE[sort_idxZ] ZPE[:, 0] = np.radians(ZPE[:, 0]) fit_ZPE = calc_4cos_coefs(ZPE) # zpe_y = calc_curves(np.radians(np.arange(0, 360, 1)), fit_ZPE, function="4cos") emil_angles = self.RxnPathResults["EmilelectronicE"][:, 0] emil_ZPE = calc_curves(np.radians(emil_angles), fit_ZPE, function="4cos") Vel_ZPE = np.column_stack( (np.radians(emil_angles), emil_ZPE + self.RxnPathResults["EmilelectronicE"][:, 1])) VelwZPE_coeffs1 = calc_4cos_coefs(Vel_ZPE) new_x = np.radians(np.arange(0, 360, 1)) y = calc_curves(new_x, VelwZPE_coeffs1, function="4cos") y -= min(y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = calc_4cos_coefs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Emil_Velcoeffs_4order.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Emil_Velcoeffs_4order.csv" else: print("DFT Vel") Vel_ZPE = np.array([(d, v) for d, v in Vel_ZPE_dict.items()]) sort_idx = np.argsort(Vel_ZPE[:, 0]) Vel_ZPE = Vel_ZPE[sort_idx] Vel_ZPE[:, 0] = np.radians(Vel_ZPE[:, 0]) new_x = np.radians(np.arange(0, 360, 1)) if "MixedData2" in self.PORparams or self.PORparams[ "Vexpansion"] is "fourth": VelwZPE_coeffs1 = calc_4cos_coefs(Vel_ZPE) y = calc_curves(new_x, VelwZPE_coeffs1, function="4cos") y -= min( y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = calc_4cos_coefs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_4order.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_4order.csv" elif self.PORparams["None"] and self.PORparams["twoD"]: VelwZPE_coeffs1 = fourier_coeffs(Vel_ZPE) y = calc_curves(new_x, VelwZPE_coeffs1, function="fourier") y -= min( y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = fourier_coeffs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6cos6sin_2D.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6cos6sin_2D.csv" elif self.PORparams["None"] and self.PORparams["twoD"] is False: VelwZPE_coeffs1 = fourier_coeffs(Vel_ZPE) y = calc_curves(new_x, VelwZPE_coeffs1, function="fourier") y -= min( y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = fourier_coeffs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6cos6sin.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6cos6sin.csv" elif self.PORparams["twoD"]: VelwZPE_coeffs1 = calc_cos_coefs(Vel_ZPE) y = calc_curves(new_x, VelwZPE_coeffs1) y -= min( y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = calc_cos_coefs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6order_2D.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6order_2D.csv" else: VelwZPE_coeffs1 = calc_cos_coefs(Vel_ZPE) y = calc_curves(new_x, VelwZPE_coeffs1) y -= min( y) # shift curve so minima are at 0 instead of negative VelwZPE_coeffs = calc_cos_coefs(np.column_stack((new_x, y))) npy_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6order.npy" csv_name = f"{self.MoleculeInfo.MoleculeName}_Velcoeffs_6order.csv" # save results np.save(os.path.join(self.MoleculeInfo.MoleculeDir, npy_name), VelwZPE_coeffs) np.savetxt(os.path.join(self.MoleculeInfo.MoleculeDir, csv_name), VelwZPE_coeffs) return os.path.join(self.MoleculeInfo.MoleculeDir, npy_name)