def test_brownian(): lambda_0 = 0.05 # reorganization energy (dimensionless) omega_0 = 1.0 # vibrational frequency (dimensionless) zeta = 0.5 # damping constant (dimensionless) max_tier = 5 omega_1 = np.sqrt(omega_0**2 - zeta**2*0.25) J = pyheom.Brownian(lambda_0, zeta, omega_0) corr_dict = pyheom.noise_decomposition( J, T = 1, # temperature (dimensionless) type_LTC = 'PSD', n_PSD = 1, type_PSD = 'N-1/N' ) s = corr_dict['s'].toarray() a = corr_dict['a'].toarray() gamma = corr_dict['gamma'].toarray() delta = 0 h = np.array([[omega_1, 0], [0, 0]]) op = np.array([[0, 1], [1, 0]]) max_terms = 3 corr = Correlation(k_max=max_terms, beta=1) corr.symm_coeff = np.diag(s) corr.asymm_coeff = np.diag(a) corr.exp_coeff = np.diag(gamma) corr.delta_coeff = delta corr.print() heom = Hierachy([max_tier] * max_terms, h, op, corr) rho_0 = np.zeros((2, 2)) rho_0[0, 0] = 1 init_wfn = heom.gen_extended_rho(rho_0) solver = MultiLayer(init_wfn, heom.diff()) # Define the obersevable of interest dat = [] for n, (time, r) in enumerate(solver.propagator( steps=5000, ode_inter=0.01, )): if n % 100 == 0: rho = np.reshape(r, (-1, 4)) for n, _rn in enumerate(rho): if n == 0: flat_data = [time] + list(rho[0]) dat.append(flat_data) if n <= 0: print("Time: {} ; {}: {}".format(time, n, _rn[0] + _rn[-1])) return np.array(dat)
def gen_ref(): lambda_0 = 0.05 # reorganization energy (dimensionless) omega_0 = 1.0 # vibrational frequency (dimensionless) zeta = 0.5 # damping constant (dimensionless) max_tier = 5 J = pyheom.Brownian(lambda_0, zeta, omega_0) corr_dict = pyheom.noise_decomposition( J, T = 1, # temperature (dimensionless) type_LTC = 'PSD', n_PSD = 1, type_PSD = 'N-1/N' ) n_state = 2 omega_1 = np.sqrt(omega_0**2 - zeta**2 * 0.25) H = np.array([[omega_1, 0], [0, 0]]) V = np.array([[0, 1], [1, 0]]) noises = [ dict(V=V, C=corr_dict) ] h = pyheom.HEOM( H, noises, max_tier=max_tier, matrix_type='dense', hierarchy_connection='loop', ) dt__unit = 5.0e-3 rho_0 = np.zeros((n_state,n_state)) rho_0[0, 0] = 1 h.set_rho(rho_0) callback_interval = 5 count = 10000 ref = [] def callback(t, rho): flat_data = [t] + list(np.reshape(rho, -1)) ref.append(flat_data) h.time_evolution(dt__unit, count, callback, callback_interval) return np.array(ref)
def test_drude_train(): eta = 0.05 # reorganization energy (dimensionless) gamma_c = 0.05 # vibrational frequency (dimensionless) max_tier = 10 max_terms = 3 J = pyheom.Drudian(eta, gamma_c) corr_dict = pyheom.noise_decomposition( J, T=1, # temperature (dimensionless) type_LTC='PSD', n_PSD=max_terms - 1, type_PSD='N-1/N') s = corr_dict['s'].toarray() a = corr_dict['a'].toarray() gamma = corr_dict['gamma'].toarray() delta = 0 omega_1 = 0.05 omega_2 = 0.02 H = np.array([[omega_1, omega_2], [omega_2, 0]]) V = np.array([[0, 0], [0, 1]]) corr = Correlation(k_max=max_terms, beta=1) corr.symm_coeff = np.diag(s) corr.asymm_coeff = np.diag(a) corr.exp_coeff = np.diag(gamma) corr.delta_coeff = delta corr.print() heom = Hierachy([max_tier] * max_terms, H, V, corr) rho_0 = np.zeros((2, 2)) rho_0[0, 0] = 1 # TT HEOM tensor_train = tensor_train_template(rho_0, [max_tier] * max_terms, rank=max_tier) root = tensor_train[0] leaves_dict = {leaf.name: leaf for leaf in root.leaves()} all_terms = [] for term in heom.diff(): all_terms.append([(leaves_dict[str(fst)], snd) for fst, snd in term]) solver = MultiLayer(root, all_terms) solver.ode_method = 'RK45' solver.snd_order = False solver.max_ode_steps = 100000 # Define the obersevable of interest projector = np.zeros((max_tier, 1)) projector[0] = 1.0 dat = [] for n, (time, r) in enumerate(solver.propagator( steps=20000, ode_inter=0.01, )): head = root.array for t in tensor_train[1:]: spf = Tensor.partial_product(t.array, 1, projector, 0) head = Tensor.partial_product(head, head.ndim - 1, spf, 0) rho = np.reshape(head, (4, -1))[:, 0] flat_data = [time] + list(rho) dat.append(flat_data) print("Time {} | Pop_1 {} | Total {}".format(time, rho[0], rho[0] + rho[-1])) return np.array(dat)
import pyheom pyheom.units['energy'] = pyheom.unit.dimensionless pyheom.units['time'] = pyheom.unit.dimensionless import tqdm lambda_0 = 0.01 # reorganization energy (dimensionless) omega_0 = 1 # vibrational frequency (dimensionless) zeta = 0.5 # damping constant (dimensionless) T = 1 # temperature (dimensionless) max_tier = 5 J = pyheom.brown(lambda_0, zeta, omega_0) corr_dict = pyheom.noise_decomposition(J, T=T, type_ltc='psd', n_psd=1, type_psd='N-1/N') n_state = 2 omega_1 = np.sqrt(omega_0**2 - zeta**2 * 0.25) H = np.array([[omega_1, 0], [0, 0]]) V = np.array([[0, 1], [1, 0]]) noises = [dict(V=V, C=corr_dict)] h = pyheom.heom( H, noises,
from minitn.lib.units import Quantity from minitn.lib.logging import Logger import pyheom # Bath lambda_0 = 0.01 # reorganization energy (dimensionless) omega_0 = 1.0 # vibrational frequency (dimensionless) zeta = 0.5 # damping constant (dimensionless) max_tier = 5 max_terms = 2 J = pyheom.Brownian(lambda_0, zeta, omega_0) corr_dict = pyheom.noise_decomposition( J, T=1, # temperature (dimensionless) type_LTC='PSD', n_PSD=max_terms - 1, type_PSD='N-1/N') # System n_state = 2 omega_1 = np.sqrt(omega_0**2 - zeta**2 * 0.25) H = np.array([[omega_1, 0.0], [0.0, 0.0]]) V = np.array([[0.0, 1.0], [1.0, 0.0]]) # init state rho_0 = np.zeros((n_state, n_state)) rho_0[0, 0] = 1 dt_unit = 0.001 callback_interval = 100
def test_drude_tree(): eta = 0.05 # reorganization energy (dimensionless) gamma_c = 0.05 # vibrational frequency (dimensionless) max_tier = 10 max_terms = 3 J = pyheom.Drudian(eta, gamma_c) corr_dict = pyheom.noise_decomposition( J, T=1, # temperature (dimensionless) type_LTC='PSD', n_PSD=max_terms - 1, type_PSD='N-1/N') s = corr_dict['s'].toarray() a = corr_dict['a'].toarray() gamma = corr_dict['gamma'].toarray() delta = 0 omega_1 = 0.05 omega_2 = 0.02 H = np.array([[omega_1, omega_2], [omega_2, 0]]) V = np.array([[0, 0], [0, 1]]) corr = Correlation(k_max=max_terms, beta=1) corr.symm_coeff = np.diag(s) corr.asymm_coeff = np.diag(a) corr.exp_coeff = np.diag(gamma) corr.delta_coeff = delta corr.print() heom = Hierachy([max_tier] * max_terms, H, V, corr) rho_0 = np.zeros((2, 2)) rho_0[0, 0] = 1 root = tensor_tree_template(rho_0, [max_tier] * max_terms, rank=max_tier // 2) solver = MultiLayer(root, heom.diff(), use_str_name=True) solver.ode_method = 'RK45' solver.snd_order = False solver.max_ode_steps = 100000 dat = [] for n, (time, r) in enumerate(solver.propagator( steps=20000, ode_inter=0.01, )): if n % 100 == 0: head = root.array print(head.shape) rho = Tensor.partial_product(r.array, 0, r[0][0].array, 0) rho = np.reshape(rho, (-1, 4)) flat_data = [time] + list(rho[0]) dat.append(flat_data) print("Time: {} | Pop 0: {} | Total: {}".format( flat_data[0], flat_data[1], flat_data[1] + flat_data[-1])) return np.array(dat)