def lindbladian_population(U_dict: dict, lvl: int, gate: str): U = U_dict[gate] lvls = int(np.sqrt(U.shape[0])) psi_0 = tf.constant(basis(lvls, 0), dtype=tf.complex128) dv_0 = tf_dm_to_vec(tf_state_to_dm(psi_0)) dv_actual = tf.matmul(U, dv_0) return populations(dv_actual, lindbladian=True)[lvl]
def initialise(self, drift_H, lindbladian=False, init_temp=None): """ Prepare the initial state of the system. At the moment finite temperature requires open system dynamics. Parameters ---------- drift_H : tf.Tensor Drift Hamiltonian. lindbladian : boolean Whether to include open system dynamics. Required for Temperature > 0. init_temp : Quantity Temperature of the device. Returns ------- tf.Tensor State or density vector """ if init_temp is None: init_temp = tf.cast(self.params["init_temp"].get_value(), dtype=tf.complex128) diag = tf.linalg.diag_part(drift_H) dim = len(diag) if abs(init_temp) > np.finfo( float).eps: # this checks that it's not zero # TODO Deal with dressed basis for thermal state freq_diff = diag - diag[0] beta = 1 / (init_temp * constants.kb) det_bal = tf.exp(-constants.hbar * freq_diff * beta) norm_bal = det_bal / tf.reduce_sum(det_bal) dm = tf.linalg.diag(norm_bal) if lindbladian: return tf_utils.tf_dm_to_vec(dm) else: raise Warning( "C3:WARNING: We still need to do Von Neumann right.") else: state = tf.constant(qt_utils.basis(dim, 0), shape=[dim, 1], dtype=tf.complex128) if lindbladian: return tf_utils.tf_dm_to_vec(tf_utils.tf_state_to_dm(state)) else: return state