Skip to content

Commit f113646

Browse files
committed
cleaned up beta - now ready for release!
1 parent abcf493 commit f113646

File tree

3 files changed

+0
-234
lines changed

3 files changed

+0
-234
lines changed

wptherml/lightlib.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,6 @@ def normalized_power(lam, TE, BB):
3737
return numerator/denominator
3838

3939

40-
def Lum_efficiency_prime(lam, TE, TE_prime):
41-
upper = np.amax(lam)
42-
ph = datalib.PhLum(lam)
43-
num = ph*TE
44-
num_prime = ph*TE_prime
45-
numerator = numlib.Integrate(num, lam, 0, upper )
46-
numerator_prime = numlib.Integrate(num_prime, lam, 0, upper)
47-
48-
denominator = numlib.Integrate(TE, lam, 0, upper)
49-
denominator_prime = numlib.Integrate(TE_prime, lam, 0, upper)
50-
51-
return (denominator*numerator_prime - numerator*denominator_prime)/(denominator**2)
52-
5340
def Lum_efficacy(lam, TE):
5441
le = Lum_efficiency(lam, TE)
5542
efficacy = 683*le
@@ -64,29 +51,3 @@ def IdealSource(lam, T):
6451
TE_ideal = ph * rho
6552
return TE_ideal
6653

67-
'''
68-
69-
def luminous_efficiency(lam, thermal_emission_array):
70-
upper = np.amax(lam)
71-
ph = datalib.PhLum(lam)
72-
num = datalib.PhLum(lam)*thermal_emission_array
73-
numerator = numlib.Integrate(num, lam, 0, upper )
74-
den = thermal_emission_array
75-
denominator = numlib.Integrate(den, lam, 0, upper)
76-
luminous_efficiency_value = (numerator/denominator)
77-
return luminous_efficiency_value
78-
79-
def luminous_efficacy(lam, thermal_emission_array):
80-
le = luminous_efficiency_value(lam, thermal_emission_array)
81-
luminous_efficacy_value = 683*le
82-
return luminous_efficacy_value
83-
84-
def thermal_emission_ideal_source(lam, T):
85-
### compute blackbody spectrum at current T
86-
rho = datalib.BB(lam, T)
87-
### get photopic luminosity function
88-
ph = datalib.PhLum(lam)
89-
### ideal thermal emission is product of the two
90-
thermal_emission_ideal_source = ph * rho
91-
return thermal_emission_ideal_source_array
92-
'''

wptherml/tmm.py

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ def BuildP(phil):
2525

2626
### this function will compute the derivative of the P matrix for a given
2727
### layer l with respect to the thickness of layer l
28-
def Build_dP_ds(kzl, dl):
29-
P = np.zeros((2,2),dtype=complex)
30-
ci = 0+1j
31-
a = -1*ci*kzl*dl
32-
b = ci*kzl*dl
33-
P[0][1] = 0+0j
34-
P[1][0] = 0+0j
35-
P[0][0] = -ci*kzl*np.exp(a)
36-
P[1][1] = ci*kzl*np.exp(b)
37-
return P
3828

3929
def BuildD(nl, ctheta,pol):
4030
D = np.zeros((2,2),dtype=complex)
@@ -172,151 +162,7 @@ def tmm(k0, theta0, pol, nA, tA):
172162
return M
173163

174164

