Esempio n. 1
0
    def FindDCVoltages(self):
        try:       
            m = 1.46e-25                                                    # [kg] - Strontium
            Ze = 1.602e-19                                                  # [C] - singly ionized
            m_over_Ze = m/Ze                                                # [kg/C]
            omega_rf = 2*np.pi*self.internal_state['FreqRF']*1000000        # [Hz] - rf frequency
            v_rf = self.internal_state['VoltRF']                            # [V]
            Azz = 4*(2*np.pi*1000000*self.internal_state['SecularZ'])**2/omega_rf**2 #unitless curvature parameter
            trap = iontrap.IonTrap(v_rf, m_over_Ze, omega_rf, None, self.filename)

            if self.internal_state['XYTilt'] == 0:

                curvature = m_over_Ze * omega_rf**2 * Azz/4 
                constraints = {trap.grad_potential_fn:[0,0,0], trap.hess_potential_fn_ij(2,2):curvature}

            elif self.internal_state['XYTilt'] != 0:
                tilt_theta = np.radians(self.internal_state['XYTilt'])
                Axx = Azz*-1.5
                Ayy = -Axx - Azz
                C = m_over_Ze * omega_rf**2 / 4
                curvature_xx = C * ((Axx*np.cos(tilt_theta))**2 + (Ayy*np.sin(tilt_theta))**2)
                curvature_xy = C * (Axx - Ayy)*np.sin(2*tilt_theta) /2
                curvature_zz = C * Azz
                constraints = {trap.grad_potential_fn:[0,0,0], 
                trap.hess_potential_fn_ij(0,0):curvature_xx,
                trap.hess_potential_fn_ij(0,1):curvature_xy,
                trap.hess_potential_fn_ij(2,2):curvature_zz}
            dcvoltages = trap.find_dc_voltages(constraints)
            print dcvoltages

            for key in dcvoltages:
                dcvoltages[key]=round(dcvoltages[key],3)
                
            if self.internal_state ['ElectrodeConst'] == 'noconstground' or self.internal_state ['ElectrodeConst'] == 'sideground' or self.internal_state ['ElectrodeConst'] == 'symground' or self.internal_state['ElectrodeConst']=='double':
                if self.internal_state['ElectrodeConst'] == 'noconstground' or self.internal_state['ElectrodeConst']=='double':
                    self.internal_state['E0'] = dcvoltages['v0']
                    self.internal_state['E1'] = dcvoltages['v1']
                    self.internal_state['E2'] = dcvoltages['v2']
                    self.internal_state['E3'] = dcvoltages['v3']
                    self.internal_state['E4'] = dcvoltages['v4']
                    self.internal_state['E5'] = dcvoltages['v5']
                    self.internal_state['GND'] = dcvoltages['vg']
                elif self.internal_state['ElectrodeConst'] == 'sideground':
                    self.internal_state['E0'] = dcvoltages['v0']
                    self.internal_state['E1'] = dcvoltages['v1']
                    self.internal_state['E2'] = dcvoltages['v2']
                    self.internal_state['E3'] = dcvoltages['vside']
                    self.internal_state['E4'] = dcvoltages['vside']
                    self.internal_state['E5'] = dcvoltages['vside']
                    self.internal_state['GND'] = dcvoltages['vg']
                elif self.internal_state['ElectrodeConst'] == 'symground':
                    self.internal_state['E0'] = dcvoltages['vtop']
                    self.internal_state['E1'] = dcvoltages['vmid']
                    self.internal_state['E2'] = dcvoltages['vbottom']
                    self.internal_state['E3'] = dcvoltages['vtop']
                    self.internal_state['E4'] = dcvoltages['vmid']
                    self.internal_state['E5'] = dcvoltages['vbottom']
                    self.internal_state['GND'] = dcvoltages['vg']
            if self.internal_state ['ElectrodeConst'] == 'noconst' or self.internal_state ['ElectrodeConst'] == 'side' or self.internal_state['ElectrodeConst'] == 'sym':
                if self.internal_state['ElectrodeConst'] == 'noconst':
                    self.internal_state['E0'] = dcvoltages['v0']
                    self.internal_state['E1'] = dcvoltages['v1']
                    self.internal_state['E2'] = dcvoltages['v2']
                    self.internal_state['E3'] = dcvoltages['v3']
                    self.internal_state['E4'] = dcvoltages['v4']
                    self.internal_state['E5'] = dcvoltages['v5']
                    self.internal_state['GND'] = 0
                elif self.internal_state['ElectrodeConst'] == 'side':
                    self.internal_state['E0'] = dcvoltages['v0']
                    self.internal_state['E1'] = dcvoltages['v1']
                    self.internal_state['E2'] = dcvoltages['v2']
                    self.internal_state['E3'] = dcvoltages['vside']
                    self.internal_state['E4'] = dcvoltages['vside']
                    self.internal_state['E5'] = dcvoltages['vside']
                    self.internal_state['GND'] = 0
                elif self.internal_state['ElectrodeConst'] == 'sym':
                    self.internal_state['E0'] = dcvoltages['vtop']
                    self.internal_state['E1'] = dcvoltages['vmid']
                    self.internal_state['E2'] = dcvoltages['vbottom']
                    self.internal_state['E3'] = dcvoltages['vtop']
                    self.internal_state['E4'] = dcvoltages['vmid']
                    self.internal_state['E5'] = dcvoltages['vbottom']
                    self.internal_state['GND'] = 0
            #updating secular x and y frequencies
            trap2 = iontrap.IonTrap(v_rf, m_over_Ze, omega_rf, dcvoltages, self.filename)
            secularfreqs2, trapaxes2 = trap2.find_omega_secular(dcvoltages, m_over_Ze, omega_rf)[0],trap2.find_omega_secular(dcvoltages, m_over_Ze, omega_rf)[1]

            self.internal_state['SecularY']= round(secularfreqs2['omega_y']/(2*np.pi*1000000),3)
            self.internal_state['SecularX']= round(secularfreqs2['omega_x']/(2*np.pi*1000000),3)

            r_z2 = []
            r_y2 = []
            r_x2 = []
            for i in trapaxes2['z-axis']:
                r_z2.append(round(i,3))
            for i in trapaxes2['y-axis']:
                r_y2.append(round(i,3))
            for i in trapaxes2['x-axis']:
                r_x2.append(round(i,3))
            self.internal_state['TrapAZ']= r_z2
            self.internal_state['TrapAY']= r_y2
            self.internal_state['TrapAX']= r_x2
        except Exception as e:
            print "Error: %s" %(str(e))
            print traceback.format_exc()  
