Exemple #1
0
def setup1():

    # -------------------------------------------------------------------------
    # Channel a: SIPM ---------------------------------------------------------

    enable_a = 1

    source_a_cc = 2 * P('m')
    measure_a_cc = 30

    source_a_rang = 'AUTO'
    measure_a_rang = 'AUTO'

    source_a = 'V'
    measure_a = 'I'

    NPLC_a = 1
    delay_a = 10 * P('s')

    # -------------------------------------------------------------------------
    # Channel b: LED ----------------------------------------------------------

    enable_b = 1

    source_b_cc = 500 * P('u')
    measure_b_cc = 3

    source_b_rang = 'AUTO'
    measure_b_rang = 'AUTO'

    source_b = 'I'
    measure_b = 'V'

    NPLC_b = 1
    delay_b = 10 * P('s')

    return [
        enable_a, source_a_cc, measure_a_cc, source_a_rang, measure_a_rang,
        source_a, measure_a, NPLC_a, delay_a, enable_b, source_b_cc,
        measure_b_cc, source_b_rang, measure_b_rang, source_b, measure_b,
        NPLC_b, delay_b
    ]
Exemple #2
0
def setup2():

    # -------------------------------------------------------------------------
    # RTD ---------------------------------------------------------------------

    four_wire = 1

    source_cc = 300 * P('u')
    measure_cc = 0.3

    source_rang = 'AUTO'
    measure_rang = 2000

    return [four_wire, source_cc, measure_cc, source_rang, measure_rang]
Exemple #3
0
def transformers_criteria():

    # Get directory of .py file
    dir = os.path.dirname(os.path.abspath(__file__))

    flag_noPV = 0
    flag_PV = 1

    # Hours of interest when solving the circuit

    hours = ["9", "10", "11", "12", "13", "14", "15", "16", "17"]

    PV_powers_Plimit = []  # Transformers kva criteria

    print("Running circuit comparisons for Powers - Transformers Criteria\n")
    t_start = time.time()

    # Start the DSS
    dssObj = win32com.client.Dispatch("OpenDSSEngine.DSS")
    if dssObj.Start(0) == False:
        sys.exit("DSS failed to start")
    else:
        #Assign a variable to each of the interfaces
        dssText = dssObj.Text
        dssCircuit = dssObj.ActiveCircuit
        dssSolution = dssCircuit.Solution

    # Clear the DSS
    dssObj.ClearAll()

    # Load circuit
    dssText.Command = "Compile " + dir + "\\ckt24\\ckt24.dss"

    # Transformers nominal kva list
    transformer_kva_nominal = []
    all_elements = dssCircuit.AllElementNames
    transformer_list = [s for s in all_elements if "Transformer" in s]

    # Remove transformers that work over nominal kva in circuit without PV
    # from transformer_list and put them into another list
    transformer_list.remove("Transformer.05410_g2100dl9800")
    transformer_list.remove("Transformer.05410_g2100en2200")
    transformer_list.remove("Transformer.05410_g2100gi2700")
    transformer_list.remove("Transformer.05410_g2100nj7400")
    transformer_list.remove("Transformer.05410_g2101bc7200")
    transformer_list.remove("Transformer.05410_g2102cc0600")

    transformer_list_exceptions = []
    transformer_list_exceptions.append("Transformer.05410_g2100dl9800")
    transformer_list_exceptions.append("Transformer.05410_g2100en2200")
    transformer_list_exceptions.append("Transformer.05410_g2100gi2700")
    transformer_list_exceptions.append("Transformer.05410_g2100nj7400")
    transformer_list_exceptions.append("Transformer.05410_g2101bc7200")
    transformer_list_exceptions.append("Transformer.05410_g2102cc0600")

    for i in range(len(transformer_list)):
        dssCircuit.SetActiveElement(transformer_list[i])
        dssCircuit.Transformers.Name = \
        transformer_list[i].replace("Transformer.","")
        transformer_kva_nominal.append(dssCircuit.Transformers.kva)

    hours = ["9", "10", "11", "12", "13", "14", "15", "16", "17"]

    for season in ["Spring", "Summer", "Autumn", "Winter"]:

        for hour in hours:

            PV_power = 500
            power_iteration = "run again"
            while power_iteration == "run again":

                # Clear the DSS
                dssObj.ClearAll()

                # Load circuit
                dssText.Command = "Compile " + dir + "\\ckt24\\ckt24.dss"

                # Solve circuit in different loadshapes, season based
                dssText.Command = "Edit Loadshape.LS_PhaseA" \
                +" mult=(file=LS_PhaseA_"+season+"Day.txt)"
                dssText.Command = "Edit Loadshape.LS_PhaseB" \
                +" mult=(file=LS_PhaseB_"+season+"Day.txt)"
                dssText.Command = "Edit Loadshape.LS_PhaseC" \
                +" mult=(file=LS_PhaseC_"+season+"Day.txt)"
                dssText.Command = "Edit Loadshape.LS_ThreePhase" \
                +" mult=(file=LS_ThreePhase_"+season+"Day.txt)"
                dssText.Command = "Edit Loadshape.Other_Bus_Load" \
                +" mult=(file=Other_Bus_Load_"+season+"Day.txt)"

                # Change PVSystem parameters to get max power
                dssText.Command = \
                "Redirect "+dir+"\\ckt24\\5PV_new.dss"
                dssText.Command = "Redirect " + dir + "\\ckt24\\5PV_" + season + ".dss"
                dssText.Command = "Edit PVSystem.PV1 kVA=" \
                +str(PV_power)+" pmpp="+str(PV_power)
                dssText.Command = "Edit PVSystem.PV2 kVA=" \
                +str(PV_power)+" pmpp="+str(PV_power)
                dssText.Command = "Edit PVSystem.PV3 kVA=" \
                +str(PV_power)+" pmpp="+str(PV_power)
                dssText.Command = "Edit PVSystem.PV4 kVA=" \
                +str(PV_power)+" pmpp="+str(PV_power)
                dssText.Command = "Edit PVSystem.PV5 kVA=" \
                +str(PV_power)+" pmpp="+str(PV_power)
                dssText.Command = "Edit Transformer.pv_up1 kVA=" \
                +str(PV_power)
                dssText.Command = "Edit Transformer.pv_up2 kVA=" \
                +str(PV_power)
                dssText.Command = "Edit Transformer.pv_up3 kVA=" \
                +str(PV_power)
                dssText.Command = "Edit Transformer.pv_up4 kVA=" \
                +str(PV_power)
                dssText.Command = "Edit Transformer.pv_up5 kVA=" \
                +str(PV_power)

                # Set and calculate voltage bases
                dssText.Command = "Redirect " + dir + "\\ckt24\\ckt24_vbases.dss"
                # Solve circuit
                dssText.Command = "Solve mode=daily number=1 hour=" + hour

                # Results list
                transformer_kva_PV = []

                for transformer in transformer_list:
                    transformer_kva_PV.append(P(transformer, dssCircuit))

                safe_factor = 0.9
                P_flag = 0
                for i in range(len(transformer_list)):
                    if len(transformer_kva_PV[i]) == 8:
                        if  (abs(transformer_kva_PV[i][0]))> \
                        safe_factor*abs(transformer_kva_nominal[i]):
                            P_flag = 1
                    elif len(transformer_kva_PV[i]) == 16:
                        if  (abs(transformer_kva_PV[i][0])+ \
                        abs(transformer_kva_PV[i][2])+ \
                        abs(transformer_kva_PV[i][4]))> \
                        safe_factor*abs(transformer_kva_nominal[i]):
                            P_flag = 1

                if P_flag == 1:
                    PV_powers_Plimit.append([season, hour, PV_power - 500])
                    power_iteration = "stop running"

                if PV_power == 9000:
                    PV_powers_Plimit.append([season, hour, "max_iter_9000"])
                    power_iteration = "stop running"

                PV_power = PV_power + 500

            print("Running simulation of season %s, hour %s..." %
                  (season, hour))
    print()
    print("List with season, hour and maximum power for PVSystem:")
    print(PV_powers_Plimit)
    print()
    PV_powers_Plimit = [int(e[-1]) for e in PV_powers_Plimit]
    print("Minimum value: %d kW" % min(PV_powers_Plimit))
    print()

    t_end = time.time()
    print("Total simulation time (power comparisons - "
          "transformers criteria): %f" % (t_end - t_start))
