def Psun(theta_sun, lam, n, d): ### length of arrays n_lam = len(lam) n_layer = len(d) ### get Am1.5 spectrum AMg = datalib.AM15g(lam) AMd = datalib.AM15d(lam) AM = AMg - AMd #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 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"] self.transmissivity_amplitude_array_p[j][i] = tp self.transmissivity_amplitude_array_s[j][i] = ts self.reflectivity_amplitude_array_p[j][i] = rp self.reflectivity_amplitude_array_s[j][i] = rs ### 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 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"] self.transmissivity_amplitude_array[i] = t ### 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"] self.reflectivity_amplitude_array[i] = r ### 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 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