Ejemplo n.º 1
0
    def solve_interior(self):
        """solve for the interior of the sphere, the cn and dn coefficients"""
        #TODO shouldn't this be multiplied by self.radius?
        xvals = self.material_data['k'] * self.radius
        m = (self.material_data['eps'] / self.material_data['eps_b'])**.5
        mt = m * self.material_data['mu_b'] / self.material_data['mu']

        jn = riccati_1(self.lmax, xvals)
        yn = riccati_2(self.lmax, xvals)

        if self.material.name == 'metal':
            f = self.material_data['mu_b'] / self.material_data['mu']
            c = (jn[0] * yn[1] - yn[0] * jn[1]) / (f * yn[0] * jnm[1])
            d = (jn[0] * yn[1] - yn[0] * jn[1]) / (f * jnm[0] * yn[1])
        else:
            jnm = riccati_1(self.lmax, m * xvals)
            c = (m * jn[0] * yn[1] - m * yn[0] * jn[1]) / (jnm[0] * yn[1] -
                                                           mt * yn[0] * jnm[1])
            d = (m * jn[0] * yn[1] -
                 m * yn[0] * jn[1]) / (mt * jnm[0] * yn[1] - yn[0] * jnm[1])

        self.cn[...] = np.nan_to_num(c.T)
        self.dn[...] = np.nan_to_num(d.T)

        self.interior_computed = True
        return self.cn, self.dn
Ejemplo n.º 2
0
def sphere(nmax, mat, r, eps_b=1, mu_b=1):
    """Determine an, bn coefficients for a sphere

           nmax  = maximum number of orders to use
           mat   = material object
           r     = radius
           eps_b = background permittivity
           mu_b  = background permeability

       Returns multipoles object"""

    n_b = (eps_b)**.5
    xvals = mat.k*r*n_b

    an = np.zeros((nmax,mat.Nfreq), dtype=np.complex)
    bn = np.zeros((nmax,mat.Nfreq), dtype=np.complex)

    for i,x in enumerate(xvals):
        m = (mat.eps[i]/eps_b)**.5
        mt = m*mu_b/mat.mu[i]

        jn,jn_p = riccati_1(nmax,x)
        jnm,jnm_p = riccati_1(nmax,m*x)
        yn,yn_p = riccati_2(nmax,x)
        a = (mt*jnm*jn_p - jn*jnm_p)/(mt*jnm*yn_p - yn*jnm_p)
        b = (jnm*jn_p - mt*jn*jnm_p)/(jnm*yn_p - mt*yn*jnm_p)
        an[:,i] = a[1:]
        bn[:,i] = b[1:]
    
    an = np.nan_to_num(an)
    bn = np.nan_to_num(bn)
    return multipoles(mat.wav,an,bn) 
Ejemplo n.º 3
0
    def solve_exterior(self):
        """solve for the exterior of the sphere, the an and bn coefficients"""
        xvals = self.material_data['k']*self.radius
        m = (self.material_data['eps']/self.material_data['eps_b'])**.5
        mt = m*self.material_data['mu_b']/self.material_data['mu']

        jn = riccati_1(self.lmax,xvals)
        yn = riccati_2(self.lmax,xvals)

        if self.material.name == 'metal':
            a = jn[1]/yn[1]
            b = jn[0]/yn[0]
        else:
            jnm = riccati_1(self.lmax,m*xvals)
            a = (mt*jnm[0]*jn[1] - jn[0]*jnm[1])/(mt*jnm[0]*yn[1] - yn[0]*jnm[1])
            b = (jnm[0]*jn[1] - mt*jn[0]*jnm[1])/(jnm[0]*yn[1] - mt*yn[0]*jnm[1])

        self.an[...] = np.nan_to_num(a.T)
        self.bn[...] = np.nan_to_num(b.T)

        self.exterior_computed = True
        return self.an, self.bn