Exemple #4
0
def SelfHeating(smu_2612b, smu_2400, i_cc_sipm, v_cc_sipm, i_rang_sipm,
                v_rang_sipm, v_level_sipm, i_cc_led, v_cc_led, i_rang_led,
                v_rang_led, iStart, iEnd, fourWire, i_cc_rtd, v_cc_rtd,
                i_rang_rtd, r_rang_rtd, i_level_rtd, return_sweep, N, points,
                delay, curves):
    """
    
    
    
    ---------
    
    """

    NPLC = round(points * 200 * P('u') * 50, 2)

    readingsR = []

    smu_2612b.write('smua.reset()')
    smu_2612b.write('smub.reset()')
    smu_2400.write("*RST")

    smu_2612b.write('format.data = format.ASCII')

    # Buffer operations -------------------------------------------------------

    smu_2612b.write('smua.nvbuffer1.clear()')
    smu_2612b.write('smub.nvbuffer1.clear()')

    smu_2612b.write('smua.nvbuffer1.appendmode = 1')
    smu_2612b.write('smub.nvbuffer1.appendmode = 1')

    smu_2612b.write('smua.nvbuffer1.collectsourcevalues = 1')
    smu_2612b.write('smub.nvbuffer1.collectsourcevalues = 1')

    smu_2612b.write('smua.measure.count = 1')
    smu_2612b.write('smub.measure.count = 1')

    # -------------------------------------------------------------------------
    # smua configuration

    smu_2612b.write('smua.source.func = smua.OUTPUT_DCVOLTS')
    smu_2612b.write('display.smua.measure.func = display.MEASURE_DCAMPS')

    if (i_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.source.autorangei = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.source.rangei = ' + str(i_rang_sipm))

    if (v_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.measure.autorangev = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.measure.rangev = ' + str(v_rang_sipm))

    #compliance values for I and V
    smu_2612b.write('smua.source.limiti = ' + str(i_cc_sipm))
    smu_2612b.write('smua.source.limitv = ' + str(v_cc_sipm))

    smu_2612b.write('smua.source.levelv = ' + str(v_level_sipm))

    smu_2612b.write('smua.measure.nplc = ' + str(NPLC))

    # -------------------------------------------------------------------------
    # smub configuration

    smu_2612b.write('smub.source.func = smub.OUTPUT_DCAMPS')

    if (i_rang_led == 'AUTO'):
        smu_2612b.write('smub.source.autorangei = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.source.rangei = ' + str(i_rang_led))

    if (v_rang_led == 'AUTO'):
        smu_2612b.write('smub.source.autorangev = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.source.rangev = ' + str(v_rang_led))

    #compliance values for I and V
    smu_2612b.write('smub.source.limiti = ' + str(i_cc_led))
    smu_2612b.write('smub.source.limitv = ' + str(v_cc_led))

    #    smu_2612b.write('smub.measure.delay = ' + str(delay))

    #smu_2612b.write('smub.measure.nplc = ' + str(NPLC))

    # -------------------------------------------------------------------------
    # k2400 configuration (R measurement)

    smu_2400.write(':SENS:FUNC "RES"')
    smu_2400.write(':SOUR:FUNC CURR')
    smu_2400.write('SENS:RES:MODE MAN')

    if (i_rang_rtd == 'AUTO'):
        smu_2400.write(':SOUR:CURR:RANG:AUTO ON')
    else:
        smu_2400.write(':SOUR:CURR:RANG ' + str(i_rang_rtd))

    if (r_rang_rtd == 'AUTO'):
        smu_2400.write(':SENS:RES:RANG:AUTO ON')
    else:
        smu_2400.write(':SENS:RES:RANG ' + str(r_rang_rtd))

    smu_2400.write(':SOUR:CURR:LEV ' + str(i_level_rtd))

    smu_2400.write('SENS:CURR:PROT ' + str(i_cc_rtd))
    smu_2400.write('SENS:VOLT:PROT ' + str(v_cc_rtd))

    #smu_2400.write('SENS:CURR:NPLC ' + str(1))

    if fourWire:
        smu_2400.write(':SYST:RSEN ON')

    # -------------------------------------------------------------------------
    # Measurement -------------------------------------------------------------

    import numpy as np

    #calculates logarithmic current sweep
    #    a = (1.0/(N - 1)) * np.log10(iEnd / iStart)
    b = np.arange(0, N, 1)
    #    i_led_values = [iStart * 10**(i*a) for i in b]
    i_led_values = [iStart + (iEnd - iStart) / N * i for i in b]

    smu_2612b.write('smua.source.output = smua.OUTPUT_ON')
    smu_2612b.write('smub.source.output = smub.OUTPUT_ON')

    smu_2400.write('OUTP ON')

    print("Start of measurement")

    for i in range(0, curves):

        #startTime = time.time()
        for j in range(len(i_led_values)):

            smu_2612b.write('smub.source.leveli = ' + str(i_led_values[j]))
            smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
            smu_2612b.write('smua.measure.i(smua.nvbuffer1)')

            auxRead = smu_2400.query(':READ?')
            rtd_r = float(cast(auxRead)[2])
            readingsR.append(rtd_r)
            time.sleep(delay + NPLC / 50.)

        smu_2612b.write('waitcomplete()')

        if return_sweep == 1:

            n = len(i_led_values)
            for j in range(len(i_led_values)):

                smu_2612b.write('smub.source.leveli = ' +
                                str(i_led_values[n - j - 1]))
                smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
                smu_2612b.write('smua.measure.i(smua.nvbuffer1)')

                auxRead = smu_2400.query(':READ?')
                rtd_r = float(cast(auxRead)[2])
                readingsR.append(rtd_r)
                time.sleep(delay + NPLC / 50.)

        smu_2612b.write('waitcomplete()')


#        #startTime = time.time()
#        for j in range(len(i_led_values)):
#
#            smu_2612b.write('smub.source.leveli = ' + str(i_led_values[j]))
#            smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
#            smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
#
#            auxRead = smu_2400.query(':READ?')
#            rtd_r = float(cast(auxRead)[2])
#            readingsR.append(rtd_r)
#            time.sleep(delay + NPLC/50.)
#
#
#        smu_2612b.write('waitcomplete()')
#
#
#        if return_sweep == 1:
#
#            n = len(i_led_values)
#            for j in range(len(i_led_values)):
#
#                smu_2612b.write('smub.source.leveli = ' + str(i_led_values[n - j - 1]))
#                smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
#                smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
#
#                auxRead = smu_2400.query(':READ?')
#                rtd_r = float(cast(auxRead)[2])
#                readingsR.append(rtd_r)
#                time.sleep(delay + NPLC/50.)
#
#
#        smu_2612b.write('waitcomplete()')

    smu_2612b.write('smua.source.output = smua.OUTPUT_OFF')
    smu_2612b.write('smub.source.output = smub.OUTPUT_OFF')
    smu_2400.write('OUTP OFF')

    print("End of measurement")

    readingsV_sipm = cast(readBuffer(smu_2612b, 'a')[1])
    readingsI_sipm = cast(readBuffer(smu_2612b, 'a')[0])

    readingsV_led = cast(readBuffer(smu_2612b, 'b')[0])
    readingsI_led = cast(readBuffer(smu_2612b, 'b')[1])

    return [
        readingsV_sipm, readingsI_sipm, readingsV_led, readingsI_led, readingsR
    ]
Exemple #5
0
from k2612B import run
from functions import P

#script for saving secuential measurements automatically for k2612B and k2400
#optimal values for 'iv': N = 50, wait_time = 0.01
#                   'led1': N = 50, wait_time < 0.01
#                   'led2': N = 1, wait_time = 0.1, measurements = 10000
#                    (total time of measurement would be 1000s measured in [ms])

N = 1
wait_time = 10*P('m')
group_path = '10ms'

#modes available: 'iv', 'led1', 'led2' (refer to help for specifics)
mode = 'led1'

plotFlag = 1
saveFlag = 1

for j in range(1, N + 1):
    run(j, mode, group_path, plotFlag, saveFlag, wait_time)
    
#%%
from k2612B import run
from functions import P
import time   

N = 1
wait_time = [100*P('n'), 1*P('u'), 10*P('u'), 100*P('u'), 1*P('m'), 10*P('m'), 25*P('m'), 50*P('m'), 75*P('m'), 100*P('m')]
folders = ["1e-7", "1e-6", "1e-5", "0.0001", "0.001", "0.01", "0.025", "0.05", "0.075", "0.1"]
Exemple #6
0
def setup():
    from functions import P

    # -------------------------------------------------------------------------
    # Modifiable values ('iv' test and 'led' test)
    # -------------------------------------------------------------------------

    #for smua only (r measurement) --------------------------------------------

    fourWire = 1  # 1 for 4-wire sensing
    i_cca = 300 * P('u')
    v_cca = 0.3

    iRanga = 100 * P('u')
    vRanga = 0.2

    iLevela = 97 * P('u')

    # -------------------------------------------------------------------------
    #for smub only (iv curve measurement) -------------------------------------

    i_ccb = 155 * P('m')
    v_ccb = 3

    iRangb = 'AUTO'
    vRangb = 'AUTO'

    source = 'I'  #source function for smub ('iv') measurement

    vStart = 22.75
    vEnd = 25
    vStep = 10 * P('m')

    # -------------------------------------------------------------------------
    #I sweep used for led in 'led' mode and for sipm in 'iv' mode -------------

    iStart = 0 * P('m')
    iEnd = 190 * P('m')
    iStep = 2 * P('m')

    # -------------------------------------------------------------------------
    # for led2 test only ------------------------------------------------------

    v_cc_led = 2.5
    #remember wait_time functions as a "time step" here. Total time = measurements*wait_time
    measurements = 1000

    # -------------------------------------------------------------------------
    # return sweep on led1 test -----------------------------------------------

    return_sweep = 1

    # -------------------------------------------------------------------------
    # miscellaneous -----------------------------------------------------------

    NPLC = 1  #integration time for k2612b (default = 1, higher for better accuracy)

    # -------------------------------------------------------------------------
    # End of setup
    # -------------------------------------------------------------------------

    return [
        fourWire, i_cca, v_cca, iRanga, vRanga, iLevela, i_ccb, v_ccb, iRangb,
        vRangb, vStart, vEnd, vStep, iStart, iEnd, iStep, source, v_cc_led,
        NPLC, return_sweep, measurements
    ]
Exemple #7
0
def setup():
    from functions import P

    # -------------------------------------------------------------------------
    # Modifiable values
    # -------------------------------------------------------------------------

    # -------------------------------------------------------------------------
    # i_SIPM measurement ------------------------------------------------------

    i_cc_sipm = 18 * P('m')
    v_cc_sipm = 30.5

    i_rang_sipm = 'AUTO'
    v_rang_sipm = 'AUTO'

    v_level_sipm = 0

    # -------------------------------------------------------------------------
    # i_LED measurement -------------------------------------------------------

    i_cc_led = 250 * P('u')
    v_cc_led = 2.6

    i_rang_led = 'AUTO'
    v_rang_led = 'AUTO'

    # -------------------------------------------------------------------------
    # sweep setup -------------------------------------------------------------

    start = -1
    end = 30

    # -------------------------------------------------------------------------
    # RTD measurement ---------------------------------------------------------

    fourWire = 1

    i_cc_rtd = 300 * P('u')
    v_cc_rtd = 0.3

    i_rang_rtd = 'AUTO'
    r_rang_rtd = 2000

    i_level_rtd = 97 * P('u')

    # -------------------------------------------------------------------------

    return_sweep = 0

    # number of measurements

    N = 100.0

    points = 100  # measurements per point in curve, 100 for NPLC = 1

    delay = 10 * P('m')

    curves = 1

    # -------------------------------------------------------------------------
    # End of setup
    # -------------------------------------------------------------------------

    return [
        i_cc_sipm, v_cc_sipm, i_rang_sipm, v_rang_sipm, v_level_sipm, i_cc_led,
        v_cc_led, i_rang_led, v_rang_led, start, end, fourWire, i_cc_rtd,
        v_cc_rtd, i_rang_rtd, r_rang_rtd, i_level_rtd, return_sweep, N, points,
        delay, curves
    ]
Exemple #8
0
def setup():
    from functions import P
    
    # -------------------------------------------------------------------------
    # Modifiable values 
    # -------------------------------------------------------------------------
   
    # -------------------------------------------------------------------------
    # i_SIPM measurement ------------------------------------------------------
    
    i_cc_sipm      = 2*P('m')
    v_cc_sipm      = 30
    
    i_rang_sipm    = 'AUTO'
    v_rang_sipm    = 'AUTO'
    
    v_level_sipm   = 27.3
    
    # -------------------------------------------------------------------------
    # i_LED measurement -------------------------------------------------------
    
    i_cc_led       = 500*P('u')
    v_cc_led       = 3
    
    i_rang_led     = 'AUTO'
    v_rang_led     = 'AUTO'
   
    iStart         = 100*P('u')
    iEnd           = 235*P('u')
	
	 # -------------------------------------------------------------------------
	 # RTD measurement ---------------------------------------------------------
	
    fourWire	    = 1
	
    i_cc_rtd       = 300*P('u')
    v_cc_rtd       = 0.3
    
    i_rang_rtd     = 'AUTO'
    r_rang_rtd     = 2000
    
    i_level_rtd    = 97*P('u')
	
	# ------------------------------------------------------------------------- 
    
    return_sweep   = 1
	
    # number of measurements
    
    N			       = 135

    points         = 16          # measurements per point in curve
	
    delay		    = 10*P('m')
    
    curves         = 1

   
    # -------------------------------------------------------------------------
    # End of setup
    # -------------------------------------------------------------------------

    
    return [i_cc_sipm,
        		v_cc_sipm,
            i_rang_sipm,
        		v_rang_sipm,
        		v_level_sipm,
        		i_cc_led,
        		v_cc_led,
        		i_rang_led,
        		v_rang_led,
        		iStart,
        		iEnd,
        		fourWire,
        		i_cc_rtd,
        		v_cc_rtd,
        		i_rang_rtd,
        		r_rang_rtd, 
        		i_level_rtd,
        		return_sweep,
            N,
        		points,
        		delay,
            curves]
Exemple #9
0
from k2612B import run
from functions import P
import time

#script for saving secuential measurements automatically for k2612B and k2400
#optimal values for 'iv': N = 50, wait_time = 0.01
#                   'led1': N = 50, wait_time < 0.01
#                   'led2': N = 1, wait_time = 0.01, measurements = 10000
#                    (total time of measurement would be 100s)
#                   'led3': N = 50, wait_time = 0.01

N = 1
wait_time = 6 * P('m')
group_path = 'Auto calentamiento, dt = 6ms, NPLC = 0.1, espera 10s, datos=6 BIS'

#modes available: 'iv', 'led1', 'led2' (refer to help for specifics)
mode = 'led1'
NPLC = 0.001
iPolarization_led = "none"

plotFlag = 1
saveFlag = 0

for j in range(1, N + 1):
    run(j, mode, group_path, plotFlag, saveFlag, wait_time, NPLC,
        iPolarization_led)
    #time.sleep(10)

#%%  # ESTA FUNCION ES PARA MEDIR UNA CURVA ISIPM ILED EN FUNCION DEL WAIT TIME.
from k2612B import run
from functions import P
Exemple #10
0
def run(n, mode, group_path, plotFlag, saveFlag, wait_time):

    # Loading setups configurations
    config = setup()

    #rm-list_resources() to find address for smu
    address_2612b = 26
    address_2400 = 24

    clear_all()

    #running tests (smua measures iv and smub measures r)

    if mode == 'iv':
        [smu, rm] = gpib(address_2612b)

        [readingsV, readingsI, readingsR, readingsIR
         ] = ivr(smu, config[0], config[1], config[2], config[3], config[4],
                 config[5], config[6], config[7], config[8], config[9],
                 config[10], config[11], config[12], config[13], config[14],
                 config[15], config[16], config[18], wait_time)

        smu.write('reset()')

        smu.write('smua.nvbuffer1.clear()')
        smu.write('smub.nvbuffer1.clear()')

        rm.close

        Number = []
        for i in range(0, len(readingsR)):
            Number.append(i)

        if plotFlag == 1:
            graphR = plot(Number, readingsR, 'N', 'R', 1)
            graphIV = plot(readingsV, readingsI, 'V', 'I', 2)
        else:
            graphR = 'NULL'
            graphIV = 'NULL'

        if saveFlag == 1:
            save(readingsV, readingsI, readingsR, readingsIR, graphIV, graphR,
                 n, group_path)

        return

    elif mode == 'led1':

        [smu_2612b, smu_2400, rm] = gpib2(address_2612b, address_2400)

        #polarization voltage for sipm on led1 test
        vPolarization_sipm = 30

        [readingsI_sipm, readingsV_led, readingsI_led, readingsR, readingsIR
         ] = led1(smu_2612b, smu_2400, config[0], config[1], config[2],
                  config[3], config[4], config[5], config[6], config[7],
                  config[8], config[9], config[13], config[14], config[15],
                  config[19], vPolarization_sipm, wait_time)

        smu_2612b.write('reset()')

        smu_2612b.write('smua.nvbuffer1.clear()')
        smu_2612b.write('smub.nvbuffer1.clear()')
        smu_2400.write('*CLS')

        rm.close

        Number = []
        for i in range(0, len(readingsR)):
            Number.append(i)

        if plotFlag == 1:
            graphR = plot(Number, readingsR, 'N', 'R', 1)
            graphIV = plot(readingsI_led, readingsI_sipm, 'Iled', 'Isipm', 2)
        else:
            graphR = 'NULL'
            graphIV = 'NULL'

        if saveFlag == 1:
            save_led(readingsI_sipm, readingsV_led, readingsI_led, readingsR,
                     readingsIR, graphIV, graphR, n, group_path)

        return

    elif mode == 'led2':

        [smu_2612b, smu_2400, rm] = gpib2(address_2612b, address_2400)

        #polarization current for led on led2 test
        iPolarization_led = 100 * P('m')
        vPolarization_sipm = 30

        [readingsI_sipm, readingsV_led, readingsR, readingsIR
         ] = led2(smu_2612b, smu_2400, config[0], config[1], config[2],
                  config[3], config[4], config[5], config[6], config[7],
                  config[8], config[9], config[17], config[20],
                  vPolarization_sipm, iPolarization_led, wait_time)

        smu_2612b.write('reset()')

        smu_2612b.write('smua.nvbuffer1.clear()')
        smu_2612b.write('smub.nvbuffer1.clear()')
        smu_2400.write('*CLS')

        rm.close

        Time = []
        for i in range(0, len(readingsR)):
            Time.append(i * wait_time)

        if plotFlag == 1:
            graphR = plot(Time, readingsR, 't', 'R', 1)
            graphI = plot(Time, readingsI_sipm, 't', 'Isipm', 2)
        else:
            graphR = 'NULL'
            graphI = 'NULL'

        if saveFlag == 1:
            save_led(Time, readingsI_sipm, readingsV_led, readingsR,
                     readingsIR, graphI, graphR, n, group_path)

        return
Exemple #11
0
def setup():
    from functions import P

    # -------------------------------------------------------------------------
    # Modifiable values ('iv' test and 'led' test)
    # -------------------------------------------------------------------------

    #for smua only (r measurement) --------------------------------------------

    fourWire = 1  # 1 for 4-wire sensing
    i_cca = 300 * P('u')
    v_cca = 0.3

    iRanga = 'AUTO'
    vRanga = 'AUTO'

    iLevela = 97 * P('u')

    # -------------------------------------------------------------------------
    #for smub only (iv curve measurement) -------------------------------------

    i_ccb = 200 * P('m')
    v_ccb = 2

    iRangb = 'AUTO'
    vRangb = 'AUTO'

    source = 'I'  #source function for smub ('iv' mode) measurement

    vStart = 0
    vEnd = 1
    vStep = 20 * P('m')

    # -------------------------------------------------------------------------
    # return sweep on 'led1' test -----------------------------------------------

    return_sweep = 1

    # -------------------------------------------------------------------------
    #I sweep used for led in 'led' mode and for sipm in 'iv' mode -------------

    iStart = 0 * P('m')
    iEnd = 20 * P('m')
    iStep = 300 * P('u')

    # -------------------------------------------------------------------------
    # for led2 test only ------------------------------------------------------

    v_cc_led = 2

    #wait_time functions as a "time step". Total time = measurements*wait_time
    measurements = 100

    # -------------------------------------------------------------------------
    # miscellaneous -----------------------------------------------------------

    NPLC = 0.001  #integration time for k2612b (0.01 - 25)

    # -------------------------------------------------------------------------
    # End of setup
    # -------------------------------------------------------------------------

    return [
        fourWire, i_cca, v_cca, iRanga, vRanga, iLevela, i_ccb, v_ccb, iRangb,
        vRangb, vStart, vEnd, vStep, iStart, iEnd, iStep, source, v_cc_led,
        NPLC, return_sweep, measurements
    ]
Exemple #12
0
def IVComplete(smu_2612b, config):
    """
    
    
    
    ---------
    
    """

    [
        i_cc_sipm, v_cc_sipm, i_rang_sipm, v_rang_sipm, v_level_sipm, i_cc_led,
        v_cc_led, i_rang_led, v_rang_led, vStart, vEnd, return_sweep, N,
        points, delay, curves
    ] = config

    i_led_level = 500 * P('n')

    NPLC = round(points * 200 * P('u') * 50, 2)

    smu_2612b.write('reset()')
    smu_2612b.write('smua.reset()')
    smu_2612b.write('smub.reset()')

    smu_2612b.write('format.data = format.ASCII')

    smu_2612b.write('iv_buffer = smua.makebuffer(%s)' % 2 * N)

    # Buffer operations -------------------------------------------------------

    #    smu_2612b.write('smua.nvbuffer1.clear()')
    #    smu_2612b.write('smub.nvbuffer1.clear()')
    #
    #    smu_2612b.write('smua.nvbuffer1.appendmode = 1')
    #
    #    smu_2612b.write('smua.nvbuffer1.fillcount = ' + str(2*N))
    #
    #    smu_2612b.write('smua.nvbuffer1.collectsourcevalues = 1')
    #
    #    smu_2612b.write('smua.measure.count = 1')
    #
    #    smu_2612b.write('smua.nvbuffer1.clear()')
    #    smu_2612b.write('smub.nvbuffer1.clear()')

    smu_2612b.write('smua.iv_buffer.appendmode = 1')

    smu_2612b.write('smua.iv_buffer.collectsourcevalues = 1')

    smu_2612b.write('smua.measure.count = 1')

    # -------------------------------------------------------------------------
    # smua configuration (SiPM)

    smu_2612b.write('smua.source.func = smua.OUTPUT_DCVOLTS')
    smu_2612b.write('display.smua.measure.func = display.MEASURE_DCAMPS')

    if (i_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.source.autorangei = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.source.rangei = ' + str(i_rang_sipm))

    if (v_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.measure.autorangev = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.measure.rangev = ' + str(v_rang_sipm))

    #compliance values for I and V
    smu_2612b.write('smua.source.limiti = ' + str(i_cc_sipm))
    smu_2612b.write('smua.source.limitv = ' + str(v_cc_sipm))

    smu_2612b.write('smua.measure.nplc = ' + str(NPLC))

    smu_2612b.write('smua.measure.delay = ' + str(delay))

    # -------------------------------------------------------------------------
    # smua configuration (SiPM)

    smu_2612b.write('smub.source.func = smub.OUTPUT_DCAMPS')
    smu_2612b.write('display.smub.measure.func = display.MEASURE_DCVOLTS')

    if (i_rang_led == 'AUTO'):
        smu_2612b.write('smub.source.autorangei = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.source.rangei = ' + str(i_rang_led))

    if (v_rang_led == 'AUTO'):
        smu_2612b.write('smub.measure.autorangev = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.measure.rangev = ' + str(v_rang_led))

    #compliance values for I and V
    smu_2612b.write('smub.source.limiti = ' + str(i_cc_led))
    smu_2612b.write('smub.source.limitv = ' + str(v_cc_led))

    smu_2612b.write('smub.source.leveli = ' + str(0))

    import numpy as np

    # allowed voltage values in sweep
    b = np.arange(0, N, 1)
    v_sipm_values1 = [vStart - (vStart) / N * i for i in b]
    v_sipm_values2 = [20 + (vEnd - 20) / N * i for i in b]

    v_sipm_values = np.concatenate((v_sipm_values1, v_sipm_values2))

    smu_2612b.write('smua.source.output = smua.OUTPUT_ON')
    smu_2612b.write('smub.source.output = smub.OUTPUT_ON')

    print("Start of measurement")

    for i in range(0, curves):

        #startTime = time.time()
        for j in range(len(v_sipm_values)):

            smu_2612b.write('smua.source.levelv = ' + str(v_sipm_values[j]))
            #smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
            smu_2612b.write('smua.measure.i(smua.iv_buffer)')
            time.sleep(delay)

            if j != len(v_sipm_values) - 1:
                if (v_sipm_values[j + 1] - v_sipm_values[j]) > 10:
                    smu_2612b.write('smub.source.leveli = ' + str(i_led_level))

        smu_2612b.write('waitcomplete()')
        smu_2612b.write('smub.source.leveli = ' + str(0))

        if return_sweep == 1:

            n = len(v_sipm_values)
            for j in range(len(v_sipm_values)):

                smu_2612b.write('smua.source.levelv = ' +
                                str(v_sipm_values[n - j - 1]))
                #smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
                smu_2612b.write('smua.measure.i(smua.iv_buffer)')
                time.sleep(delay)

                if j != len(v_sipm_values) - 1:
                    if (v_sipm_values[j + 1] - v_sipm_values[j]) > 10:
                        smu_2612b.write('smub.source.leveli = ' +
                                        str(i_led_level))

            smu_2612b.write('waitcomplete()')
            smu_2612b.write('smub.source.leveli = ' + str(0))

    time.sleep(5)

    smu_2612b.write('smua.source.output = smua.OUTPUT_OFF')
    smu_2612b.write('smub.source.output = smub.OUTPUT_OFF')

    print("End of measurement")

    #    readingsV_sipm = cast(readBuffer(smu_2612b, 'a')[1])
    #    readingsI_sipm = cast(readBuffer(smu_2612b, 'a')[0])
    readingsV_sipm = cast(readBuffer(smu_2612b, 'a', 'iv_buffer')[1])
    readingsI_sipm = cast(readBuffer(smu_2612b, 'a', 'iv_buffer')[0])

    smu_2612b.write('iv_buffer = nil')

    return [readingsV_sipm, readingsI_sipm]
Exemple #13
0
def LEDTest(smu_2612b, config):
    """
    
    
    
    ---------
    
    """

    [
        i_cc_sipm, v_cc_sipm, i_rang_sipm, v_rang_sipm, v_level_sipm, i_cc_led,
        v_cc_led, i_rang_led, v_rang_led, _, _, return_sweep, N, points, delay,
        curves
    ] = config

    iStart = 0
    iEnd = 800 * P('n')

    NPLC = round(points * 200 * P('u') * 50, 2)

    smu_2612b.write('reset()')
    smu_2612b.write('smua.reset()')
    smu_2612b.write('smub.reset()')

    smu_2612b.write('format.data = format.ASCII')

    smu_2612b.write('led_buffer1 = smua.makebuffer(%s)' % N)
    smu_2612b.write('led_buffer2 = smub.makebuffer(%s)' % N)

    # Buffer operations -------------------------------------------------------

    #    smu_2612b.write('smua.nvbuffer1.clear()')
    #    smu_2612b.write('smub.nvbuffer1.clear()')
    #
    #    smu_2612b.write('smua.nvbuffer1.appendmode = 1')
    #    smu_2612b.write('smub.nvbuffer1.appendmode = 1')
    #
    #    smu_2612b.write('smua.nvbuffer1.collectsourcevalues = 1')
    #    smu_2612b.write('smub.nvbuffer1.collectsourcevalues = 1')
    #
    #    smu_2612b.write('smua.nvbuffer1.fillcount = ' + str(N))
    #    smu_2612b.write('smub.nvbuffer1.fillcount = ' + str(N))
    #
    #    smu_2612b.write('smua.measure.count = 1')
    #    smu_2612b.write('smub.measure.count = 1')
    #
    #
    #    smu_2612b.write('smua.nvbuffer1.clear()')
    #    smu_2612b.write('smub.nvbuffer1.clear()')

    smu_2612b.write('led_buffer1.appendmode = 1')
    smu_2612b.write('led_buffer2.appendmode = 1')

    smu_2612b.write('led_buffer1.collectsourcevalues = 1')
    smu_2612b.write('led_buffer2.collectsourcevalues = 1')

    smu_2612b.write('smua.measure.count = 1')
    smu_2612b.write('smub.measure.count = 1')

    # -------------------------------------------------------------------------
    # smua configuration (SiPM)

    smu_2612b.write('smua.source.func = smua.OUTPUT_DCVOLTS')
    smu_2612b.write('display.smua.measure.func = display.MEASURE_DCAMPS')

    if (i_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.source.autorangei = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.source.rangei = ' + str(i_rang_sipm))

    if (v_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.measure.autorangev = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.measure.rangev = ' + str(v_rang_sipm))

    #compliance values for I and V
    smu_2612b.write('smua.source.limiti = ' + str(i_cc_sipm))
    smu_2612b.write('smua.source.limitv = ' + str(v_cc_sipm))

    smu_2612b.write('smua.measure.nplc = ' + str(NPLC))

    smu_2612b.write('smua.source.levelv = 30')

    # -------------------------------------------------------------------------
    # smub configuration (LED)

    smu_2612b.write('smub.source.func = smub.OUTPUT_DCAMPS')
    smu_2612b.write('display.smub.measure.func = display.MEASURE_DCVOLTS')

    if (i_rang_led == 'AUTO'):
        smu_2612b.write('smub.source.autorangei = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.source.rangei = ' + str(i_rang_led))

    if (v_rang_led == 'AUTO'):
        smu_2612b.write('smub.measure.autorangev = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.measure.rangev = ' + str(v_rang_led))

    #compliance values for I and V
    smu_2612b.write('smub.source.limiti = ' + str(i_cc_led))
    smu_2612b.write('smub.source.limitv = ' + str(v_cc_led))

    smu_2612b.write('smub.measure.nplc = ' + str(NPLC))

    smu_2612b.write('smub.measure.delay = ' + str(delay))

    import numpy as np

    # allowed voltage values in sweep
    b = np.arange(0, N, 1)
    i_led_values = [iStart + (iEnd - iStart) / N * i for i in b]

    #can code i_led_values with log scale too

    smu_2612b.write('smua.source.output = smua.OUTPUT_ON')
    smu_2612b.write('smub.source.output = smub.OUTPUT_ON')

    print("Start of measurement")

    for i in range(0, curves):

        #startTime = time.time()
        for j in range(len(i_led_values)):

            smu_2612b.write('smub.source.leveli = ' + str(i_led_values[j]))

            smu_2612b.write('smua.measure.i(led_buffer1)')
            smu_2612b.write('smub.measure.v(led_buffer2)')
            #            smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
            #            smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
            time.sleep(delay)

        smu_2612b.write('waitcomplete()')

        if return_sweep == 1:

            n = len(i_led_values)
            for j in range(len(i_led_values)):

                smu_2612b.write('smub.source.leveli = ' +
                                str(i_led_values[n - j - 1]))

                smu_2612b.write('smua.measure.i(led_buffer1)')
                smu_2612b.write('smub.measure.v(led_buffer2)')
                #                smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
                #                smu_2612b.write('smub.measure.v(smub.nvbuffer1)')
                time.sleep(delay)

            smu_2612b.write('waitcomplete()')

    smu_2612b.write('smua.source.output = smua.OUTPUT_OFF')
    smu_2612b.write('smub.source.output = smub.OUTPUT_OFF')

    print("End of measurement")
    time.sleep(3)

    readingsI_sipm = cast(readBuffer(smu_2612b, 'a', 'led_buffer1')[0])
    readingsI_led = cast(readBuffer(smu_2612b, 'b', 'led_buffer2')[1])
    readingsV_led = cast(readBuffer(smu_2612b, 'b', 'led_buffer2')[0])

    smu_2612b.write('led_buffer1 = nil')
    smu_2612b.write('led_buffer2 = nil')

    return [readingsI_sipm, readingsI_led, readingsV_led]
Exemple #14
0
def IVComplete(smu_2612b, smu_2400, config):
    
    """
    
    
    
    ---------
    
    """
    
    [i_cc_sipm,
    v_cc_sipm,
    i_rang_sipm,
   	v_rang_sipm,
	v_level_sipm,
	i_cc_led,
	v_cc_led,
	i_rang_led,
	v_rang_led,
	vStart,
	vEnd,
	fourWire,
	i_cc_rtd,
	v_cc_rtd,
	i_rang_rtd,
	r_rang_rtd, 
	i_level_rtd,
	return_sweep,
    N,
	points,
	delay,
    curves] = config
     
     
    i_led_level = 210*P('u')
    
    NPLC = round(points*200*P('u')*50, 2)

    readingsR = []
    
    smu_2612b.write('smua.reset()')
    smu_2612b.write('smub.reset()')
    smu_2400.write("*RST")
    
    smu_2612b.write('format.data = format.ASCII')
    
    # Buffer operations -------------------------------------------------------
    
    smu_2612b.write('smua.nvbuffer1.clear()')
    smu_2612b.write('smub.nvbuffer1.clear()')
    
    smu_2612b.write('smua.nvbuffer1.appendmode = 1')
    smu_2612b.write('smub.nvbuffer1.appendmode = 1')
    
    smu_2612b.write('smua.nvbuffer1.collectsourcevalues = 1')
    smu_2612b.write('smub.nvbuffer1.collectsourcevalues = 1')

    smu_2612b.write('smua.measure.count = 1')
    smu_2612b.write('smub.measure.count = 1')
    

    # -------------------------------------------------------------------------   
    # smua configuration (SiPM)
    
    smu_2612b.write('smua.source.func = smua.OUTPUT_DCVOLTS')
    smu_2612b.write('display.smua.measure.func = display.MEASURE_DCAMPS')
    
    if (i_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.source.autorangei = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.source.rangei = ' + str(i_rang_sipm))
    
    if (v_rang_sipm == 'AUTO'):
        smu_2612b.write('smua.measure.autorangev = smua.AUTORANGE_ON')
    else:
        smu_2612b.write('smua.measure.rangev = ' + str(v_rang_sipm))

    #compliance values for I and V
    smu_2612b.write('smua.source.limiti = ' + str(i_cc_sipm))
    smu_2612b.write('smua.source.limitv = ' + str(v_cc_sipm))
	
    smu_2612b.write('smua.measure.nplc = ' + str(NPLC))
    
    smu_2612b.write('smua.measure.delay = ' + str(delay))
    
    # -------------------------------------------------------------------------   
    # smua configuration (SiPM)
    
    smu_2612b.write('smub.source.func = smub.OUTPUT_DCAMPS')
    smu_2612b.write('display.smub.measure.func = display.MEASURE_DCVOLTS')
    
    if (i_rang_led == 'AUTO'):
        smu_2612b.write('smub.source.autorangei = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.source.rangei = ' + str(i_rang_led))
    
    if (v_rang_led == 'AUTO'):
        smu_2612b.write('smub.measure.autorangev = smub.AUTORANGE_ON')
    else:
        smu_2612b.write('smub.measure.rangev = ' + str(v_rang_led))

    #compliance values for I and V
    smu_2612b.write('smub.source.limiti = ' + str(i_cc_led))
    smu_2612b.write('smub.source.limitv = ' + str(v_cc_led))
    
    smu_2612b.write('smub.source.leveli = ' + str(0))
        
    # -------------------------------------------------------------------------
    # k2400 configuration (R measurement)

    smu_2400.write(':SENS:FUNC "RES"')
    smu_2400.write(':SOUR:FUNC CURR')
    smu_2400.write('SENS:RES:MODE MAN')
	
    if (i_rang_rtd == 'AUTO'):
        smu_2400.write(':SOUR:CURR:RANG:AUTO ON')
    else:
        smu_2400.write(':SOUR:CURR:RANG ' + str(i_rang_rtd))
		
    if (r_rang_rtd == 'AUTO'):
        smu_2400.write(':SENS:RES:RANG:AUTO ON')
    else:
        smu_2400.write(':SENS:RES:RANG ' + str(r_rang_rtd))
	   

    smu_2400.write(':SOUR:CURR:LEV ' + str(i_level_rtd))
    
    smu_2400.write('SENS:CURR:PROT ' + str(i_cc_rtd))
    smu_2400.write('SENS:VOLT:PROT ' + str(v_cc_rtd))
    
    #smu_2400.write('SENS:CURR:NPLC ' + str(1))
	
    if fourWire:
        smu_2400.write(':SYST:RSEN ON')
        
    import numpy as np
    
    # allowed voltage values in sweep
    b = np.arange(0, N, 1)
    v_sipm_values1 = [vStart - (vStart)/N*i for i in b]
    
    
    v_sipm_values2 = [20 + (vEnd - 20)/N*i for i in b]
   
    v_sipm_values = np.concatenate((v_sipm_values1, v_sipm_values2))

    smu_2612b.write('smua.source.output = smua.OUTPUT_ON')
    smu_2400.write('OUTP ON')
    
    print("Start of measurement")
    
    for i in range(0, curves):
    
        #startTime = time.time()
        for j in range(len(v_sipm_values)):
            
            smu_2612b.write('smua.source.levelv = ' + str(v_sipm_values[j]))
            smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
            
            auxRead = smu_2400.query(':READ?')
            rtd_r = float(cast(auxRead)[2])
            readingsR.append(rtd_r)
            time.sleep(delay + NPLC/50.)
            
            if j != len(v_sipm_values) - 1:
                if (v_sipm_values[j + 1] - v_sipm_values[j]) > 10:
                        smu_2612b.write('smub.source.output = smub.OUTPUT_ON') 
                        smu_2612b.write('smub.source.leveli = ' + str(i_led_level)) 
                
    
    
        smu_2612b.write('waitcomplete()')
        smu_2612b.write('smub.source.leveli = ' + str(0)) 
        
        if return_sweep == 1:
            
            n = len(v_sipm_values)
            for j in range(len(v_sipm_values)):
                
                smu_2612b.write('smua.source.levelv = ' + str(v_sipm_values[n - j - 1]))
                smu_2612b.write('smua.measure.i(smua.nvbuffer1)')
                            
                auxRead = smu_2400.query(':READ?')
                rtd_r = float(cast(auxRead)[2])
                readingsR.append(rtd_r)
                time.sleep(delay + NPLC/50.)
                
                if j != len(v_sipm_values) - 1:
                    if (v_sipm_values[j + 1] - v_sipm_values[j]) > 10:
                       smu_2612b.write('smub.source.leveli = ' + str(i_led_level)) 

    
            smu_2612b.write('waitcomplete()')
            smu_2612b.write('smub.source.leveli = ' + str(0)) 
            
    smu_2612b.write('smua.source.output = smua.OUTPUT_OFF')
    smu_2612b.write('smub.source.output = smub.OUTPUT_OFF')
    smu_2400.write('OUTP OFF')
    
    print("End of measurement")
    
    readingsV_sipm = cast(readBuffer(smu_2612b, 'a')[1])
    readingsI_sipm = cast(readBuffer(smu_2612b, 'a')[0]) 

    return [readingsV_sipm, readingsI_sipm, readingsR]
Exemple #15
0
def main():

    # Get directory of .py file
    dir = os.path.dirname(os.path.abspath(__file__))

    # Start the DSS
    dssObj = win32com.client.Dispatch("OpenDSSEngine.DSS")
    if dssObj.Start(0) == False:
        sys.exit("DSS failed to start")
    else:
        #Assign a variable to each of the interfaces
        dssText = dssObj.Text
        dssCircuit = dssObj.ActiveCircuit
        dssSolution = dssCircuit.Solution

    # Clear the DSS
    dssObj.ClearAll()

    # Load circuit
    dssText.Command = "Compile " + dir + "\\ckt24\\ckt24.dss"

    transformer_kva_nominal = []
    all_elements = dssCircuit.AllElementNames
    transformer_list = [s for s in all_elements if "Transformer" in s]
    for i in range(len(transformer_list)):
        dssCircuit.SetActiveElement(transformer_list[i])
        dssCircuit.Transformers.Name = \
        transformer_list[i].replace("Transformer.","")
        transformer_kva_nominal.append(dssCircuit.Transformers.kva)

    # Solve circuit in different loadshapes, season based
    dssText.Command = "Edit Loadshape.LS_PhaseA" \
    +" mult=(file=LS_PhaseA_SummerDay.txt)"
    dssText.Command = "Edit Loadshape.LS_PhaseB" \
    +" mult=(file=LS_PhaseB_SummerDay.txt)"
    dssText.Command = "Edit Loadshape.LS_PhaseC" \
    +" mult=(file=LS_PhaseC_SummerDay.txt)"
    dssText.Command = "Edit Loadshape.LS_ThreePhase" \
    +" mult=(file=LS_ThreePhase_SummerDay.txt)"
    dssText.Command = "Edit Loadshape.Other_Bus_Load" \
    +" mult=(file=Other_Bus_Load_SummerDay.txt)"

    # Set and calculate voltage bases
    dssText.Command = "Redirect " + dir + "\\ckt24\\ckt24_vbases.dss"

    # Solve circuit
    dssText.Command = "Solve mode=daily number=1 hour=15"

    transformer_kva_ckt = []
    for transformer in transformer_list:
        transformer_kva_ckt.append(P(transformer, dssCircuit))

    transformer_compare = []
    for i in range(len(transformer_list)):
        t = []
        t.append(transformer_list[i])
        t.append(transformer_kva_nominal[i])
        if len(transformer_kva_ckt[i]) == 8:
            t.append(transformer_kva_ckt[i][0])
        elif len(transformer_kva_ckt[i]) == 16:
            t.append(transformer_kva_ckt[i][0] + transformer_kva_ckt[i][2] +
                     transformer_kva_ckt[i][4])
        transformer_compare.append(t)
    # print(transformer_compare)
    # print()
    print("Transformers over nominal kva:")
    print()
    for i in range(len(transformer_compare)):
        if transformer_compare[i][2] > transformer_compare[i][1]:
            print(transformer_compare[i][0])
    print()
    kva_sum = []
    for i in range(len(transformer_compare)):
        if i > 25:
            kva_sum.append(transformer_compare[i][1])
    kva_sum = sum(kva_sum)
    print("Service xfmr connected kva: %.1f" % kva_sum)