Calculator.py
def _numerical_evaluation_(self,analytical_quantity,freq,q):
        """Substitute numerical values into any analytical expression.
        
        Use lambdify function to substitute numerical values into analytical quantity
        specified by user.
        Automatically broadcast the 1D freq and q arrays into a 2D array to evaluate reflection coefficient at each combination of freq and q.
        
        Args:
            freq (array): numpy.ndarray array of frequencies of incident light; in unit of cm^-1
            q (array): numpy.ndarray of in-plane momenta associated with incident light
        
        Return:
            The numerical value of analytical_quantity with corresponding dimension of array (based on dimension of freq and q). 
        
        """
        
        T = self.transferMatrix
        entranceMaterial = T.entrance
        exitMaterial = T.exit
        layerDictionary = T.layerDictionary
        
        if (type(freq)==float or type(freq)==int)and(type(q)==float or type(q)==int):
            singlePointEvaluation = True
        else:
            singlePointEvaluation = False
        
        subs = {}
        subs['c'] = 3e10
        subs['omega'] = 2*np.pi*freq
    
        #for first boundary
        if singlePointEvaluation==True:
            kz = entranceMaterial.get_kz(freq,q)
            epsilon = entranceMaterial.epsilon(freq,q)
            mu = entranceMaterial.mu(freq,q)
            subs['k_z1'] = self._extract_singleton_array_value_(kz)
            subs['epsilon_1'] = self._extract_singleton_array_value_(epsilon)
            subs['mu_1'] = self._extract_singleton_array_value_(mu)
        else:
            subs['k_z1'] = entranceMaterial.get_kz(freq,q)
            subs['epsilon_1'] = entranceMaterial.epsilon(freq,q)
            subs['mu_1'] = entranceMaterial.mu(freq,q)  
        
        #for in between layers
        for x in range(2, self.numLayers+2):
    
            layer = layerDictionary['L'+str(x)]
            material = layer.get_material()
            surface = layerDictionary['S'+str(x-1)+str(x)]
            subs['z{}'.format(x)] = layer.get_thickness()
            
            if singlePointEvaluation==True:
                kz = material.get_kz(freq,q)
                sigma = surface.conductivity(freq)
                epsilon = material.epsilon(freq,q)
                mu = material.mu(freq,q)
                subs['k_z{}'.format(x)] = kz
                subs['sigma{0}{1}'.format(x-1,x)] = sigma
                subs['epsilon_{}'.format(x)] = epsilon
                subs['mu_{}'.format(x)] = mu
            else:
                subs['k_z{}'.format(x)] = material.get_kz(freq,q)
                subs['sigma{0}{1}'.format(x-1,x)] = surface.conductivity(freq)
                subs['epsilon_{}'.format(x)] = material.epsilon(freq,q)
                subs['mu_{}'.format(x)] = material.mu(freq,q)
    
        #for last boundary
        surface = layerDictionary['S'+str(self.numLayers+1)+str(self.numLayers+2)]
        if singlePointEvaluation==True:
            kz = exitMaterial.get_kz(freq,q)
            epsilon = exitMaterial.epsilon(freq,q)
            mu = exitMaterial.mu(freq,q)
            sigma = surface.conductivity(freq)
            subs['k_z{}'.format(self.numLayers+2)] = kz
            subs['epsilon_{}'.format(self.numLayers+2)] = epsilon
            subs['mu_{}'.format(self.numLayers+2)] = mu
            subs['sigma{0}{1}'.format(self.numLayers+1,self.numLayers+2)] = sigma
        else:
            subs['k_z{}'.format(self.numLayers+2)] = exitMaterial.get_kz(freq,q)
            subs['epsilon_{}'.format(self.numLayers+2)] = exitMaterial.epsilon(freq,q)
            subs['mu_{}'.format(self.numLayers+2)] = exitMaterial.mu(freq,q)
            subs['sigma{0}{1}'.format(self.numLayers+1,self.numLayers+2)] = surface.conductivity(freq)
    
        numerics = sympy.lambdify(subs.keys(), analytical_quantity, modules='numpy')
        numerical_quantity = numerics(*subs.values())
        return numerical_quantity
Substitute numerical values into any analytical expression.
        
        Use lambdify function to substitute numerical values into analytical quantity
        specified by user.
        Automatically broadcast the 1D freq and q arrays into a 2D array to evaluate reflection coefficient at each combination of freq and q.
        
        Args:
            freq (array): numpy.ndarray array of frequencies of incident light; in unit of cm^-1
            q (array): numpy.ndarray of in-plane momenta associated with incident light
        
        Return:
            The numerical value of analytical_quantity with corresponding dimension of array (based on dimension of freq and q). 
        
        
