Пример #1
0
class RampCurrent(Procedure):
    field  = FloatParameter(unit="T")
    resistance = Quantity(unit="Ohm")

    mag = AMI430("192.168.5.109")
    keith = Keithley2400("GPIB0::25::INSTR")

    def init_instruments(self):
        self.keith.triad()
        self.keith.conf_meas_res(res_range=1e5)
        self.keith.conf_src_curr(comp_voltage=0.4, curr_range=1.0e-5)
        self.keith.current = 2e-6
        self.mag.ramp()

        self.field.assign_method(self.mag.set_field)
        self.resistance.assign_method(self.keith.get_resistance)

        for param in self._parameters:
            self._parameters[param].push()

    def run(self):
        """This is run for each step in a sweep."""
        for param in self._parameters:
            self._parameters[param].push()
        for quant in self._quantities:
            self._quantities[quant].measure()
        logging.info("Field, Resistance: {:f}, {:g}".format(self.field.value, self.resistance.value) )

    def shutdown_instruments(self):
        self.keith.current = 0.0e-5
        self.mag.zero()
Пример #2
0
class RampCurrent(Procedure):
    voltage = FloatParameter(unit="V")
    current = Quantity(unit="A")

    yoko = YokogawaGS200("GPIB0::30::INSTR")

    def init_instruments(self):
        self.yoko.function = "voltage"
        self.yoko.level = 0.0
        self.yoko.output = True

        self.voltage.assign_method(self.yoko.set_level)
        self.current.assign_method(self.yoko.get_sense_value)

        for param in self._parameters:
            self._parameters[param].push()

    def run(self):
        """This is run for each step in a sweep."""
        for param in self._parameters:
            self._parameters[param].push()
        time.sleep(0.5)
        for quant in self._quantities:
            self._quantities[quant].measure()

    def shutdown_instruments(self):
        self.yoko.level = 0.0
        self.yoko.output = False
Пример #3
0
class MeasureLockinVoltage(Procedure):
    set_field = FloatParameter(name="Set Field", unit="G")
    field = Quantity(name="Field", unit="G")
    voltage = Quantity(name="Magnitude", unit="V")

    bop = BOP2020M("GPIB0::1::INSTR")
    lock = SR830("GPIB0::9::INSTR")
    hp = HallProbe("calibration/HallProbe.cal", lock.set_ao1, lock.get_ai1)
    mag = Electromagnet('calibration/GMW.cal', hp.get_field, bop.set_current,
                        bop.get_current)

    def init_instruments(self):
        self.tc_delay = self.lock.measure_delay()
        self.averages = 10

        def lockin_measure():
            time.sleep(self.tc_delay)
            vals = []
            for i in range(self.averages):
                vals.append(self.lock.r)
            return np.mean(vals)

        self.set_field.assign_method(self.mag.set_field)
        self.field.assign_method(self.mag.get_field)
        self.voltage.assign_method(lockin_measure)

        for param in self._parameters:
            self._parameters[param].push()

    def run(self):
        """This is run for each step in a sweep."""
        for param in self._parameters:
            self._parameters[param].push()
        for quant in self._quantities:
            self._quantities[quant].measure()
        logging.info("Field, Lockin Magnitude: {:f}, {:g}".format(
            self.field.value, self.voltage.value))

    def shutdown_instruments(self):
        self.bop.current = 0.0
Пример #4
0
class SwitchingAWG(Procedure):
    """Simple square pulse switching, to and fro, using only AWG pulses."""

    # Parameters
    attempt_number = IntParameter("Switching attempts", default=1024, abstract=True)
    field_setpoint = FloatParameter("Field Setpoint", unit="G")
    pulse_voltage  = FloatParameter("Pulse Amplitude", unit="V")
    pulse_duration = FloatParameter("Pulse Duration", unit="s")

    # Instrument resources
    bop  = BOP2020M("GPIB0::1::INSTR")
    lock = SR865("USB0::0xB506::0x2000::002638::INSTR")
    hp   = HallProbe("calibration/HallProbe.cal", lock.set_ao1, lock.get_ai1)
    mag  = Electromagnet('calibration/GMW.cal', hp.get_field, bop.set_current, bop.get_current)
    pspl = Picosecond10070A("GPIB0::24::INSTR")

    # Quantities
    field = Quantity("Field", unit="G")

    # Traces
    raw_trace = Trace("P")

    # Filters
    clusterer   = Clusterer(input=raw_trace)
    probability = CollapseProbability(input=clusterer)



    def init_instruments(self):

        # AWG Initialization
        arb.set_output(True, channel=1)
        arb.set_output(False, channel=2)
        arb.sample_freq = 12.0e9
        arb.waveform_output_mode = "WSPEED"

        arb.abort()
        arb.delete_all_waveforms()
        arb.reset_sequence_table()

        arb.set_output_route("DC", channel=1)
        arb.voltage_amplitude = 1.0

        arb.set_marker_level_low(0.0, channel=1, marker_type="sync")
        arb.set_marker_level_high(1.5, channel=1, marker_type="sync")

        arb.continuous_mode = False
        arb.gate_mode = False
        arb.sequence_mode = "SCENARIO"
        arb.scenario_advance_mode = "SINGLE"