175-
### analytically differentiates the transfer matrix
176-
### with respect to the thickness of a layer li to be specified by
177-
### the user!
178-
def d_tmm_dsi(li, k0, theta0, pol, nA, tA):
179-
t1 = np.zeros((2,2),dtype=complex)
180-
t2 = np.zeros((2,2),dtype=complex)
181-
Dl = np.zeros((2,2),dtype=complex)
182-
Dli = np.zeros((2,2),dtype=complex)
183-
Pl = np.zeros((2,2),dtype=complex)
184-
M = np.zeros((2,2),dtype=complex)
185-
186-
D1 = BuildD(nA[0], np.cos(theta0), pol)
187-
### Note it is actually faster to invert the 2x2 matrix
188-
### "By Hand" than it is to use linalg.inv
189-
### and this inv step seems to be the bottleneck for the TMM function
190-
tmp = D1[0,0]*D1[1,1]-D1[0,1]*D1[1,0]
191-
det = 1/tmp
192-
M[0,0] = det*D1[1,1]
193-
M[0,1] = -det*D1[0,1]
194-
M[1,0] = -det*D1[1,0]
195-
M[1,1] = det*D1[0,0]
196-
#D1i = inv(D1)
197-
#print("D1i is ")
198-
#print(D1i)
199-
200-
201-
### This is the number of layers in the structure
202-
L = len(nA)
203-
kz = np.zeros(L,dtype=complex)
204-
phil = np.zeros(L,dtype=complex)
205-
ctheta = np.zeros(L,dtype=complex)
206-
theta = np.zeros(L,dtype=complex)
207-
208-
### since kx is conserved through all layers, just compute it
209-
### in the upper layer (layer 1), for which you already known
210-
### the angle of incidence
211-
kx = nA[0]*k0*np.sin(theta0)
212-
kz[0] = np.sqrt((nA[0]*k0)**2 - kx**2)
213-
kz[L-1] = np.sqrt((nA[L-1]*k0)**2 - kx**2)
214-
215-
### keeping consistent with K-R excitation
216-
if np.real(kz[0])<0:
217-
kz[0] = -1*kz[0]
218-
if np.imag(kz[L-1])<0:
219-
kz[L-1] = -1*kz[L-1]
220-
221-
''' For dM/dsi we have three cases:
222-
we compute contributions to M as normal for layers 2-li-1
223-
we compute dPi/dsi for layer li
224-
we compute contributions to M as normal for layers li+1 - L-1
225-
'''
226-
227-
''' layers 2 - li-1 '''
228-
for i in range(1,li):
229-
kz[i] = np.sqrt((nA[i]*k0)**2 - kx**2)
230-
if np.imag(kz[i])<0:
231-
kz[i] = -1*kz[i]
232-
233-
ctheta[i] = kz[i]/(nA[i]*k0)
234-
theta[i] = np.arccos(ctheta[i])
235-
236-
phil[i] = kz[i]*tA[i]
237-
238-
Dl = BuildD(nA[i],ctheta[i], pol)
239-
## Invert Dl
240-
tmp = Dl[0,0]*Dl[1,1]-Dl[0,1]*Dl[1,0]
241-
det = 1/tmp
242-
Dli[0,0] = det*Dl[1,1]
243-
Dli[0,1] = -det*Dl[0,1]
244-
Dli[1,0] = -det*Dl[1,0]
245-
Dli[1,1] = det*Dl[0,0]
246-
#Dli = inv(Dl)
247-
## form Pl
248-
Pl = BuildP(phil[i])
249-
250-
t1 = np.matmul(M,Dl)
251-
t2 = np.matmul(t1,Pl)
252-
M = np.matmul(t2,Dli)
253-
254-
''' layer li '''
255-
kz[li] = np.sqrt((nA[li]*k0)**2 - kx**2)
256-
if np.imag(kz[li])<0:
257-
kz[li] = -1*kz[li]
258-
259-
ctheta[li] = kz[li]/(nA[li]*k0)
260-
theta[li] = np.arccos(ctheta[li])
261-
262-
Dl = BuildD(nA[li], ctheta[li], pol)
263-
tmp = Dl[0,0]*Dl[1,1]-Dl[0,1]*Dl[1,0]
264-
det = 1/tmp
265-
Dli[0,0] = det*Dl[1,1]
266-
Dli[0,1] = -det*Dl[0,1]
267-
Dli[1,0] = -det*Dl[1,0]
268-
Dli[1,1] = det*Dl[0,0]
269-
270-
Pl = Build_dP_ds(kz[li], tA[li])
271-
272-
t1 = np.matmul(M, Dl)
273-
t2 = np.matmul(t1, Pl)
274-
M = np.matmul(t2, Dli)
275-
276-
277-
''' layers li+1 - L-1 '''
278-
for i in range(li+1,(L-1)):
279-
kz[i] = np.sqrt((nA[i]*k0)**2 - kx**2)
280-
if np.imag(kz[i])<0:
281-
kz[i] = -1*kz[i]
282-
283-
ctheta[i] = kz[i]/(nA[i]*k0)
284-
theta[i] = np.arccos(ctheta[i])
285-
286-
phil[i] = kz[i]*tA[i]
287-
288-
Dl = BuildD(nA[i],ctheta[i], pol)
289-
## Invert Dl
290-
tmp = Dl[0,0]*Dl[1,1]-Dl[0,1]*Dl[1,0]
291-
det = 1/tmp
292-
Dli[0,0] = det*Dl[1,1]
293-
Dli[0,1] = -det*Dl[0,1]
294-
Dli[1,0] = -det*Dl[1,0]
295-
Dli[1,1] = det*Dl[0,0]
296-
#Dli = inv(Dl)
297-
## form Pl
298-
Pl = BuildP(phil[i])
299-
300-
t1 = np.matmul(M,Dl)
301-
t2 = np.matmul(t1,Pl)
302-
M = np.matmul(t2,Dli)
303-
304-
### M is now the product of D_1^-1 .... D_l-1^-1... just need to
305-
### compute D_L and multiply M*D_L
306-
kz[L-1] = np.sqrt((nA[L-1]*k0)**2 - kx**2)
307-
ctheta[L-1]= kz[L-1]/(nA[L-1]*k0)
308-
DL = BuildD(nA[L-1], ctheta[L-1], pol)
309-
t1 = np.matmul(M,DL)
310-
### going to create a dictionary called M which will
311-
### contain the matrix elements of M as well as
312-
### other important quantities like incoming and outgoing angles
313-
dM_ds = {"dM11_ds": t1[0,0],
314-
"dM12_ds": t1[0,1],
315-
"dM21_ds": t1[1,0],
316-
"dM22_ds": t1[1,1]
317-
}
318165

