-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSymbolicComputationInteractive.sage
89 lines (66 loc) · 2.19 KB
/
SymbolicComputationInteractive.sage
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
84
85
86
87
88
89
class SymbolicComputationInteractive(SymbolicComputationBase):
"""
Makes interactive tables
"""
def InteractiveSubspaceOperators(self):
"""
Returns inner function
Prepares default values for inner function
"""
def inner(index = self.space.SubspaceSelector()):
"""
Prints H, L for given subspace
User specifies subspace
Should be passed to interact()
"""
subspace = self.space.subspaces[index]
name = 'H'
var = subspace.GetBlock(self.H)
l = [(name, var)]
for i, L in enumerate(self.L):
name = 'L_{}'.format(i)
var = subspace.GetBlock(L)
l.append((name, var))
html_vars(l)
return inner
def InteractiveVars(self):
"""
Returns inner function
Prepares default values for inner function
"""
l = [
(r'|g\rangle', self.psi_g),
(r'|e\rangle', self.psi_e),
(r'|0\rangle', self.psi_ph0),
(r'|1\rangle', self.psi_ph1),
(r'a', self.a),
(r'a^{+}', self.a_plus),
(r'\sigma^{-}', self.sigma_minus),
(r'\sigma^{+}', self.sigma_plus),
(r'H_{\rm field}', self.H_field),
(r'H_{\rm at}', self.H_at),
(r'H_{\rm field,at}', self.H_field_at),
(r'H_{\rm sum}', self.H_sum),
(r'H_{\rm tun}', self.H_tun),
(r'H_{\rm chain}', self.H_chain),
(r'H', self.H),
(r'T', self.space.T),
(r'H^{\rm ex}', self.H_e)
]
d = dict(l)
latex_vars = ['${}$'.format(x[0]) for x in l]
variable_selector = selector(
label = 'Show variable: ',
values = latex_vars,
buttons = True,
ncols = 4,
nrows = 5)
def inner(variable = variable_selector):
"""
Prints matrix chosen by the user
Should be passed to interact()
"""
key = variable[1:-1]
value = d[key]
html_var(key, value)
return inner