def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = DLC80WA(arg[0])
    second = Ag(arg[1])
    third = DLC80WA(arg[2])
    fourth = Ag(arg[3])
    fifth = DLC80WA(arg[4])
    sixth = Ag(arg[5])
    seventh = DLC80WA(arg[6])
    mystruct = ML([first, second, third, fourth, fifth, sixth, seventh])
    print mystruct

    mystruct.calculate_color()
    TR(mystruct)

    index_lower = 0
    index_middle = 0
    upper_middle = 0
    index_upper = 0

    if mystruct.wl[len(mystruct.wl) - 1] < 3000:
        index_upper = len(mystruct.wl) - 1
    for index, i in enumerate(mystruct.wl):
        if index_lower == 0 and i >= myConst.lower_limit:
            index_lower = index
        elif index_middle == 0 and i >= myConst.upper_limit:
            index_middle = index
        elif myConst.upper_limit != 700 and upper_middle == 0:
            if i >= 700:
                upper_middle = index
        elif index_upper == 0 and i >= 3000:
            index_upper = index
            break
    if myConst.upper_limit == 700:
        upper_middle = index_middle

    T_array = np.interp(mystruct.wl[index_lower:index_middle], P_data[:, 0],
                        P_data[:, 1])
    R_array = np.interp(mystruct.wl[upper_middle:index_upper], S_data[:, 0],
                        S_data[:, 3])

    Transmittance = sum(
        mystruct.T[index_lower:index_middle] * T_array) / (sum(T_array))
    Reflectance = sum(
        mystruct.R[upper_middle:index_upper] * R_array) / (sum(R_array))

    priority_value = myConst.R_factor * Reflectance + myConst.T_factor * Transmittance

    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance))

    print 'Transmittance =%s' % float("{0:.4f}".format(Transmittance))

    print 'T color:', mystruct.T_color
    print 'R color:', mystruct.R_color

    show()
Example #2
0
def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = DLC80WA(arg[0])
    second = Ag(arg[1])
    third = DLC80WA(arg[2])
    fourth = Ag(arg[3])
    fifth = DLC80WA(arg[4])
    sixth=Ag(arg[5])
    seventh=DLC80WA(arg[6])
    eighth=Ag(arg[7])
    nineth=DLC80WA(arg[8])
    mystruct = ML([first, second, third, fourth, fifth, sixth, seventh, eighth, nineth])
    print mystruct
    
    mystruct.calculate_color()
    TR(mystruct)
    
    index_lower=0
    index_middle=0
    upper_middle=0
    index_upper=0

    if mystruct.wl[len(mystruct.wl)-1]<3000:
        index_upper=len(mystruct.wl)-1
    for index,  i in enumerate(mystruct.wl):
        if index_lower ==0 and i>=myConst.lower_limit:
            index_lower = index
        elif index_middle==0 and i>=myConst.upper_limit:
            index_middle=index
        elif myConst.upper_limit!= 700 and upper_middle==0:
            if i>=700:
                upper_middle=index
        elif index_upper==0 and i>=3000:
            index_upper=index
            break
    if myConst.upper_limit==700:
        upper_middle=index_middle
        
    T_array = np.interp(mystruct.wl[index_lower:index_middle],P_data[:, 0] , P_data[:, 1])
    R_array=  np.interp(mystruct.wl[upper_middle:index_upper],S_data[:, 0] , S_data[:, 3])
        
    Transmittance = sum(mystruct.T[index_lower:index_middle]*T_array)/(sum(T_array))
    Reflectance = sum(mystruct.R[upper_middle:index_upper]*R_array)/(sum(R_array))

    priority_value = myConst.R_factor*Reflectance + myConst.T_factor*Transmittance
    
    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance))

    print 'Transmittance =%s' % float("{0:.4f}".format(Transmittance))
    
    print 'T color:', mystruct.T_color
    print 'R color:', mystruct.R_color

    show()   