Substitute numerical values into any analytical expression.
Use lambdify function to substitute numerical values into analytical quantity
specified by user.
Automatically broadcast the 1D freq and q arrays into a 2D array to evaluate reflection coefficient at each combination of freq and q.
Substitute numerical values into any analytical expression . Use lambdify function to substitute numerical values into analytical quantity specified by user . Automatically broadcast the 1D freq and q arrays into a 2D array to evaluate reflection coefficient at each combination of freq and q .
def _numerical_evaluation_(self,analytical_quantity,freq,q):
        T = self.transferMatrix
        entranceMaterial = T.entrance
        exitMaterial = T.exit
        layerDictionary = T.layerDictionary
        if (type(freq)==float or type(freq)==int)and(type(q)==float or type(q)==int):
            singlePointEvaluation = True
        else:
            singlePointEvaluation = False
        subs = {}
        subs['c'] = 3e10
        subs['omega'] = 2*np.pi*freq
        if singlePointEvaluation==True:
            kz = entranceMaterial.get_kz(freq,q)
            epsilon = entranceMaterial.epsilon(freq,q)
            mu = entranceMaterial.mu(freq,q)
            subs['k_z1'] = self._extract_singleton_array_value_(kz)
            subs['epsilon_1'] = self._extract_singleton_array_value_(epsilon)
            subs['mu_1'] = self._extract_singleton_array_value_(mu)
        else:
            subs['k_z1'] = entranceMaterial.get_kz(freq,q)
            subs['epsilon_1'] = entranceMaterial.epsilon(freq,q)
            subs['mu_1'] = entranceMaterial.mu(freq,q)  
        for x in range(2, self.numLayers+2):
            layer = layerDictionary['L'+str(x)]
            material = layer.get_material()
            surface = layerDictionary['S'+str(x-1)+str(x)]
            subs['z{}'.format(x)] = layer.get_thickness()
            if singlePointEvaluation==True:
                kz = material.get_kz(freq,q)
                sigma = surface.conductivity(freq)
                epsilon = material.epsilon(freq,q)
                mu = material.mu(freq,q)
                subs['k_z{}'.format(x)] = kz
                subs['sigma{0}{1}'.format(x-1,x)] = sigma
                subs['epsilon_{}'.format(x)] = epsilon
                subs['mu_{}'.format(x)] = mu
            else:
                subs['k_z{}'.format(x)] = material.get_kz(freq,q)
                subs['sigma{0}{1}'.format(x-1,x)] = surface.conductivity(freq)
                subs['epsilon_{}'.format(x)] = material.epsilon(freq,q)
                subs['mu_{}'.format(x)] = material.mu(freq,q)
        surface = layerDictionary['S'+str(self.numLayers+1)+str(self.numLayers+2)]
        if singlePointEvaluation==True:
            kz = exitMaterial.get_kz(freq,q)
            epsilon = exitMaterial.epsilon(freq,q)
            mu = exitMaterial.mu(freq,q)
            sigma = surface.conductivity(freq)
            subs['k_z{}'.format(self.numLayers+2)] = kz
            subs['epsilon_{}'.format(self.numLayers+2)] = epsilon
            subs['mu_{}'.format(self.numLayers+2)] = mu
            subs['sigma{0}{1}'.format(self.numLayers+1,self.numLayers+2)] = sigma
        else:
            subs['k_z{}'.format(self.numLayers+2)] = exitMaterial.get_kz(freq,q)
            subs['epsilon_{}'.format(self.numLayers+2)] = exitMaterial.epsilon(freq,q)
            subs['mu_{}'.format(self.numLayers+2)] = exitMaterial.mu(freq,q)
            subs['sigma{0}{1}'.format(self.numLayers+1,self.numLayers+2)] = surface.conductivity(freq)
        numerics = sympy.lambdify(subs.keys(), analytical_quantity, modules='numpy')
        numerical_quantity = numerics(*subs.values())
        return numerical_quantity
