Example #1
0
def cond_w0_size(cavityMatrix, condStart, condEnd, wl):
    w0 = []
    for matrix in cavityMatrix:
        q0 = abcd.q_resonator(matrix)
        r0, w0_pre = abcd.r_w(q0, wl, 1)
        w0_pre = w0_pre*1000    # Convert to µm

        if (w0_pre >= condStart and  w0_pre <= condEnd):
            w0.append(w0_pre)
    return w0
Example #2
0
    def calcBeamsize(self, watchElementOrder, varElementOrder, xstart, xend):
        if not self.basicSetup():
            print('Basics FAIL')
            return False, False, False, False, False

        # Define coordinate X
        xvec = np.linspace(xstart, xend, num=100)
        beamsizeList = list(self.elementList)
        # Relevant elements
        watchElement = self.findElement_byNumber(watchElementOrder)
        varElement = self.findElement_byNumber(varElementOrder)

        # Calculate coordinate Y
        yvec_tan = []
        yvec_sag = []

        # For every value of the X axis vector
        for number in xvec:
            beamsizeList = self.updateOtherList(varElement['ID'], beamsizeList,
                                                'entry1', number)

            beamsizeMatrix = [
                self.calcCavityMatrix(beamsizeList, 0),
                self.calcCavityMatrix(beamsizeList, 1)
            ]
            q0 = []
            for matrix in beamsizeMatrix:
                q0.append(abcd.q_resonator(matrix))
            q = abcd.q_element(q0, watchElement, beamsizeList)

            # Refractive index
            if 'refr_index' in watchElement.keys():
                refr_index = watchElement['refr_index']
            else:
                refr_index = 1.0

            # Wavelength (micrometres)
            wl = self.wl_mm

            # Calculate beamsize
            R, w = abcd.r_w(q[0], wl, refr_index)
            yvec_tan.append(w * 1E3)
            R, w = abcd.r_w(q[1], wl, refr_index)
            yvec_sag.append(w * 1E3)

        xlabel = 'Variation of element ' + str(varElement['Order']) + ' (mm)'
        ylabel = 'Beam size at element ' + str(watchElement['Order']) + ' (µm)'
        return np.array(xvec), np.array(yvec_tan), np.array(
            yvec_sag), xlabel, ylabel
Example #3
0
    def calcCavity(self):
        #time_start = time.time()
        if not self.basicSetup():
            return False
        #print('basicSetup: {}'.format((time.time() - time_start)*1E6))

        # Calculate cavity matrix, for both sagittal and tangential
        cavityMatrix = []
        #time_start = time.time()
        cavityMatrix.append(self.calcCavityMatrix(self.elementList, 0))
        cavityMatrix.append(self.calcCavityMatrix(self.elementList, 1))
        self.cavityMatrix = cavityMatrix
        #print('cavityMatrix: {}'.format((time.time() - time_start)*1E6))

        # Before anything check stability
        #time_start = time.time()
        if not self.stabilityBool(cavityMatrix):
            print('Error happened with stabilityBool')
            return False
        #print('StabilityBool: {}'.format((time.time() - time_start)*1E6))

        # Calculate complex beam parameter
        # This is the starting point to calculate the propagation
        #time_start = time.time()
        self.q0 = []
        for matrix in cavityMatrix:
            self.q0.append(abcd.q_resonator(matrix))
        #print('Beam parameter: {}'.format((time.time() - time_start)*1E6))

        # Calculate propagation through cavity, both proyections
        proy = 0
        #time_start = time.time()
        self.z_tan, self.wz_tan, self.z_limits_tan, self.z_names_tan = abcd.propagation(
            self.elementList, self.q0[proy], self.wl_mm, proy)
        proy = 1
        self.z_sag, self.wz_sag, self.z_limits_sag, self.z_names_sag = abcd.propagation(
            self.elementList, self.q0[proy], self.wl_mm, proy)
        #print('Propagation: {}'.format((time.time() - time_start)*1E6))

        #time_start = time.time()
        self.z_tan = np.array(self.z_tan)
        self.z_sag = np.array(self.z_sag)
        self.wz_tan = np.array(self.wz_tan)
        self.wz_sag = np.array(self.wz_sag)
        #print('selfVariables: {}'.format((time.time() - time_start)*1E6))

        return True
Example #4
0
def cond_waist(cavityMatrix, elementList, conditionAtnumber, condStart, condEnd, wl):
    q0 = []
    for matrix in cavityMatrix:
        q0.append(abcd.q_resonator(matrix))
            
    proy = 0
    z_tan, wz_tan, z_limits_tan, z_names_tan = abcd.propagation(elementList, q0[proy], wl, proy)
    proy = 1
    z_sag, wz_sag, z_limits_sag, z_names_sag = abcd.propagation(elementList, q0[proy], wl, proy)
    # Join and convert to µm
    wz_both = [np.array(wz_tan)*1000, np.array(wz_sag)*1000]
        
    wz_min = []
    for wz in wz_both:
        # I WAS FORCING THE SOLUTION NOT TO BE AN EDGE OF THE DISTANCE, BUT THAT IS ACTUALLY A VALID SOLUTION
        if (
            min(wz[conditionAtnumber]) >= condStart
            and
            min(wz[conditionAtnumber]) <= condEnd
            ):
            wz_min.append(min(wz[conditionAtnumber]))
        else:
            return False
    return wz_min
Example #5
0
def cond_w_element(cavityMatrix, elementList, conditionAt, condStart, condEnd, wl):
    elementX = elementList[conditionAt]
    try:
        refractiveIndex = elementX['refr_index']
    except:
        refractiveIndex = 1
    
    q0 = []    
    for matrix in cavityMatrix:
        q0.append(abcd.q_resonator(matrix))
        
    q = abcd.q_element(q0, elementX, elementList)
    
    r, w_tan = abcd.r_w(q[0], wl, refractiveIndex)
    r, w_sag = abcd.r_w(q[1], wl, refractiveIndex)
    w_tan = w_tan*1000    # Convert to µm
    w_sag = w_sag*1000    # Convert to µm
    
    if ((w_tan >= condStart and  w_tan <= condEnd) and 
        (w_sag >= condStart and  w_sag <= condEnd)):
        w = [w_tan, w_sag]
        return w
    else:
        return False