def transfer(cov_mat):
 
     cav = apply(t00 * FilterCavity(omega, detuning, length, input_transmission, losses).two_photon_matrix + MM, cov_mat)
     cav_losses = 1 - (abs(t00 * FilterCavity(omega, detuning, length, input_transmission, losses).reflectionCoefficient() + tmm)**2 + abs(t00 * FilterCavity(-omega, detuning, length, input_transmission, losses).reflectionCoefficient() + tmm)**2) / 2
     cav_vac = cav_losses * State().covariance_matrix
                 
     return cav + cav_vac
 def variance(self, quadrature_angle = 0, dB = True):
     cov_rot = apply(rotation(-quadrature_angle), self.covariance_matrix)
     var = np.real(cov_rot[0, 0])
     if dB:
         return  10 * np.log10(var)
     else:
         return var
 def __init__(self, omega, detuning, length, input_transmission, losses):
     
     self.omega, self.detuning, self.length, self.input_transmission, self.losses = omega, detuning, length, input_transmission, losses
     
     def reflection_coefficient(omega, detuning, input_transmission, losses):
         '''gives the transfer function in field amplitude of the cavity'''
         
         epsilon = 2 * losses / (input_transmission**2 + losses)
         ksi = 4 * (omega - detuning) * length / (c * (input_transmission**2 + losses))
         
         return( 1 - (2 - epsilon) / (1 + i * ksi) )
     
     one_photon_matrix = np.matrix([[reflection_coefficient(omega, detuning, input_transmission, losses), 0], [0, np.conjugate(reflection_coefficient(-omega, detuning, input_transmission, losses))]])
     
     two_photon_matrix = apply(A2, one_photon_matrix)
     
     LinearOpticalElement.__init__(self, two_photon_matrix)
 def __init__(self, squeezing_dB, theta = 0):
     r = - 0.5 * np.log(10**(-squeezing_dB/10))
     amplitude_squeezed = np.matrix( [[np.exp(-r), 0], [0, np.exp(r)]] )
     
     LinearOpticalElement.__init__(self, apply(rotation(-theta), amplitude_squeezed))
 def __init__(self, two_photon_matrix):
     
     transfer = lambda M: apply(two_photon_matrix, M)
     OpticalElement.__init__(self, transfer)
     
     self.two_photon_matrix = two_photon_matrix