def _numerical_evaluation_ ( self , analytical_quantity , freq , q ) : T = self . transferMatrix entranceMaterial = T . entrance exitMaterial = T . exit layerDictionary = T . layerDictionary if ( type ( freq ) == float or type ( freq ) == int ) and ( type ( q ) == float or type ( q ) == int ) : singlePointEvaluation = True else : singlePointEvaluation = False subs = { } subs [ 'c' ] = 3e10 subs [ 'omega' ] = 2 * np . pi * freq if singlePointEvaluation == True : kz = entranceMaterial . get_kz ( freq , q ) epsilon = entranceMaterial . epsilon ( freq , q ) mu = entranceMaterial . mu ( freq , q ) subs [ 'k_z1' ] = self . _extract_singleton_array_value_ ( kz ) subs [ 'epsilon_1' ] = self . _extract_singleton_array_value_ ( epsilon ) subs [ 'mu_1' ] = self . _extract_singleton_array_value_ ( mu ) else : subs [ 'k_z1' ] = entranceMaterial . get_kz ( freq , q ) subs [ 'epsilon_1' ] = entranceMaterial . epsilon ( freq , q ) subs [ 'mu_1' ] = entranceMaterial . mu ( freq , q ) for x in range ( 2 , self . numLayers + 2 ) : layer = layerDictionary [ 'L' + str ( x ) ] material = layer . get_material ( ) surface = layerDictionary [ 'S' + str ( x - 1 ) + str ( x ) ] subs [ 'z{}' . format ( x ) ] = layer . get_thickness ( ) if singlePointEvaluation == True : kz = material . get_kz ( freq , q ) sigma = surface . conductivity ( freq ) epsilon = material . epsilon ( freq , q ) mu = material . mu ( freq , q ) subs [ 'k_z{}' . format ( x ) ] = kz subs [ 'sigma{0}{1}' . format ( x - 1 , x ) ] = sigma subs [ 'epsilon_{}' . format ( x ) ] = epsilon subs [ 'mu_{}' . format ( x ) ] = mu else : subs [ 'k_z{}' . format ( x ) ] = material . get_kz ( freq , q ) subs [ 'sigma{0}{1}' . format ( x - 1 , x ) ] = surface . conductivity ( freq ) subs [ 'epsilon_{}' . format ( x ) ] = material . epsilon ( freq , q ) subs [ 'mu_{}' . format ( x ) ] = material . mu ( freq , q ) surface = layerDictionary [ 'S' + str ( self . numLayers + 1 ) + str ( self . numLayers + 2 ) ] if singlePointEvaluation == True : kz = exitMaterial . get_kz ( freq , q ) epsilon = exitMaterial . epsilon ( freq , q ) mu = exitMaterial . mu ( freq , q ) sigma = surface . conductivity ( freq ) subs [ 'k_z{}' . format ( self . numLayers + 2 ) ] = kz subs [ 'epsilon_{}' . format ( self . numLayers + 2 ) ] = epsilon subs [ 'mu_{}' . format ( self . numLayers + 2 ) ] = mu subs [ 'sigma{0}{1}' . format ( self . numLayers + 1 , self . numLayers + 2 ) ] = sigma else : subs [ 'k_z{}' . format ( self . numLayers + 2 ) ] = exitMaterial . get_kz ( freq , q ) subs [ 'epsilon_{}' . format ( self . numLayers + 2 ) ] = exitMaterial . epsilon ( freq , q ) subs [ 'mu_{}' . format ( self . numLayers + 2 ) ] = exitMaterial . mu ( freq , q ) subs [ 'sigma{0}{1}' . format ( self . numLayers + 1 , self . numLayers + 2 ) ] = surface . conductivity ( freq ) numerics = sympy . lambdify ( subs . keys ( ) , analytical_quantity , modules = 'numpy' ) numerical_quantity = numerics ( * subs . values ( ) ) return numerical_quantity
Substitute numerical values into any analytical expression.
Substitute numerical values into any analytical expression .
"""Substitute numerical values into any analytical expression.
        
        Use lambdify function to substitute numerical values into analytical quantity
        specified by user.
        Automatically broadcast the 1D freq and q arrays into a 2D array to evaluate reflection coefficient at each combination of freq and q.
        
        Args:
            freq (array): numpy.ndarray array of frequencies of incident light; in unit of cm^-1
            q (array): numpy.ndarray of in-plane momenta associated with incident light
        
        Return:
            The numerical value of analytical_quantity with corresponding dimension of array (based on dimension of freq and q). 
        
        """ #for first boundary #for in between layers #for last boundary
self
analytical_quantity
freq
numpy.ndarray array of frequencies of incident light; in unit of cm^-1
numpy . ndarray array of frequencies of incident light ; in unit of cm^ - 1
q
numpy.ndarray of in-plane momenta associated with incident light
numpy . ndarray of in - plane momenta associated with incident light