def test_compare_solvers_coherent_state_legacy(): """ correlation: legacy me and es for oscillator in coherent initial state """ N = 20 a = destroy(N) H = a.dag() * a G1 = 0.75 n_th = 2.00 c_ops = [np.sqrt(G1 * (1 + n_th)) * a, np.sqrt(G1 * n_th) * a.dag()] rho0 = coherent_dm(N, np.sqrt(4.0)) taulist = np.linspace(0, 5.0, 100) with warnings.catch_warnings(): warnings.simplefilter("ignore") corr1 = correlation(H, rho0, None, taulist, c_ops, a.dag(), a, solver="me") corr2 = correlation(H, rho0, None, taulist, c_ops, a.dag(), a, solver="es") assert_(max(abs(corr1 - corr2)) < 1e-4)
def get_qutip_peierls_kubo(J, nsites, ph_levels, omega, g, temperature, time_series): clist = get_clist(nsites, ph_levels) blist = get_blist(nsites, ph_levels) qn_idx = get_qnidx(ph_levels, nsites) H = get_peierls_hamiltonian(nsites, J, omega, g, clist, blist).extract_states(qn_idx) init_state = (-temperature.to_beta() * H).expm().unit() holstein_terms = [] peierls_terms = [] for i in range(nsites): next_i = (i + 1) % nsites holstein_terms.append(J * clist[i].dag() * clist[next_i]) holstein_terms.append(-J * clist[i] * clist[next_i].dag()) peierls_terms.append(g * omega * clist[i].dag() * clist[next_i] * (blist[i].dag() + blist[i])) peierls_terms.append(-g * omega * clist[i] * clist[next_i].dag() * (blist[i].dag() + blist[i])) j_oper1 = sum(holstein_terms).extract_states(qn_idx) j_oper2 = sum(peierls_terms).extract_states(qn_idx) # Add negative signs because j is taken to be real corr1 = -qutip.correlation(H, init_state, [0], time_series, [], j_oper1, j_oper1)[0] corr2 = -qutip.correlation(H, init_state, [0], time_series, [], j_oper1, j_oper2)[0] corr3 = -qutip.correlation(H, init_state, [0], time_series, [], j_oper2, j_oper1)[0] corr4 = -qutip.correlation(H, init_state, [0], time_series, [], j_oper2, j_oper2)[0] corr = corr1 + corr2 + corr3 + corr4 return corr, np.array([corr1, corr2, corr3, corr4]).T
def get_exact_autocorr(mol_list, temperature, time_series): nsites = len(mol_list) J = mol_list.j_constant.as_au() ph = mol_list[0].dmrg_phs[0] ph_levels = ph.n_phys_dim omega = ph.omega[0] g = -ph.coupling_constant clist = get_clist(nsites, ph_levels) blist = get_blist(nsites, ph_levels) qn_idx = get_qnidx(ph_levels, nsites) H = get_hamiltonian(nsites, J, omega, g, clist, blist).extract_states(qn_idx) init_state = (-temperature.to_beta() * H).expm().unit() terms = [] for i in range(nsites - 1): terms.append(clist[i].dag() * clist[i + 1]) terms.append(-clist[i] * clist[i + 1].dag()) j_oper = sum(terms).extract_states(qn_idx) corr = qutip.correlation(H, init_state, [0], time_series, [], j_oper, j_oper)[0] return corr
def get_qutip_holstein_kubo(model, temperature, time_series): nsites = len(model) J = model.j_constant ph = model[0].ph_list[0] ph_levels = ph.n_phys_dim omega = ph.omega[0] g = -ph.coupling_constant clist = get_clist(nsites, ph_levels) blist = get_blist(nsites, ph_levels) qn_idx = get_qnidx(ph_levels, nsites) H = get_holstein_hamiltonian(nsites, J, omega, g, clist, blist).extract_states(qn_idx) init_state = (-temperature.to_beta() * H).expm().unit() terms = [] for i in range(nsites - 1): terms.append(J * clist[i].dag() * clist[i + 1]) terms.append(-J * clist[i] * clist[i + 1].dag()) j_oper = sum(terms).extract_states(qn_idx) # Add the negative sign because j is taken to be real return -qutip.correlation(H, init_state, [0], time_series, [], j_oper, j_oper)[0]
def test_compare_solvers_steadystate_legacy(): """ correlation: legacy me and es for oscillator in steady-state """ N = 20 a = destroy(N) H = a.dag() * a G1 = 0.75 n_th = 2.00 c_ops = [np.sqrt(G1 * (1 + n_th)) * a, np.sqrt(G1 * n_th) * a.dag()] taulist = np.linspace(0, 5.0, 100) with warnings.catch_warnings(): warnings.simplefilter("ignore") corr1 = correlation(H, None, None, taulist, c_ops, a.dag(), a, solver="me") corr2 = correlation(H, None, None, taulist, c_ops, a.dag(), a, solver="es") assert_(max(abs(corr1 - corr2)) < 1e-4)