319-
return dM_ds
320166
### This function will take a thickness array
321167
### and a scalar thickness and will return
322168
### the index of the layer in which you are in

wptherml/wpml.py

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ def __init__(self, args):
112112
self.valid_emiss_vs_theta = []
113113
self.validation_option = 1
114114

115-
### derivative quantities
116-
self.reflectivity_prime_array = np.zeros(len(self.lambda_array))
117-
self.emissivity_prime_array = np.zeros(len(self.lambda_array))
118-
119115

120116
### In some cases the user may wish to compute
121117
### R, T, or eps vs angle at a specific wavelength
@@ -297,39 +293,7 @@ def fresnel(self):
297293
return 1
298294
### currently will return derivative of reflectivity and emissivity
299295
### wrt to thickness of layer i
300-
def fresnel_prime(self, layer_i):
301-
nc = np.zeros(len(self.d),dtype=complex)
302-
for i in range(0,len(self.lambda_array)):
303-
for j in range(0,len(self.d)):
304-
nc[j] = self.n[j][i]
305-
306-
k0 = np.pi*2/self.lambda_array[i]
307-
### get transfer matrix for this k0, th, pol, nc, and d
308-
M = tmm.tmm(k0, self.theta, self.pol, nc, self.d)
309-
dM_ds = tmm.d_tmm_dsi(layer_i, k0, self.theta, self.pol, nc, self.d)
310-
311-
### store all relevant matrix elements in variable names
312-
M21 = M["M21"]
313-
M11 = M["M11"]
314-
M21p = dM_ds["dM21_ds"]
315-
M11p = dM_ds["dM11_ds"]
316-
317-
### get reflection amplitude
318-
r = M["M21"]/M["M11"]
319-
r_star = np.conj(r)
320-
321-
### get derivative of reflection amplitudes
322-
r_prime = (M11*M21p - M21*M11p)/(M11*M11)
323-
r_prime_star = np.conj(r_prime)
324-
325-
### get reflectivity
326-
R_prime = r_prime * r_star + r * r_prime_star
327-
### get Reflectivity
328-
self.reflectivity_prime_array[i] = np.real(R_prime)
329-
### get Transmissivity
330-
self.emissivity_prime_array[i] = 1 - self.reflectivity_prime_array[i]
331296

332-
return 1
333297

334298
def angular_fresnel(self, lambda_0):
335299
### create an array for RI of each layer at the
@@ -463,11 +427,6 @@ def thermal_emission_ea(self):
463427

464428
return 1
465429

466-
''' METHOD FOR J-AGG ENHANCEMENT '''
467-
def jagg_sd(self):
468-
self.jagg_sd_val = numlib.Integrate(self.emissivity_array, self.lambda_array, 500e-9, 700e-9)/200e-9
469-
return 1
470-
471430
''' METHODS FOR STPVLIB!!! '''
472431

473432
### Normal versions first - no explicit dependence on angle

0 commit comments

Comments
 (0)