def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = Ag(arg[0])
    second = DLC80WA(arg[1])
    
    mystruct = ML([first, second])
    print mystruct
    
    mystruct.calculate_color()
    TR(mystruct, min_wl=200, max_wl=2500, legend=False, show_solar=True)
    plot.plt.grid("on")
    plot.plt.plot([400,400], [0,1], "k--")
    plot.plt.plot([700,700], [0,1], "k--")
    plot.plt.text(440, 0.70, "visible", fontsize=16)
    
    index_lower=0
    index_middle=0
    upper_middle=0
    index_upper=0
    if mystruct.wl[len(mystruct.wl)-1]<3000:
        index_upper=len(mystruct.wl)-1
    for index,  i in enumerate(mystruct.wl):
        if index_lower ==0 and i>=myConst.lower_limit:
            index_lower = index
        elif index_middle==0 and i>=myConst.upper_limit:
            index_middle=index
        elif myConst.upper_limit!= 700 and upper_middle==0:
            if i>=700:
                upper_middle=index
        elif index_upper==0 and i>=3000:
            index_upper=index
            break
    if myConst.upper_limit==700:
        upper_middle=index_middle
        
    T_array = np.interp(mystruct.wl[index_lower:index_middle],P_data[:, 0] , P_data[:, 1])
    R_array=  np.interp(mystruct.wl[upper_middle:index_upper],S_data[:, 0] , S_data[:, 3])
        
    Transmittance = sum(mystruct.T[index_lower:index_middle]*T_array)/(sum(T_array))
    Reflectance = sum(mystruct.R[upper_middle:index_upper]*R_array)/(sum(R_array))

    priority_value = myConst.R_factor*Reflectance + myConst.T_factor*Transmittance
    
    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance))

    print 'Transmittance =%s' % float("{0:.4f}".format(Transmittance))
    
    print 'T color:', mystruct.T_color
    print 'R color:', mystruct.R_color

    show()   
Example #4
0
def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = Al(arg[1])
    second = Ag(arg[2])
    third = ITO(arg[3])
    
    mystruct = ML([first, second, third])
    print mystruct
    
    mystruct.calculate_color()

    TR(mystruct, show_solar=True, max_wl=2500, min_wl=250, legend=True)
    plot.plt.grid("on")
    plot.plt.plot([400,400], [0,1], "k--")
    plot.plt.plot([700,700], [0,1], "k--")
    plot.plt.text(425, 0.70, "visible", fontsize=16)
    
    index_lower=0
    index_middle=0
    index_lower_middle=0
    upper_middle=0
    index_upper=0

    for index,  i in enumerate(mystruct.wl):
        if index_lower ==0 and i>=myConst.lower_limit:
            index_lower = index
        elif index_middle==0 and i>=myConst.upper_limit:
            index_middle=index
            break
    if myConst.upper_limit==700:
        upper_middle=index_middle
        
    T_array = np.interp(mystruct.wl[index_lower_middle:index_middle],P_data[:, 0] , P_data[:, 1])
    R1_array=  np.interp(mystruct.wl[upper_middle:index_upper],S_data[:, 0] , S_data[:, 3])
    R2_array=  np.interp(mystruct.wl[index_lower:index_lower_middle],S_data[:, 0] , S_data[:, 3])

    Transmittance = sum(mystruct.T[index_lower_middle:index_middle]*T_array)/(sum(T_array))
    Reflectance2 = sum(mystruct.R[index_lower:index_lower_middle]*R2_array)/(sum(R2_array))
    Reflectance1 = sum(mystruct.R[upper_middle:index_upper]*R1_array)/(sum(R1_array)) 
    Reflectance = Reflectance1 + Reflectance2
    
    priority= myConst.R_factor*Reflectance + myConst.T_factor*Transmittance
    
    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance/2))

    print 'Transmittance =%s' % float("{0:.4f}".format(Transmittance))
    
    print 'T color:', mystruct.T_color
    print 'R color:', mystruct.R_color

    show()   
