-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_analytic.py
36 lines (26 loc) · 1.19 KB
/
test_analytic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import numpy as np
from pytest import approx, mark
import sys
@mark.skipif(sys.platform != "linux", reason="S4 (RCWA) only installed for tests under Linux")
def test_get_order_directions():
from rayflare.analytic.diffraction import get_order_directions
from solcore import material
Air = material("Air")()
Si = material("Si")()
x = 700
size = ((x, 0), (x / 2, np.sin(np.pi / 3) * x))
wl = np.linspace(600, 1100, 50)
res_ref = get_order_directions(wl, size, 3, Air, Si, 0.2, 0)
in_oc = [1, 1.0, np.ones_like(wl), np.ones_like(wl).tolist()]
out_oc = [Si.n(wl*1e-9), Si.n(wl*1e-9).tolist(), 4, 3.6]
for ni in in_oc:
for no in out_oc:
res = get_order_directions(wl, size, 3, ni, no, 0.2, 0)
assert np.all(np.array(res["order_index"]) == np.array(res_ref["order_index"]))
assert np.min(res["theta_r"]) == approx(0.2)
assert np.max(res["theta_r"]) == approx(np.pi/2)
assert np.min(res["theta_t"]) == approx(np.pi/2)
assert np.max(res["theta_t"]) < np.pi
assert np.min(res["k_xy"]) == 0
assert np.min(res["phi"]) >= 0
assert np.max(res["phi"]) < np.pi/2