-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
241 lines (215 loc) · 14.6 KB
/
index.html
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bloch sphere visualizer</title>
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!--Import materialize.css-->
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" media="screen,projection"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<!-- Custom CSS-->
<link type="text/css" rel="stylesheet" href="style.css" media="screen,projection"/>
<!-- Favicon -->
<link rel="icon" type="image/x-icon" href="logo_v1.svg">
<!--Let browser know website is optimized for mobile-->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="description" content="Simulate the evolution of a qubit or spin on the Bloch sphere. This tool is ideal to understand quantum operations and to generate plots for presentations or publications.">
<link rel="canonical" href="https://bloch.kherb.io/" />
</head>
<body class="indigo lighten-5">
<main>
<div class="container" style="min-width:1200px">
<script type="text/javascript">
$(document).ready(function(){
$('.collapsible').collapsible();
});
</script>
<div class="row lighten-5 grey">
<nav>
<div class="nav-wrapper indigo">
<img src="logo_v1.svg" alt="Bloch sphere tool" style="height: 3.5em; margin:0.5em"/> <a href="#" class="brand-logo" style="margin-left:.4em;"><span style="height: 1.8em; margin-bottom: .1em; display:inline-block">Bloch sphere simulator</span></a>
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li class="active"><a href="index.html">Tool</a></li>
<li><a href="explain.html">Explanation</a></li>
<li ><a href="https://github.com/kherb27/Blochy" target="_blank">GitHub ↗</a></li>
</ul>
</div>
</nav>
<div class="col s12 indigo"></div>
<div class="col s12" style="margin-top:1em;"><a class="waves-effect waves-light btn-small" onclick="restart()">Init</a>
<a class="waves-effect waves-light btn-small" onclick="undo()">Undo</a>
</div>
<div class="col s6">
<div id='myDiv' class='card' style='padding-bottom: 100%;'><noscript>Javascript necessary</noscript></div>
<a class="waves-effect waves-light btn-small" onclick="export_png()" style="margin-bottom: 1em;">Download</a>
</div>
<div class="col s6">
<ul class="collapsible expandable">
<li class="active">
<div class="collapsible-header"><i class="material-icons">rotate_right</i>Rotations around default axes</div>
<div class="collapsible-body">
<table>
<tr>
<td style="min-width:4em;">
x axis
</td>
<td>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',math.PI/2);">+90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',-math.PI/2);">-90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',math.PI);">+180°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',-math.PI);">-180°</a>
<div class="input-field inline" style="width:3em; margin-left:1em;">
<input id="x_angle" type="number" style="width:2em;" placeholder="45">°
</div>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',-document.getElementById('x_angle').value/180*math.PI);">-</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',document.getElementById('x_angle').value/180*math.PI);">+</a>
</td>
</tr>
<tr><td style="min-width:4em;">
y axis</td><td>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',math.PI/2);">+90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',-math.PI/2);">-90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',math.PI);">+180°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',-math.PI);">-180°</a>
<div class="input-field inline" style="width:3em; margin-left:1em;">
<input id="y_angle" type="number" style="width:2em;" placeholder="45">°
</div>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',-document.getElementById('y_angle').value/180*math.PI);">-</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',document.getElementById('y_angle').value/180*math.PI);">+</a>
</td>
</tr>
<tr><td style="min-width:4em;">
z axis</td><td>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',math.PI/2);">+90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',-math.PI/2);">-90°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',math.PI);">+180°</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',-math.PI);">-180°</a>
<div class="input-field inline" style="width:3em; margin-left:1em;">
<input id="z_angle" type="number" style="width:2em;" placeholder="45">°
</div>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',-document.getElementById('z_angle').value/180*math.PI);">-</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',document.getElementById('z_angle').value/180*math.PI);">+</a>
</td>
</tr></table>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">rotate_right</i>Rotations around custom axis</div>
<div class="collapsible-body">
<!--<label>
<input type="checkbox" />
<span>Show axis on sphere</span>
</label> -->
<table>
<tr>
<td>Polar angle</td><td><input id="custom_axis_polar" type="number" style="width:4em;margin-left:0.5em;" value="90">°</td>
</tr>
<tr>
<td>Azimuthal angle</td><td><input id="custom_axis_azimuth" type="number" style="width:4em;margin-left:0.5em;" value="0">°</td>
</tr>
<tr>
<td>Rotation angle</td><td><input id="custom_axis_rot_angle" type="number" style="width:4em;margin-left:0.5em;" value="90" step="1">°</td>
</tr>
</table><br/>
<a class="waves-effect waves-light btn-small blue-grey" onclick="custom_rotate_state();">Apply rotation</a>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">clear</i>Quantum gates</div>
<div class="collapsible-body">
<table>
<tr>
<td>Pauli gates</td>
<td>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('x',math.PI);">X</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('y',math.PI);">Y</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',math.PI);">Z</a>
</td>
</tr>
<tr>
<td>Hadamard</td>
<td> <a class="waves-effect waves-light btn-small blue-grey" onclick="hadamard();">H</a>
</tr>
<tr>
<td>Phase</td>
<td> <a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',math.PI/2);">S</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',-math.PI/2);">S†</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',math.PI/4);">T</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="rotate_state('z',-math.PI/4);">T†</a>
</td>
</tr>
</table>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">rss_feed</i>Pulses</div>
<div class="collapsible-body">
<table>
<tr>
<td>Detuning</td><td><input id="detuning" type="number" style="width:4em;margin-left:0.5em;" value="0" step="0.01" onchange="rabi_plot();"></td>
<td>Phase</td><td><input id="phase" type="number" style="width:4em;margin-left:0.5em;" value="0" step="1" max="360" onchange="rabi_plot();">°</td>
</tr>
<tr>
<td>Amplitude</td><td><input id="amplitude" type="number" style="width:4em;margin-left:0.5em;" value="1" step="0.01" onchange="rabi_plot();"></td>
<td>Pulse length</td><td><input id="pulselength" type="number" style="width:4em;margin-left:0.5em;" value="0.5" step="0.01" onchange="rabi_plot();"></td>
</tr>
</table>
<div>
<label>Transition probability plot</label>
<div id="rabi_div" style="width:100%;height:10em;"></div>
</div>
<div style="margin-top:4em;">
<a class="waves-effect waves-light btn-small blue-grey" onclick="pulse_apply('x');">Apply pulse along x</a>
<a class="waves-effect waves-light btn-small blue-grey" onclick="pulse_apply('y');">Apply pulse along y</a>
</div>
</div>
</li>
<li>
<div class="collapsible-header"><i class="material-icons">settings_input_component</i>Settings</div>
<div class="collapsible-body">
<table>
<tr><td>
Spin color
</td><td><input type="color" id="spin_color" value="#1a237e" onchange="update_state_plot();"></td>
<td>Histrory trace color</td><td><input type="color" id="phosphor_color" value="#1a237e" /></td>
</tr>
<tr>
<td>Top state text</td><td><input type="text" id="north_text" value="0" style="width:5em" onchange="BLOCHSPHERE = gen_bloch_sphere();update_state_plot(full_update=true)"></td>
<td>Bottom state text</td><td><input type="text" id="south_text" value="1" style="width:5em" onchange="BLOCHSPHERE = gen_bloch_sphere();update_state_plot(full_update=true)"></td>
</tr>
<tr><td>History trace length</td><td><input type="number" id="phosphor_length" value="10" min="0" step="1" style="width:5em"></td>
<td></td><td></td>
</tr>
<tr>
<td>Export size</td>
<td>
<input id="export_size" type="number" value="800" style="width:5em"> px
</td>
<td></td><td></td>
</tr>
</table>
</div>
</li>
</ul>
</div>
</div>
</div></main>
<footer class="page-footer">
<div class="footer-copyright" style="width:100%; text-align: center;margin-left: auto;margin-right: auto; display: block;">
© Konstantin Herb — ETH Zurich — 2023 — MIT license
</div>
</footer>
<!--JavaScript at end of body for optimized loading-->
<!-- Load plotly.js into the DOM -->
<!-- <script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js'></script> -->
<!-- <script src="https://cdn.plot.ly/plotly-latest.min.js"></script> -->
<script src="plotly-2.16.1.min.js"></script>
<!--Math-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/11.2.1/math.js" integrity="sha512-47N5yVdAeXJ+9qstVMTH2Z0EpX618sjYZcswRwhpldSTD0IbW6yQPtzg4RLrPp/2+TIgEF1elT68/ZBu82nqJA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="helper.js"></script>
<script src="quantum.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<script type="text/javascript" src="plot.js"></script>
<script type="text/javascript" src="ui.js"></script>
</body>
</html>