def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    ##    first = DLC80WA(arg[0])
    ##    second = Ag(arg[1])
    ##    third = DLC80WA(arg[2])
    ##    fourth = Ag(arg[3])
    ##    fifth = DLC80WA(arg[4])

    first = Ag(arg[0])
    second = DLC80WA(arg[1])
    third = Ag(arg[2])
    fourth = DLC80WA(arg[3])
    fifth = AlN(arg[4])
    mystruct = ML([first, second, third, fourth, fifth],
                  min_wl=230,
                  max_wl=2476)
    print mystruct

    mystruct.calculate_color()

    # Doing unchecked attribute mutation here...future person beware. This
    # only applies because of comment above in correct_TR
    mystruct.T, mystruct.R = correct_TR(mystruct)

    TR(mystruct, show_solar=True, max_wl=2500)

    index_lower = 0
    index_middle = 0
    upper_middle = 0
    index_upper = 0

    if mystruct.wl[len(mystruct.wl) - 1] < 3000:
        index_upper = len(mystruct.wl) - 1
    for index, i in enumerate(mystruct.wl):
        if index_lower == 0 and i >= myConst.lower_limit:
            index_lower = index
        elif index_middle == 0 and i >= myConst.upper_limit:
            index_middle = index
        elif myConst.upper_limit != 700 and upper_middle == 0:
            if i >= 700:
                upper_middle = index
        elif index_upper == 0 and i >= 3000:
            index_upper = index
            break
    if myConst.upper_limit == 700:
        upper_middle = index_middle

    T_array = np.interp(mystruct.wl[index_lower:index_middle], P_data[:, 0],
                        P_data[:, 1])
    R_array = np.interp(mystruct.wl[upper_middle:index_upper], S_data[:, 0],
                        S_data[:, 3])

    Transmittance = sum(
        mystruct.T[index_lower:index_middle] * T_array) / (sum(T_array))
    Reflectance = sum(
        mystruct.R[upper_middle:index_upper] * R_array) / (sum(R_array))

    priority_value = myConst.R_factor * Reflectance + myConst.T_factor * Transmittance

    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance))

    print 'Transmitance =%s' % float("{0:.4f}".format(Transmittance))

    print 'T_color:', mystruct.T_color
    print 'R_color:', mystruct.R_color

    show()
def plot_structure(arg, text_only=False):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = Ag(arg[1])
    second = AlN(arg[2])
    mystruct = ML([first, second],
                  min_wl=MIN_WL, max_wl=MAX_WL)
    TR(mystruct)

    show()

#### Uncomment for 6-layer structure