Esempio n. 2
0
    def FindSecularFreqs(self):
        try:
            v_dict={}

            if self.internal_state ['ElectrodeConst'] == 'noconstground' or self.internal_state ['ElectrodeConst'] == 'sideground' or self.internal_state ['ElectrodeConst'] == 'symground':
                v_dict['vg']= self.internal_state['GND']
                if self.internal_state['ElectrodeConst'] == 'noconstground' or self.internal_state['ElectrodeConst']=='double':
                    v_dict['v0']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v1']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v2']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v3']= self.internal_state['E3']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                    v_dict['v4']= self.internal_state['E4']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                    v_dict['v5']= self.internal_state['E5']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                elif self.internal_state['ElectrodeConst'] == 'sideground':
                    v_dict['v0']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v1']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v2']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vside']= self.internal_state['E3']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                elif self.internal_state['ElectrodeConst'] == 'symground':
                    v_dict['vtop']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vmid']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vbottom']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']
            if self.internal_state ['ElectrodeConst'] == 'noconst' or self.internal_state ['ElectrodeConst'] == 'side' or self.internal_state ['ElectrodeConst'] == 'sym':
                if self.internal_state['ElectrodeConst'] == 'noconst':
                    v_dict['v0']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v1']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v2']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v3']= self.internal_state['E3']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                    v_dict['v4']= self.internal_state['E4']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                    v_dict['v5']= self.internal_state['E5']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                elif self.internal_state['ElectrodeConst'] == 'side':
                    v_dict['v0']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v1']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['v2']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vside']= self.internal_state['E3']+self.internal_state['VertComp']-self.internal_state['HorizComp']
                elif self.internal_state['ElectrodeConst'] == 'sym':
                    v_dict['vtop']= self.internal_state['E0']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vmid']= self.internal_state['E1']+self.internal_state['VertComp']+self.internal_state['HorizComp']
                    v_dict['vbottom']= self.internal_state['E2']+self.internal_state['VertComp']+self.internal_state['HorizComp']

            
            m = 1.46e-25                                    # [kg] - Strontium
            Ze = 1.602e-19                                  # [C] - singly ionized
            m_over_Ze = m/Ze                                # [kg/C]
            omega_rf = 2*np.pi*self.internal_state['FreqRF']*1000000        # [Hz] - rf frequency
            v_rf = self.internal_state['VoltRF']                            # [V]

            trap = iontrap.IonTrap(v_rf, m_over_Ze, omega_rf, v_dict, self.filename)
            secularfreqs, trapaxes = trap.find_omega_secular(v_dict, m_over_Ze, omega_rf)[0],trap.find_omega_secular(v_dict, m_over_Ze, omega_rf)[1]
            
            self.internal_state['SecularZ']= round(secularfreqs['omega_z']/(2*np.pi*1000000),3)
            self.internal_state['SecularY']= round(secularfreqs['omega_y']/(2*np.pi*1000000),3)
            self.internal_state['SecularX']= round(secularfreqs['omega_x']/(2*np.pi*1000000),3)

            r_z = []
            r_y = []
            r_x = []
            for i in trapaxes['z-axis']:
                r_z.append(round(i,3))
            for i in trapaxes['y-axis']:
                r_y.append(round(i,3))
            for i in trapaxes['x-axis']:
                r_x.append(round(i,3))
            self.internal_state['TrapAZ']= r_z
            self.internal_state['TrapAY']= r_y
            self.internal_state['TrapAX']= r_x
        except Exception as e:
            print "Error: %s" %(str(e))
            print traceback.format_exc()