-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinterface_node.m
83 lines (72 loc) · 2.79 KB
/
interface_node.m
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
classdef interface_node < handle & tf_node
properties
from % index of material after interface
into % index of material after interface
t_acc % total time accumulated to reach this node
amp % amplitude after this node
type % +1 for transmission, -1 for reflection
child % layer_node child
end
methods
function obj = interface_node(from, into, type, t_acc, amp_prev,...
geom, freq, n_solve, t_cut, a_cut, parent)
obj.from = from; obj.into = into; obj.t_acc = t_acc;
obj.type = type; obj.parent = parent;
obj.num_layers = numel(geom);
n_from = geom(from).n_func(freq, n_solve);
n_into = geom(into).n_func(freq, n_solve);
rf = node_constants.rf;
tr = node_constants.tr;
% handle reflection
if type == -1
amp = amp_prev*abs(rf(n_from, n_into));
obj.amp = amp;
obj.tf = rf(n_from, n_into);
if amp > a_cut
obj.child = layer_node(from, from-into, t_acc, amp,...
geom, freq, n_solve, t_cut, a_cut, obj);
end
end
if type == +1
amp = amp_prev*abs(tr(n_from, n_into));
obj.amp = amp;
obj.tf = tr(n_from, n_into);
if (amp > a_cut) && into < numel(geom)
obj.child = layer_node(into, into-from, t_acc, amp, ...
geom, freq, n_solve, t_cut, a_cut, obj);
end
end
end
function cs = children(obj)
cs = [];
if isa(obj.child, 'layer_node')
cs = obj.child;
end
end
function s = to_s(obj)
type_s = 'r';
if obj.type > 0
type_s = 't';
end
s = sprintf('%d -> %d (%s)', obj.from, obj.into, type_s);
end
function s = dot_label(obj, em)
type_s = 'r';
color = '#ffb380';
if obj.type > 0
type_s = 't';
color = '#ff9999';
end
fcolor = [color '78'];
if em
color = '#000000';
end
pen_width = '1.0';
if em
pen_width = '4.0';
end
s = sprintf('%d[label=<%s<SUB>%d%d</SUB>>, style=filled, color="%s", fillcolor="%s", penwidth=%s]\n', ...
obj.id, type_s, obj.from, obj.into, color, fcolor, pen_width);
end
end
end