##    fifth = Ag(arg[4])
##    sixth = DLC80WA(arg[5])
##    
##    mystruct = ML([first, second, third, fourth,
##                   fifth, sixth, AlN(20)],
##                  min_wl=230, max_wl=2476)
    print mystruct
    
    mystruct.calculate_color()

    # Doing unchecked attribute mutation here...future person beware. This
    # only applies because of comment above in correct_TR
    mystruct = correct_TR(mystruct)
    
    index_lowerUV=0
    index_lowervis=0
    index_uppervis=0
    upper_middle=0
    index_upper=0

    if mystruct.wl[len(mystruct.wl)-1]<3000:
        index_upper=len(mystruct.wl)-1
    for index,  i in enumerate(mystruct.wl):
        if index_lowervis ==0 and i>=myConst.lower_limit:
            index_lowervis = index
        elif index_uppervis==0 and i>=myConst.upper_limit:
            index_uppervis=index
        elif myConst.upper_limit!= 700 and upper_middle==0:
            if i>=700:
                upper_middle=index
        elif index_upper==0 and i>=3000:
            index_upper=index
            break
    if myConst.upper_limit==700:
        upper_middle=index_uppervis
        
    

    photopic_array = np.interp(mystruct.wl[index_lowervis:index_uppervis],P_data[:, 0] , P_data[:, 1])
    V_normalized_data = np.interp(mystruct.wl[index_lowervis:index_uppervis],V_data[:, 0], V_data[:, 3]) / max(V_data[:, 3])
    T_ideal_array = photopic_array/V_normalized_data
    perfect_T_array = [1] * (len(photopic_array))
	
    sol_array = np.interp(mystruct.wl[index_lowerUV:index_upper],S_data[:, 0] , S_data[:, 3])
    sol_array_UV = np.interp(mystruct.wl[index_lowerUV:index_lowervis],U_data[:, 0] , U_data[:, 3])
    sol_array_vis = np.interp(mystruct.wl[index_lowervis:index_uppervis],V_data[:, 0] , V_data[:, 3])
    sol_array_IR = np.interp(mystruct.wl[index_uppervis:index_upper],I_data[:, 0] , I_data[:, 3])
    
    
    Tvis = sum(mystruct.T[index_lowervis:index_uppervis]*photopic_array)/(sum(photopic_array))
   
    #Tpriority = sum(mystruct.T[index_lowervis:index_uppervis]*T_ideal_array)/(sum(T_ideal_array))
    #Tpriority = sum(mystruct.T[index_lowervis:index_uppervis]*sol_array_vis*photopic_array)/(sum(sol_array_vis*photopic_array))
    #Tpriority = 1/np.sqrt(sum((mystruct.T[index_lowervis:index_uppervis]*sol_array_vis/max(sol_array_vis)-photopic_array)**2))
    Tpriority = 1/np.sqrt(sum((mystruct.T[index_lowervis:index_uppervis]-sol_array_vis/max(sol_array_vis))**2))
    #Tpriority = 1/np.sqrt(sum((mystruct.T[index_lowervis:index_uppervis]-perfect_T_array)**2))
    
    TSER_UV = 1 - sum(mystruct.T[index_lowerUV:index_lowervis]*sol_array_UV)/(sum(sol_array_UV))
    TSER_vis = 1 - sum(mystruct.T[index_lowervis:index_uppervis]*sol_array_vis)/(sum(sol_array_vis))
    TSER_IR = 1 - sum(mystruct.T[index_uppervis:index_upper]*sol_array_IR)/(sum(sol_array_IR))
    # 0.0342 = % of AM1.5 energy in UV
    # 0.426 = % of AM1.5 energy in visible
    # 0.54 = % of AM1.5 energy in IR (700-2500)
    check_TSER = TSER_UV * 0.0342 + TSER_vis * 0.426 + TSER_IR * 0.54 - .04
    TSER = 1 - sum(mystruct.T[index_lowerUV:index_upper]*sol_array)/(sum(sol_array)) - 0.04
	
    #TSER_priority = TSER_UV * 0.0342 / (0.0342 + 0.54) + TSER_IR * 0.54 / (0.0342 + 0.54)
    TSER_priority = TSER_IR
	
    #priority = myConst.p1 * Tpriority + myConst.p2 * (TSER_IR - myConst.wanted_TSER)
    priority = myConst.p1 * Tpriority + myConst.p2 * TSER_priority
    #priority = myConst.p1 * Tpriority * Tvis + myConst.p2 * TSER_priority
    #priority = -1 / (Tvis - myConst.p1) - \
    #           abs(myConst.p2 * (TSER - myConst.wanted_TSER))                                                                            
													  
						                                          

    print 'TSER = %s' % float("{0:.4f}".format(TSER))
    print 'check_TSER = %s' % float("{0:.4f}".format(check_TSER))
    print 'TSER in UV = %s' % float("{0:.4f}".format(TSER_UV))
    print 'TSER in visible = %s' % float("{0:.4f}".format(TSER_vis))
    print 'TSER in IR = %s' % float("{0:.4f}".format(TSER_IR))

    print 'Tpriority = %s' % float("{0:.4f}".format(Tpriority))

    print 'Tvis = %s' % float("{0:.4f}".format(Tvis)) 
    
    print 'T_color:', mystruct.T_color
    print 'R_color:', mystruct.R_color

    for i in range(len(mystruct.wl)):
        print mystruct.wl[i]," ", mystruct.T[i]," ", mystruct.R[i]

    #print 'UV lower bound:', index_lowerUV
    #print 'Visible lower bound:', index_lowervis
    #print 'Visible upper bound:', index_uppervis
    #print 'IR upper bound:', index_upper
    #print mystruct.wl[:]

    if not text_only:
        TR(mystruct, show_solar=True, min_wl=200, max_wl=2500)
        plot.plt.grid("on")
        plot.plt.plot([400,400], [0,1], "k--")
        plot.plt.plot([700,700], [0,1], "k--")
        plot.plt.text(425, 0.70, "visible", fontsize=16)

        show()

    return mystruct
