def test_eta_opt(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, tracking="overlap") uc_energy_au, uc_eta = traj.find_eta_opt(units="au") corr_energy_au, corr_eta = traj.find_eta_opt(corrected=True, units="au") uc_energy_ev, uc_eta = traj.find_eta_opt(ref_energy=ref_energy, units="eV") corr_energy_ev, corr_eta = traj.find_eta_opt(ref_energy=ref_energy, corrected=True, units="eV") assert np.isclose(np.real(uc_energy_au), -109.265006) assert np.isclose(np.real(corr_energy_au), -109.26652) assert np.isclose(np.real(uc_energy_ev), 2.6381) assert np.isclose(np.real(corr_energy_ev), 2.59686) traj = CAPH.track_state(1, tracking="energy") uc_energy_au = traj.get_energy(uc_eta) corr_energy_au = traj.get_energy(corr_eta, corrected=True) uc_energy_ev = traj.get_energy(uc_eta, ref_energy=ref_energy, units="eV") corr_energy_ev = traj.get_energy(corr_eta, ref_energy=ref_energy, corrected=True, units="eV") assert np.isclose(np.real(uc_energy_au), -109.265006) assert np.isclose(np.real(corr_energy_au), -109.26652) assert np.isclose(np.real(uc_energy_ev), 2.6381) assert np.isclose(np.real(corr_energy_ev), 2.59686)
def test_correction(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, correction="density") E1, eta1 = traj.find_eta_opt(corrected=True, units="au") traj = CAPH.track_state(1, correction="derivative") E2, eta2 = traj.find_eta_opt(corrected=True, units="au") assert np.isclose(E1, E2) assert np.isclose(eta1, eta2)
def test_tracking(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, tracking="overlap") E1, eta1 = traj.find_eta_opt(corrected=True, units="au") traj = CAPH.track_state(1, tracking="energy") E2, eta2 = traj.find_eta_opt(corrected=True, units="au") assert np.isclose(E1, E2) assert np.isclose(eta1, eta2)
def test_energies_ev(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) assert np.isclose(np.real(CAPH.energies_ev(ref_energy=ref_energy)[0]), 1.3174781) traj = CAPH.track_state(1, tracking="overlap") assert np.isclose(np.real(traj.energies_ev(ref_energy=ref_energy)[0]), 2.55378)
def get_corrected_energy(pc): CAPH = CAPHamiltonian(pc=pc) eta_list = np.linspace(0, 5000, 101) eta_list = np.around(eta_list * 1E-5, decimals=5) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, tracking="energy") corr_energy, corr_eta_opt = traj.find_eta_opt(corrected=True, start_idx=10, end_idx=-1, ref_energy=ref_energy, units="eV") return corr_energy
def test_roots(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1) E1, eta1, root1 = traj.find_eta_opt(corrected=True, units="au", return_root=True) E2, root2 = traj.get_energy(eta1, corrected=True, units="au", return_root=True) assert root1 == root2 assert np.isclose(E1, E2)
"qchem_output": "../../analysis/N2/ref_outputs/qc_inp.out", "qchem_fchk": "../../analysis/N2/ref_outputs/qc_inp.fchk", } s = pyopencap.System(sys_dict) pc = pyopencap.CAP(s, cap_dict, 5) pc.read_data(es_dict) pc.compute_projected_cap() W = pc.get_projected_cap() H0 = pc.get_H() CAPH = CAPHamiltonian(pc=pc) eta_list = np.linspace(0, 5000, 201) eta_list = np.around(eta_list * 1E-5, decimals=5) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, tracking="energy") ref_energy = -109.36195558 # Find optimal value of eta uc_energy, eta_opt = traj.find_eta_opt(start_idx=10, ref_energy=ref_energy, units="eV") # start_idx and end_idx for search use python slice notation (i.e. [start_idx:end_idx]). corr_energy, corr_eta_opt = traj.find_eta_opt(corrected=True, start_idx=10, end_idx=-1, ref_energy=ref_energy, units="eV") uc_energy_au = traj.get_energy(eta_opt, units="au") corr_energy_au = traj.get_energy(eta_opt, units="au", corrected=True) print("Uncorrected:") print(uc_energy)
def test_energies_ev(): CAPH = CAPHamiltonian(output=os.path.join(dest_dir, "n2_opencap.out")) CAPH.run_trajectory(eta_list) traj = CAPH.track_state(1, tracking="overlap")
# Analyze OpenCAP output file, view eigenvalue trajectory import pyopencap from pyopencap.analysis import CAPHamiltonian import numpy as np import argparse import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description='Process OpenCAP output file.') parser.add_argument('output_file',help='OpenCAP output file') args = parser.parse_args() CAPH = CAPHamiltonian(output=args.output_file) eta_list = np.linspace(0,5000,101) eta_list = np.around(eta_list * 1E-5,decimals=5) CAPH.run_trajectory(eta_list) plt.plot(np.real(CAPH.total_energies),np.imag(CAPH.total_energies),'ro') plt.show() for i in range(0,CAPH.nstates): traj = CAPH.track_state(i,tracking="overlap") uc_energy, eta_opt = traj.find_eta_opt(start_idx=10) corr_energy, corr_eta_opt = traj.find_eta_opt(corrected=True,start_idx=10) plt.plot(np.real(traj.uncorrected_energies),np.imag(traj.uncorrected_energies),'-ro') plt.plot(np.real(traj.corrected_energies),np.imag(traj.corrected_energies),'-bo') plt.plot(np.real(corr_energy),np.imag(corr_energy),"g*",markersize=20) plt.plot(np.real(uc_energy),np.imag(uc_energy),"g*",markersize=20) plt.show()