def fresnel_ea(self): if (self.explicit_angle != 1): error = 'ERROR: EXPLIT ANGLE OPTION NOT SELECTED! \n' error = error + 'RE-INSTANTIATE YOUR MULTILAYER CLASS AND BE SURE \n' error = error + 'TO INCLUDE A LINE IN YOUR STRUCTURE DICTIONARY LIKE THE FOLLOWING: \n' error = error + 'EXPLICIT_ANGLE: 1' print(error) exit() ### The angles come from Gauss-Legendre quadrature nc = np.zeros(len(self.d), dtype=complex) ### outter loop is over wavelength - this modulates the RI for i in range(0, len(self.lambda_array)): k0 = np.pi * 2 / self.lambda_array[i] ### for given wavelength, the stack will have the following set of RIs for j in range(0, len(self.d)): nc[j] = self.n[j][i] ### iterate over angles for j in range(0, len(self.t)): ### for given angle, k0, pol, nc, and d ### compute M Mp = tmm.tmm(k0, self.t[j], 'p', nc, self.d) Ms = tmm.tmm(k0, self.t[j], 's', nc, self.d) ### get amplitudes and related quantities from M dictionaries tp = 1. / Mp["M11"] ts = 1. / Ms["M11"] tp_i = Mp["theta_i"] ts_i = Ms["theta_L"] tp_L = Mp["theta_L"] ts_L = Ms["theta_L"] facp = nc[len(self.d) - 1] * np.cos(tp_L) / (nc[0] * np.cos(tp_i)) facs = nc[len(self.d) - 1] * np.cos(ts_L) / (nc[0] * np.cos(ts_i)) rp = Mp["M21"] / Mp["M11"] rs = Ms["M21"] / Ms["M11"] ### Reflectivity for each polarization self.reflectivity_array_p[j][i] = np.real(rp * np.conj(rp)) self.reflectivity_array_s[j][i] = np.real(rs * np.conj(rs)) ### Transmissivity for each polarization self.transmissivity_array_p[j][i] = np.real(tp * np.conj(tp) * facp) self.transmissivity_array_s[j][i] = np.real(ts * np.conj(ts) * facs) ### Emissivity for each polarization self.emissivity_array_p[j][i] = 1. - self.reflectivity_array_p[ j][i] - self.transmissivity_array_p[j][i] self.emissivity_array_s[j][i] = 1. - self.reflectivity_array_s[ j][i] - self.transmissivity_array_s[j][i] return 1
def Psun(theta_sun, lam, n, d): ### length of arrays n_lam = len(lam) n_layer = len(d) ### get Am1.5 spectrum AM = datalib.AM(lam) ### variables to hold emissivity for s- and p-polarized light emissivity_s = 0. emissivity_p = 0. ### allocate array for refractive index at a particular wavelength nc = np.zeros(n_layer, dtype=complex) ### compute emissivity and integrate all at once P_sun_sum = 0. dl = np.abs(lam[1] - lam[0]) for i in range(0, n_lam): for j in range(0, n_layer): nc[j] = n[j][i] k0 = np.pi * 2 / lam[i] ### get p-polarized transfer matrix for this k0, th, pol, nc, and d Mp = tmm.tmm(k0, theta_sun, 'p', nc, d) ### get s-polarized transfer matrix for this k0, th, pol, nc, and d Ms = tmm.tmm(k0, theta_sun, 's', nc, d) ### get t amplitudes tp = 1. / Mp["M11"] ts = 1. / Ms["M11"] ### get incident/final angles tpi = Mp["theta_i"] tpL = Mp["theta_L"] tsi = Ms["theta_i"] tsL = Ms["theta_L"] ### get geometric factor associated with transmission facp = nc[n_layer - 1] * np.cos(tpL) / (nc[0] * np.cos(tpi)) facs = nc[n_layer - 1] * np.cos(tsL) / (nc[0] * np.cos(tsi)) ### get reflection amplitude rp = Mp["M21"] / Mp["M11"] rs = Ms["M21"] / Ms["M11"] ### get Reflectivity Rp = np.real(rp * np.conj(rp)) Rs = np.real(rs * np.conj(rs)) ### get Transmissivity Tp = np.real(tp * np.conj(tp) * facp) Ts = np.real(ts * np.conj(ts) * facs) emissivity_p = 1 - Rp - Tp emissivity_s = 1 - Rs - Ts P_sun_sum = P_sun_sum + 0.5 * (emissivity_p + emissivity_s) * AM[i] * dl return P_sun_sum
def angular_fresnel(self, lambda_0): ### create an array for RI of each layer at the ### desired wavelength nc = np.zeros(len(self.d),dtype=complex) ### get RI for each layer and store it in nc array #for i in range(0,len(self.matlist)): # nc[i] = datalib.Material_RI(lambda_0, self.matlist[i]) idx, = np.where(self.lambda_array <= lambda_0) idx_val = idx[len(idx)-1] for i in range(0,len(self.matlist)): nc[i] = self.n[i][idx_val] k0 = np.pi*2/lambda_0 i=0 for thetai in self.theta_array: ### increment by 1/2 degrees M = tmm.tmm(k0, thetai, self.pol, nc, self.d) t = 1./M["M11"] ### get incident/final angle ti = M["theta_i"] tL = M["theta_L"] ### get geometric factor associated with transmission fac = nc[len(self.d)-1]*np.cos(tL)/(nc[0]*np.cos(ti)) ### get reflection amplitude r = M["M21"]/M["M11"] ### get Reflectivity self.r_vs_theta[i] = np.real(r * np.conj(r)) ### get Transmissivity self.t_vs_theta[i] = np.real(t*np.conj(t)*fac) self.eps_vs_theta[i] = 1 - self.r_vs_theta[i] - self.t_vs_theta[i] i = i+1 return 1
def fresnel(self): nc = np.zeros(len(self.d),dtype=complex) for i in range(0,len(self.lambda_array)): for j in range(0,len(self.d)): nc[j] = self.n[j][i] k0 = np.pi*2/self.lambda_array[i] ### get transfer matrix for this k0, th, pol, nc, and d M = tmm.tmm(k0, self.theta, self.pol, nc, self.d) ### get t amplitude t = 1./M["M11"] ### get incident/final angle ti = M["theta_i"] tL = M["theta_L"] ### get geometric factor associated with transmission fac = nc[len(self.d)-1]*np.cos(tL)/(nc[0]*np.cos(ti)) ### get reflection amplitude r = M["M21"]/M["M11"] ### get Reflectivity self.reflectivity_array[i] = np.real(r * np.conj(r)) ### get Transmissivity self.transmissivity_array[i] = np.real(t*np.conj(t)*fac) self.emissivity_array[i] = 1 - self.reflectivity_array[i] - self.transmissivity_array[i] return 1
def fresnel_prime(self, layer_i): nc = np.zeros(len(self.d), dtype=complex) for i in range(0, len(self.lambda_array)): for j in range(0, len(self.d)): nc[j] = self.n[j][i] k0 = np.pi * 2 / self.lambda_array[i] ### get transfer matrix for this k0, th, pol, nc, and d M = tmm.tmm(k0, self.theta, self.pol, nc, self.d) dM_ds = tmm.d_tmm_dsi(layer_i, k0, self.theta, self.pol, nc, self.d) ### store all relevant matrix elements in variable names M21 = M["M21"] M11 = M["M11"] M21p = dM_ds["dM21_ds"] M11p = dM_ds["dM11_ds"] ### get reflection amplitude r = M["M21"] / M["M11"] r_star = np.conj(r) ### get derivative of reflection amplitudes r_prime = (M11 * M21p - M21 * M11p) / (M11 * M11) r_prime_star = np.conj(r_prime) ### get reflectivity R_prime = r_prime * r_star + r * r_prime_star ### get Reflectivity self.reflectivity_prime_array[i] = np.real(R_prime) ### get Transmissivity self.emissivity_prime_array[ i] = 1 - self.reflectivity_prime_array[i] return 1
def fresnel_ea(self): ### The angles come from Gauss-Legendre quadrature nc = np.zeros(len(self.d),dtype=complex) ### outter loop is over wavelength - this modulates the RI for i in range(0,len(self.lambda_array)): k0 = np.pi*2/self.lambda_array[i] ### for given wavelength, the stack will have the following set of RIs for j in range(0,len(self.d)): nc[j] = self.n[j][i] ### iterate over angles for j in range(0,len(self.t)): ### for given angle, k0, pol, nc, and d ### compute M Mp = tmm.tmm(k0, self.t[j], 'p', nc, self.d) Ms = tmm.tmm(k0, self.t[j], 's', nc, self.d) ### get amplitudes and related quantities from M dictionaries tp = 1./Mp["M11"] ts = 1./Ms["M11"] tp_i = Mp["theta_i"] ts_i = Ms["theta_L"] tp_L = Mp["theta_L"] ts_L = Ms["theta_L"] facp = nc[len(self.d)-1]*np.cos(tp_L)/(nc[0]*np.cos(tp_i)) facs = nc[len(self.d)-1]*np.cos(ts_L)/(nc[0]*np.cos(ts_i)) rp = Mp["M21"]/Mp["M11"] rs = Ms["M21"]/Ms["M11"] ### Reflectivity for each polarization self.reflectivity_array_p[j][i] = np.real(rp * np.conj(rp)) self.reflectivity_array_s[j][i] = np.real(rs * np.conj(rs)) ### Transmissivity for each polarization self.transmissivity_array_p[j][i] = np.real(tp*np.conj(tp)*facp) self.transmissivity_array_s[j][i] = np.real(ts*np.conj(ts)*facs) ### Emissivity for each polarization self.emissivity_array_p[j][i] = 1. - self.reflectivity_array_p[j][i] - self.transmissivity_array_p[j][i] self.emissivity_array_s[j][i] = 1. - self.reflectivity_array_s[j][i] - self.transmissivity_array_s[j][i] return 1