Example #7
0
def plot_structure(arg):
    '''
Basically, this function plots the graph of reflectance and transmittance of a
given three layer structure versus wavelength. The argument is given as a tuple or a list of 3 elements.
In addition, it provides the values of reflectance, transmittance, R_color and T_color.
'''
    first = Al(arg[1])
    second = Al2O3(arg[2])
    third = Ag(arg[3])
    fourth = Al2O3(arg[4])
    mystruct = ML([first, second, third, fourth],
                  min_wl=230, max_wl=2476)

#### Uncomment for 6-layer structure

##    fifth = Ag(arg[4])
##    sixth = DLC80WA(arg[5])
##    
##    mystruct = ML([first, second, third, fourth,
##                   fifth, sixth, AlN(20)],
##                  min_wl=230, max_wl=2476)
    print mystruct
    
    mystruct.calculate_color()

    # Doing unchecked attribute mutation here...future person beware. This
    # only applies because of comment above in correct_TR
        
    TR(mystruct, show_solar=True, max_wl=1500, min_wl=250, legend=True)
    plot.plt.grid("on")
    plot.plt.plot([400,400], [0,1], "k--")
    plot.plt.plot([700,700], [0,1], "k--")
    plot.plt.text(425, 0.70, "visible", fontsize=16)
      
    index_lower=0
    index_middle=0
    index_lower_middle=0
    upper_middle=0
    index_upper=0
    if mystruct.wl[len(mystruct.wl)-1]<3000:
        index_upper=len(mystruct.wl)-1
    for index,  i in enumerate(mystruct.wl):
        if index_lower ==0 and i>=myConst.lower_limit:
            index_lower = index
        if index_lower_middle ==0 and i>=myConst.middle_limit:
            index_lower_middle = index
        elif index_middle==0 and i>=myConst.upper_limit:
            index_middle=index
        elif index_upper==0 and i>=3000:
            index_upper=index
            break
    if myConst.upper_limit==800:
        upper_middle=index_middle
        
    T_array = np.interp(mystruct.wl[index_lower_middle:index_middle],P_data[:, 0] , P_data[:, 1])
    R1_array=  np.interp(mystruct.wl[upper_middle:index_upper],S_data[:, 0] , S_data[:, 3])
    R2_array=  np.interp(mystruct.wl[index_lower:index_lower_middle],S_data[:, 0] , S_data[:, 3])

    Transmittance = sum(mystruct.T[index_lower_middle:index_middle]*T_array)/(sum(T_array))
    Reflectance2 = sum(mystruct.R[index_lower:index_lower_middle]*R2_array)/(sum(R2_array))
    Reflectance1 = sum(mystruct.R[upper_middle:index_upper]*R1_array)/(sum(R1_array)) 
    Reflectance = Reflectance1 + Reflectance2
    
    priority= myConst.R_factor*Reflectance + myConst.T_factor*Transmittance

    
    print 'Reflectance=%s' % float("{0:.4f}".format(Reflectance/2))

    print 'Transmitance =%s' % float("{0:.4f}".format(Transmittance))

    #print 'Absorptance =%s' % float("{0:.4f}".format(priority_value))
    
    print 'T_color:', mystruct.T_color
    print 'R_color:', mystruct.R_color

    show()