def run_ro(ro_0, H, dt, nt, config, states=set(), fidelity_mode=False, thres=0.1): # -------------------------------------------------------- U = Unitary(H, dt) if __debug__: U.to_csv(config.U_csv) U_data = U.data U_conj = U.conj() U_conj_data = U_conj.data # -------------------------------------------------------- if fidelity_mode: ro_0_sqrt = lg.fractional_matrix_power(ro_0.data, 0.5) fidelity = [] ro_t = ro_0.data # ---------------------------------------------------------------------------- with open(config.z_csv, "w") as csv_file: writer = csv.writer( csv_file, quoting=csv.QUOTE_NONE, lineterminator="\n") for t in range(0, nt+1): diag_abs = np.abs(np.diag(ro_t)) trace_abs = np.sum(diag_abs) peaks = peakutils.indexes(diag_abs, thres=thres) for i in peaks: states.add(i) print(diag_abs) Assert(abs(1 - trace_abs) <= 0.1, "ro is not normed", cf()) writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # -------------------------------------------------------------------- if fidelity_mode: fidelity_t = round(Fidelity(ro_0_sqrt, ro_t), 5) fidelity_t = "{:.5f}".format(fidelity_t) fidelity.append(fidelity_t) # -------------------------------------------------------------------- ro_t = U_data.dot(ro_t).dot(U_conj_data) # ---------------------------------------------------------------------------- st = dict() # exit(0) for k in range(len(H.states)): if k in states: st[k] = str(H.states[k][1]) else: st[k] = "" write_xbp(H.states, config.x_csv, ind=st) write_t(T_str_v(config.T), config.nt, config.y_csv) # ---------------------------------------------------------- if fidelity_mode: list_to_csv(config.fid_csv, fidelity, header=["fidelity"])
def run(args): ro_0 = H = None T = nt = dt = l = None U_csv = x_csv = y_csv = z_csv = None thres = None T_list = sink_list = None sink_limit = None in_photons = out_photons = None lindblad = args['lindblad'] if 'in_photons' in args: in_photons = args['in_photons'] if 'out_photons' in args: out_photons = args['out_photons'] # --------------------------------------------------------------------------------------------- if 'ro_0' in args: ro_0 = args['ro_0'] Assert(ro_0 is not None, 'param[\'ro_0\'] is not set') # --------------------------------------------------------------------------------------------- if 'H' in args: H = args['H'] Assert(H is not None, 'param[\'H\'] is not set') # --------------------------------------------------------------------------------------------- if 'l' in args: l = args['l'] # --------------------------------------------------------------------------------------------- if 'T' in args: T = args['T'] if 'dt' in args: dt = args['dt'] if 'nt' in args: nt = args['nt'] if 'sink_limit' in args: sink_limit = args['sink_limit'] if 'precision' in args: precision = args['precision'] else: precision = 1e-10 # --------------------------------------------------------------------------------------------- if 'U_csv' in args: U_csv = args['U_csv'] if 'x_csv' in args: x_csv = args['x_csv'] if 'y_csv' in args: y_csv = args['y_csv'] if 'z_csv' in args: z_csv = args['z_csv'] # --------------------------------------------------------------------------------------------- if 'thres' in args: thres = args['thres'] if 'T_list' in args: T_list = args['T_list'] T_list.clear() if 'sink_list' in args: sink_list = args['sink_list'] # --------------------------------------------------------------------------------------------- Assert(dt is not None, 'param[\'dt\'] is not set') # --------------------------------------------------------------------------------------------- print("run starts ...") # --------------------------------------------------------------------------------------------- # Unitary U = Unitary(H, dt) # print(type(U.data)) if U_csv is not None: U.to_csv(args['U_csv']) U_data = U.data U_conj = U.conj() # print(type(U_conj)) # --------------------------------------------------------------------------------------------- ro_t = ro_0 # --------------------------------------------------------------------------------------------- if "z_csv" is not None: fz_csv = open("z_csv", "w") writer = csv.writer(fz_csv, quoting=csv.QUOTE_NONE, lineterminator="\n") states_dim = [] en = 0 L_RO = [] L_OUT = [] for i in args['lindblad']['out']: L_ = operator_L(ro_t, i) L_RO.append(L_) L_OUT.append(L_) diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) start_energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) start_energy['0_1'] = np.sum(start_energy['0_1']) start_energy['1_2'] = np.sum(start_energy['1_2']) sink = {} t = 0 while True: diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) # print(np.sum(energy)) if sink_list is None: if np.sum(energy['0_1']) - start_energy['0_1'] > in_photons: # print("init_energy: ", start_energy, ", energy: ", np.sum( # energy[1:]), ", ", np.round(energy, 3), sep="") # exit(0) return False # ----------------------------------------------------------- # write # writer_all.writerow(["{:.5f}".format(x) for x in diag_abs]) # writer.writerow(["{:.5f}".format(x) for x in v_bin]) if "z_csv" is not None: writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # ----------------------------------------------------------- # T_list if T_list is not None: T_list.append(t) # ----------------------------------------------------------- if sink_list is not None: zero = diag_abs[0] # print(energy['0_1']) # exit(0) sink['0_1'] = start_energy['0_1'] - \ np.sum(energy['0_1']) sink['1_2'] = start_energy['1_2'] - \ np.sum(energy['1_2']) sink_list['0_1'].append(sink['0_1']) sink_list['1_2'].append(sink['1_2']) # print('dist:', abs(sink_limit - sink['0_1']), abs(sink_limit - sink['1_2'])) if sink_limit is not None: if abs(sink_limit - sink['0_1']) < precision: # or \ # abs(sink_limit - sink['1_2']) < precision: print(np.round(diag_abs, 3)) return False print(sink['0_1'], sink['1_2']) # ----------------------------------------------------------- for L_ in L_RO: ro_t.data += dt * L_(ro_t).data ro_t.data = ((U.data).dot(ro_t.data)).dot(U_conj.data) Assert( abs(1 - ro_t.abs_trace()) <= args['precision'], "ro is not normed: " + str(ro_t.abs_trace())) # ro_t.normalize() t += dt return True
def run_wf(w_0, H, dt, nt, config, states=set(), fidelity_mode=False, thres=0.1): # -------------------------------------------------------- U = Unitary(H, dt) if __debug__: U.to_csv(config.U_csv) U_data = U.data # -------------------------------------------------------- if fidelity_mode: fidelity = [] w_t = w_0.data # ---------------------------------------------------------------------------- with open(config.z_csv, "w") as csv_file: writer = csv.writer( csv_file, quoting=csv.QUOTE_NONE, lineterminator="\n") for t in range(0, nt+1): diag_abs = np.abs(w_t.toarray()[:, 0])**2 trace_abs = np.sum(diag_abs) # print(diag_abs) # print(trace_abs) for i, j in enumerate(diag_abs): if abs(j) > thres: states.add(i) Assert(abs(1 - trace_abs) <= 0.1, "ro is not normed", FILE(), LINE()) # -------------------------------------------------------------------- # if fidelity_mode: # w_t = np.matrix(w_t) # D = w_0.getH().dot(w_t).reshape(-1)[0, 0] # fidelity_t = round(abs(D), 3) # fidelity_t = "{:>.5f}".format(fidelity_t) # fidelity.append(fidelity_t) # print(fidelity) writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # -------------------------------------------------------------------- w_t = U_data.dot(w_t) # ---------------------------------------------------------------------------- st = dict() print(states) print(H.states) for k in range(len(H.states)): if k in states: st[k] = str(H.states[k][1]) else: st[k] = "" write_xbp(H.states, config.x_csv, ind=st) write_t(T_str_v(config.T), config.nt, config.y_csv)
def run(args): # --------------------------------------------------------------------------------------------- ro_0 = H = None T = nt = dt = l = None U_csv = x_csv = y_csv = z_csv = None thres = None T_list = sink_list = None sink_limit = None in_photons = out_photons = None lindblad = args['lindblad'] if 'in_photons' in args: in_photons = args['in_photons'] if 'out_photons' in args: out_photons = args['out_photons'] # --------------------------------------------------------------------------------------------- if 'ro_0' in args: ro_0 = args['ro_0'] Assert(ro_0 is not None, 'param[\'ro_0\'] is not set') # --------------------------------------------------------------------------------------------- if 'H' in args: H = args['H'] Assert(H is not None, 'param[\'H\'] is not set') # --------------------------------------------------------------------------------------------- if 'l' in args: l = args['l'] # --------------------------------------------------------------------------------------------- if 'T' in args: T = args['T'] if 'dt' in args: dt = args['dt'] if 'nt' in args: nt = args['nt'] if 'sink_limit' in args: sink_limit = args['sink_limit'] if 'precision' in args: precision = args['precision'] else: precision = 1e-10 # --------------------------------------------------------------------------------------------- if 'U_csv' in args: U_csv = args['U_csv'] if 'x_csv' in args: x_csv = args['x_csv'] if 'y_csv' in args: y_csv = args['y_csv'] if 'z_csv' in args: z_csv = args['z_csv'] # --------------------------------------------------------------------------------------------- if 'thres' in args: thres = args['thres'] if 'T_list' in args: T_list = args['T_list'] T_list.clear() if 'sink_list' in args: sink_list = args['sink_list'] sink_list.clear() # --------------------------------------------------------------------------------------------- Assert(dt is not None, 'param[\'dt\'] is not set') # --------------------------------------------------------------------------------------------- # print("run starts ...") # --------------------------------------------------------------------------------------------- # a = operator_a(H, H.capacity, H.cavity.n_atoms) # acrossa = operator_acrossa(H, H.capacity, H.cavity.n_atoms) # across = a.conj() # # a.print(precision=3) # # print() # # across.print(precision=3) # # exit(0) # if check: # across_a = Matrix(H.size, H.size, dtype=np.longdouble) # across_a.data = lil_matrix((across.data).dot(a.data), dtype=np.longdouble) # # a_cross_a.print() # # across_a__cross = Matrix(H.size, H.size, dtype=np.double) # across_a__cross = across_a.conj() # aa_cross = Matrix(H.size, H.size, dtype=np.double) # aa_cross.data = (aa.data.dot(aa.data.transpose())) # --------------------------------------------------------------------------------------------- # Unitary U = Unitary(H, dt) # print(type(U.data)) if U_csv is not None: U.to_csv(args['U_csv']) U_data = U.data U_conj = U.conj() # print(type(U_conj)) # --------------------------------------------------------------------------------------------- ro_t = ro_0 # --------------------------------------------------------------------------------------------- if "z_csv" is not None: fz_csv = open("z_csv", "w") writer = csv.writer(fz_csv, quoting=csv.QUOTE_NONE, lineterminator="\n") states_dim = [] en = 0 L_ro = L_out = operator_L(ro_t, args['lindblad']['out']) diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) start_energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) start_energy['0_1'] = np.sum(start_energy['0_1']) start_energy['1_2'] = np.sum(start_energy['1_2']) t = 0 while True: diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) # print(np.sum(energy)) # exit(0) if sink_list is None: # print(np.round(diag_abs, 3)) # energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) # print("energy:", np.sum(energy)) # print() # sleep(1) if np.sum(energy['0_1']) - start_energy['0_1'] > in_photons: # print("init_energy: ", start_energy, ", energy: ", np.sum( # energy[1:]), ", ", np.round(energy, 3), sep="") # exit(0) return False # ----------------------------------------------------------- # write # writer_all.writerow(["{:.5f}".format(x) for x in diag_abs]) # writer.writerow(["{:.5f}".format(x) for x in v_bin]) if "z_csv" is not None: writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # ----------------------------------------------------------- # T_list if T_list is not None: # sleep(1) T_list.append(t) # ----------------------------------------------------------- # print(states_bin) # exit(0) # sink sink = {} if sink_list is not None: # zero = abs(ro_t.data[0, 0]) zero = diag_abs[0] # print('start_energy:', start_energy['0_1']) # exit(0) # print(energy['0_1']) # exit(0) sink['0_1'] = start_energy['0_1'] - \ np.sum(energy['0_1'][1:H.capacity['0_1']+1]) sink['1_2'] = start_energy['1_2'] - \ np.sum(energy['1_2'][1:H.capacity['1_2']+1]) # sink['1_2'] = start_energy['1_2'] - \ # np.sum(energy['1_2'][1:H.capacity+1]) # sink = start_energy - np.sum(energy[1:H.capacity+1]) # st_energy = ((operator_acrossa(H, H.capacity, H.cavity.n_atoms)).data.dot(ro_0.data)) # st_energy = np.sum(np.abs(start_energy)) # sink = start_energy - st_energy # sink = args['en_'] - np.sum(energy[1:]) # print("sink:", sink, ", energy:", np.sum(energy[1:H.capacity+1])) # sink = H.capacity - np.sum(energy[1:]) # sink = args['H'].capacity * zero # print("sink =", H.capacity, "-", np.sum(energy[1:])) # sink = args['H'].capacity * zero # print("init_energy: ", start_energy, ", energy: ", np.sum( # energy[1:]), ", ", np.round(energy, 3), ", sink: ", sink, sep="") # if len(sink_list) != 0 and (sink_list[-1] - sink) > precision: # print("err:", sink, "<", sink_list[-1]) # exit(0) sink_list.append(sink['0_1']) if sink_limit is not None: if abs(sink_limit - sink['0_1']) < precision: return False if abs(sink_limit - sink['1_2']) < precision: return False print(sink['0_1'], sink['1_2']) # ----------------------------------------------------------- # evolution # ro_t.data = ro_t.data + dt * L_ro(ro_t).data # LL = Matrix(m=ro_t.m, n=ro_t.n, dtype=np.complex128) # LL.data = L_ro(ro_t).data # print("L_ro:") # LL.print() # print("ro_t:") # ro_t.print() # exit(0) # ro_t.data = ((U.data).dot(ro_t.data)).dot(U_conj.data) ro_t.data = ((U.data).dot(ro_t.data + dt * L_ro(ro_t).data)).dot( U_conj.data) Assert( abs(1 - ro_t.abs_trace()) <= args['precision'], "ro is not normed: " + str(ro_t.abs_trace())) # ro_t.normalize() # ----------------------------------------------------------- t += dt # across_a__cross.print() # H.print_states() # ro_0.print() # sleep(1) # --------------------------------------------------------------------------------------------- if x_csv is not None: write_x_not_ind(H.states, x_csv) # write_xbp(H.states, config.x_csv, ind=st) if y_csv is not None: write_t(T_str_v(T), nt, y_csv) # --------------------------------------------------------------------------------------------- if z_csv is not None: fz_csv.close() # --------------------------------------------------------------------------------------------- return True
def run_wf(w_0, H, dt, nt, config, states=set(), fidelity_mode=False, thres=0.1): # -------------------------------------------------------- U = Unitary(H, dt) if __debug__: U.to_csv(config.U_csv) U_data = U.data # -------------------------------------------------------- if fidelity_mode: fidelity = [] w_0 = np.matrix(w_0.data) w_t = np.array(w_0.data) # ---------------------------------------------------------------------------- with open(config.z_csv, "w") as csv_file: writer = csv.writer( csv_file, quoting=csv.QUOTE_NONE, lineterminator="\n") for t in range(0, nt+1): w_t_arr = w_t.reshape(1, -1)[0] diag_abs = np.abs(w_t_arr)**2 trace_abs = np.sum(diag_abs) # peaks = peakutils.indexes(diag_abs, thres=thres) # print(diag_abs) for i, j in enumerate(diag_abs): if abs(j) > thres: states.add(i) # for i in peaks: # print(i) # exit(0) # states.add(i) # exit(0) # print(diag_abs) Assert(abs(1 - trace_abs) <= 0.1, "ro is not normed", cf()) # -------------------------------------------------------------------- if fidelity_mode: w_t = np.matrix(w_t) D = w_0.getH().dot(w_t).reshape(-1)[0, 0] fidelity_t = round(abs(D), 3) fidelity_t = "{:>.5f}".format(fidelity_t) fidelity.append(fidelity_t) # print(fidelity) # print(diag_abs) writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # -------------------------------------------------------------------- w_t = np.array(U_data.dot(w_t)) # ---------------------------------------------------------------------------- st = dict() print(states) print(H.states) # exit(0) for k in range(len(H.states)): if k in states: st[k] = str(H.states[k][1]) else: st[k] = "" write_xbp(H.states, config.x_csv, ind=st) write_t(T_str_v(config.T), config.nt, config.y_csv) # ---------------------------------------------------------- if fidelity_mode: list_to_csv(config.fid_csv, fidelity, header=["fidelity"])
def run(args): # --------------------------------------------------------------------------------------------- ro_0 = H = None T = nt = dt = l = None U_csv = x_csv = y_csv = z_csv = None thres = None T_list = sink_list = None sink_limit = None in_photons = out_photons = None lindblad = args['lindblad'] if 'in_photons' in args: in_photons = args['in_photons'] if 'out_photons' in args: out_photons = args['out_photons'] # --------------------------------------------------------------------------------------------- if 'ro_0' in args: ro_0 = args['ro_0'] Assert(ro_0 is not None, 'param[\'ro_0\'] is not set') # --------------------------------------------------------------------------------------------- if 'H' in args: H = args['H'] Assert(H is not None, 'param[\'H\'] is not set') # --------------------------------------------------------------------------------------------- if 'l' in args: l = args['l'] # --------------------------------------------------------------------------------------------- if 'T' in args: T = args['T'] if 'dt' in args: dt = args['dt'] if 'nt' in args: nt = args['nt'] if 'sink_limit' in args: sink_limit = args['sink_limit'] if 'precision' in args: precision = args['precision'] else: precision = 1e-10 # --------------------------------------------------------------------------------------------- if 'U_csv' in args: U_csv = args['U_csv'] if 'x_csv' in args: x_csv = args['x_csv'] if 'y_csv' in args: y_csv = args['y_csv'] if 'z_csv' in args: z_csv = args['z_csv'] # --------------------------------------------------------------------------------------------- if 'thres' in args: thres = args['thres'] if 'T_list' in args: T_list = args['T_list'] T_list.clear() if 'sink_list' in args: sink_list = args['sink_list'] sink_list.clear() # --------------------------------------------------------------------------------------------- Assert(dt is not None, 'param[\'dt\'] is not set') # --------------------------------------------------------------------------------------------- # print("run starts ...") # --------------------------------------------------------------------------------------------- # a = operator_a(H, H.capacity, H.cavity.n_atoms) # acrossa = operator_acrossa(H, H.capacity, H.cavity.n_atoms) # across = a.conj() # # a.print(precision=3) # # print() # # across.print(precision=3) # # exit(0) # if check: # across_a = Matrix(H.size, H.size, dtype=np.longdouble) # across_a.data = lil_matrix((across.data).dot(a.data), dtype=np.longdouble) # # a_cross_a.print() # # across_a__cross = Matrix(H.size, H.size, dtype=np.double) # across_a__cross = across_a.conj() # aa_cross = Matrix(H.size, H.size, dtype=np.double) # aa_cross.data = (aa.data.dot(aa.data.transpose())) # --------------------------------------------------------------------------------------------- # Unitary U = Unitary(H, dt) # print(type(U.data)) if U_csv is not None: U.to_csv(args['U_csv']) U_data = U.data U_conj = U.conj() # print(type(U_conj)) # --------------------------------------------------------------------------------------------- ro_t = ro_0 # --------------------------------------------------------------------------------------------- if "z_csv" is not None: fz_csv = open("z_csv", "w") writer = csv.writer(fz_csv, quoting=csv.QUOTE_NONE, lineterminator="\n") states_dim = [] en = 0 # states_bin = {} # for k, v in enumerate(H.states): # en = v[0] + np.sum(v[1]) # if en not in states_bin: # states_bin[en] = [] # states_bin[en].append(k) # if v[0] + np.sum(v[1]) > en: # en += 1 # states_dim.append(k-1) # print(states_dim) # exit(0) # ll = across_a.data+across.data # ll_cross = ll.getH() L_ro = L_out = operator_L(ro_t, args['lindblad']['out']) diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) start_energy = ro_t.energy( H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) start_energy = np.sum(start_energy) t = 0 while True: # for t in range(0, nt+1): # ----------------------------------------------------------- # print("\t", t) # print(t, "/", nt) diag_abs = np.abs(ro_t.data.diagonal(), dtype=np.longdouble) # print(diag_abs) energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) print(np.sum(energy)) if sink_list is None: # print(np.round(diag_abs, 3)) # energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) # print("energy:", np.sum(energy)) # print() # sleep(1) if np.sum(energy) - start_energy > in_photons: # print("init_energy: ", start_energy, ", energy: ", np.sum( # energy[1:]), ", ", np.round(energy, 3), sep="") # exit(0) return False # ----------------------------------------------------------- # write # writer_all.writerow(["{:.5f}".format(x) for x in diag_abs]) # writer.writerow(["{:.5f}".format(x) for x in v_bin]) if "z_csv" is not None: writer.writerow(["{:.5f}".format(x) for x in diag_abs]) # ----------------------------------------------------------- # T_list if T_list is not None: # sleep(1) T_list.append(t) # ----------------------------------------------------------- # print(states_bin) # exit(0) # sink if sink_list is not None: # zero = abs(ro_t.data[0, 0]) zero = diag_abs[0] # states_dim = [1, 4, 4, 3] # print(np.abs(ro_t.diagonal())) # capacity = 1 # start = states_dim[0]+1 # energy = [0] * (H.capacity + H.cavity.n_atoms+1) # # print(energy) # for i in range(1, len(states_bin)): # # print(i) # for j in states_bin[i]: # # print(states_bin[i]) # energy[i] += diag_abs[j] # # energy[i] += np.sum(diag_abs[states_bin[i]]) # energy = ro_t.energy(H.capacity, H.cavity.n_atoms, H.states_bin, diag_abs) # for i in range(1, len(states_bin)): # energy[i] *= i # for c in states_dim[1:]: # # energy[capacity] = capacity # fin = c+1 # # fin = start+c # print(capacity, c, '[', start, ':', fin, ']') # energy[capacity] = np.sum(diag_abs[start:fin]) * (capacity) # # energy[capacity] = np.sum(diag_abs[start:fin]) * (H.capacity-capacity) # print("energy[", capacity, "] = ", np.sum(diag_abs[start:fin]), " * ", (capacity)) # # print("cnt =", cnt, energy[cnt], np.sum(energy[cnt])) # capacity += 1 # start = fin # exit(0) # print(np.round(energy, 3)) # print("energy:", energy) # sink = np.sum(energy) - np.sum(energy[1:]) # sink = np.sum(energy) - np.sum(energy[1:]) sink = start_energy - np.sum(energy[1:H.capacity+1]) # st_energy = ((operator_acrossa(H, H.capacity, H.cavity.n_atoms)).data.dot(ro_0.data)) # st_energy = np.sum(np.abs(start_energy)) # sink = start_energy - st_energy # sink = args['en_'] - np.sum(energy[1:]) # print("sink:", sink, ", energy:", np.sum(energy[1:H.capacity+1])) # sink = H.capacity - np.sum(energy[1:]) # sink = args['H'].capacity * zero # print("sink =", H.capacity, "-", np.sum(energy[1:])) # sink = args['H'].capacity * zero # print("init_energy: ", start_energy, ", energy: ", np.sum( # energy[1:]), ", ", np.round(energy, 3), ", sink: ", sink, sep="") if len(sink_list) != 0 and (sink_list[-1] - sink) > precision: print("err:", sink, "<", sink_list[-1]) exit(0) sink_list.append(sink) if sink_limit is not None: if abs(sink_limit - sink) < precision: return False # ----------------------------------------------------------- # evolution # ro_t.data = ro_t.data + dt * L_ro(ro_t).data # LL = Matrix(m=ro_t.m, n=ro_t.n, dtype=np.complex128) # LL.data = L_ro(ro_t).data # print("L_ro:") # LL.print() # print("ro_t:") # ro_t.print() # exit(0) # ro_t.data = ((U.data).dot(ro_t.data)).dot(U_conj.data) ro_t.data = ((U.data).dot(ro_t.data + dt * L_ro(ro_t).data)).dot(U_conj.data) Assert(abs(1 - ro_t.abs_trace()) <= args['precision'], "ro is not normed: " + str(ro_t.abs_trace())) # ro_t.normalize() # ----------------------------------------------------------- t += dt # across_a__cross.print() # H.print_states() # ro_0.print() # sleep(1) # --------------------------------------------------------------------------------------------- if x_csv is not None: write_x_not_ind(H.states, x_csv) # write_xbp(H.states, config.x_csv, ind=st) if y_csv is not None: write_t(T_str_v(T), nt, y_csv) # --------------------------------------------------------------------------------------------- if z_csv is not None: fz_csv.close() # --------------------------------------------------------------------------------------------- return True