Пример #5
0
class SwitchingPSPL(Procedure):

    # instrument_settings = {"lock":{"amp":0.1, "freq":167}}

    # These don't correspond to actual instrument parameters, and are thus "abstract"
    attempt_number             = IntParameter("Switching Attempt Index", abstract=True)
    middle_voltage             = FloatParameter("Middle Voltage Value", unit="V", abstract = True)
    high_probability_duration  = FloatParameter("High Probability Duration", unit="s", abstract=True)
    initialization_probability = FloatParameter("Initialization Probability", default=1.0, abstract=True)
    resistance_averages        = IntParameter("Resistance Averages", default=2, abstract=True)

    # These do correspond to instrument parameters
    field_setpoint             = FloatParameter("Field Setpoint", unit="G")
    pulse_voltage              = FloatParameter("Pulse Amplitude", unit="V")
    pulse_duration             = FloatParameter("Pulse Duration", unit="s")

    # Quantities to be measured
    field         = Quantity("Field", unit="G")
    initial_state = Quantity("Initial Voltage", unit="V")
    final_state   = Quantity("Final Voltage", unit="V")

    # Instrument resources
    bop  = BOP2020M("Kepco Power Supply", "GPIB1::1::INSTR")
    lock = SR830("Lockin Amplifier", "GPIB1::9::INSTR")
    hp   = HallProbe("calibration/HallProbe.cal", lock.set_ao1, lock.get_ai1)
    mag  = Electromagnet('calibration/GMW.cal', hp.get_field, bop.set_current, bop.get_current)
    pspl = Picosecond10070A("Pulse Generator", "GPIB1::24::INSTR")

    def init_instruments(self):
        self.tc_delay = self.lock.measure_delay()
        self.pspl.output = True

        def lockin_measure_initial():
            if np.random.random() <= self.initialization_probability.value:
                self.pspl.duration = self.high_probability_duration.value
                time.sleep(0.09) # Required to let the duration settle
                self.pspl.trigger()
                self.pspl.duration = self.pulse_duration.value
                time.sleep(0.09) # Required to let the duration settle
            time.sleep(self.tc_delay)
            return np.mean( [self.lock.r for i in range(self.resistance_averages.value)] )

        def lockin_measure_final():
            self.pspl.trigger()
            time.sleep(self.tc_delay)
            return np.mean( [self.lock.r for i in range(self.resistance_averages.value)] )

        # Associate quantities and parameters with their respective methods
        self.field_setpoint.assign_method(lambda x: setattr(self.mag, 'field', x))
        self.field.assign_method(lambda : getattr(self.mag, 'field'))
        self.initial_state.assign_method(lockin_measure_initial)
        self.final_state.assign_method(lockin_measure_final)
        self.pulse_voltage.assign_method(self.pspl.set_amplitude)
        self.pulse_duration.assign_method(self.pspl.set_duration)

        def find_reset_duration():
            # Search over pulse durations for highest probability reversal
            logging.warning("Finding optimal duration for this pulse amplitude...")

            num_pulses = 40
            durs = np.linspace(0.15e-9, 1.0e-9, 10)
            probs = []

            for dur in durs:
                self.pspl.duration = dur
                ivs = []
                fvs = []
                for i in range(num_pulses):
                    time.sleep(self.tc_delay)
                    v_initial = np.mean( [self.lock.r for i in range(self.resistance_averages.value)] )
                    ivs.append(v_initial)
                    self.pspl.trigger()
                    time.sleep(self.tc_delay)
                    v_final = np.mean( [self.lock.r for i in range(self.resistance_averages.value)] )
                    fvs.append(v_final)
                ivs = np.array(ivs)
                fvs = np.array(fvs)
                initial_states = (ivs-self.middle_voltage.value) > 0.0
                final_states = (fvs-self.middle_voltage.value) > 0.0
                switched = np.logical_xor(initial_states, final_states)
                num_attempts_APtoP = np.sum(initial_states > 0)
                num_attempts_PtoAP = np.sum(initial_states == 0)
                switched_APtoP = np.sum( np.logical_and(switched, initial_states) )
                switched_PtoAP = np.sum( np.logical_and(switched, np.logical_not(initial_states)) )
                if num_attempts_APtoP == 0:
                    prob_APtoP = 0.0
                else:
                    prob_APtoP = switched_APtoP/num_attempts_APtoP
                if num_attempts_PtoAP == 0:
                    prob_PtoAP = 0.0
                else:
                    prob_PtoAP = switched_PtoAP/num_attempts_PtoAP
                probs.append(0.5*(prob_PtoAP + prob_APtoP))
                logging.warning("Found probability {:f} for duration {:g}".format(probs[-1], dur))

            # Set the reset duration to the best available average probability
            self.high_probability_duration.value = durs[np.argmax(probs)]
            self.initialization_probability.value = 0.5/np.max(probs)
            logging.warning("Best probability {:f}".format(self.initialization_probability.value))
            logging.warning("Selected duration {:g}".format(self.high_probability_duration.value))

            # Reset the PSPL to the original duration
            self.pspl.duration = self.pulse_duration.value

        self.pulse_voltage.add_post_push_hook(find_reset_duration)

        for param in self._parameters:
            logging.warning("Pushing parameter {:s}".format(self._parameters[param].name))
            self._parameters[param].push()

    def shutdown_instruments(self):
        self.bop.current = 0.0
        self.pspl.output = False

    def run(self):
        self.initial_state.measure()
        self.final_state.measure()