-
Notifications
You must be signed in to change notification settings - Fork 29
/
07_qutip_usage.html
306 lines (184 loc) · 19.3 KB
/
07_qutip_usage.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Using Krotov with QuTiP — Krotov 7c20d3f documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/version-alert.js"></script>
<script crossorigin="anonymous" integrity="sha256-Ae2Vz/4ePdIu6ZyI/5ZGsYnb+m0JlOmKPjt6XZ9JJkA=" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"extensions": ["tex2jax.js"], "jax": ["input/TeX", "output/SVG"], "TeX": {"extensions": ["AMSmath.js", "AMSsymbols.js"], "Macros": {"tr": ["{\\operatorname{tr}}", 0], "diag": ["{\\operatorname{diag}}", 0], "abs": ["{\\operatorname{abs}}", 0], "pop": ["{\\operatorname{pop}}", 0], "ee": ["{\\text{e}}", 0], "ii": ["{\\text{i}}", 0], "aux": ["{\\text{aux}}", 0], "opt": ["{\\text{opt}}", 0], "tgt": ["{\\text{tgt}}", 0], "init": ["{\\text{init}}", 0], "lab": ["{\\text{lab}}", 0], "rwa": ["{\\text{rwa}}", 0], "bra": ["{\\langle#1\\vert}", 1], "ket": ["{\\vert#1\\rangle}", 1], "Bra": ["{\\left\\langle#1\\right\\vert}", 1], "Braket": ["{\\left\\langle #1\\vphantom{#2} \\mid #2\\vphantom{#1}\\right\\rangle}", 2], "ketbra": ["{\\vert#1\\rangle\\!\\langle#2\\vert}", 2], "Ket": ["{\\left\\vert#1\\right\\rangle}", 1], "mat": ["{\\mathbf{#1}}", 1], "op": ["{\\hat{#1}}", 1], "Op": ["{\\hat{#1}}", 1], "dd": ["{\\,\\text{d}}", 0], "daggered": ["{^{\\dagger}}", 0], "transposed": ["{^{\\text{T}}}", 0], "Liouville": ["{\\mathcal{L}}", 0], "DynMap": ["{\\mathcal{E}}", 0], "identity": ["{\\mathbf{1}}", 0], "Norm": ["{\\left\\lVert#1\\right\\rVert}", 1], "norm": ["{\\lVert#1\\rVert}", 1], "Abs": ["{\\left\\vert#1\\right\\vert}", 1], "avg": ["{\\langle#1\\rangle}", 1], "Avg": ["{\\left\\langle#1\\right\\rangle}", 1], "AbsSq": ["{\\left\\vert#1\\right\\vert^2}", 1], "Re": ["{\\operatorname{Re}}", 0], "Im": ["{\\operatorname{Im}}", 0], "Real": ["{\\mathbb{R}}", 0], "Complex": ["{\\mathbb{C}}", 0], "Integer": ["{\\mathbb{N}}", 0]}}, "tex2jax": {"inlineMath": [["$", "$"], ["\\(", "\\)"]], "processEscapes": true, "ignoreClass": "document", "processClass": "math|output_area"}})</script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/graphviz.css" type="text/css" />
<link rel="stylesheet" href="_static/mycss.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Examples" href="08_examples.html" />
<link rel="prev" title="Krotov’s Method" href="06_krotovs_method.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Krotov
</a>
<div class="version">
0.4.0
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="01_overview.html">Krotov Python Package</a></li>
<li class="toctree-l1"><a class="reference internal" href="02_contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="03_authors.html">Credits</a></li>
<li class="toctree-l1"><a class="reference internal" href="04_features.html">Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="05_history.html">History</a></li>
<li class="toctree-l1"><a class="reference internal" href="06_krotovs_method.html">Krotov’s Method</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Using Krotov with QuTiP</a></li>
<li class="toctree-l1"><a class="reference internal" href="08_examples.html">Examples</a></li>
<li class="toctree-l1"><a class="reference internal" href="09_howto.html">How-Tos</a></li>
<li class="toctree-l1"><a class="reference internal" href="10_other_methods.html">Other Optimization Methods</a></li>
<li class="toctree-l1"><a class="reference internal" href="99_bibliography.html">References</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="API/krotov.html">API of the Krotov package</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Krotov</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Using Krotov with QuTiP</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<style>
/* CSS overrides for sphinx_rtd_theme */
/* 24px margin */
.nbinput.nblast.container,
.nboutput.nblast.container {
margin-bottom: 19px; /* padding has already 5px */
}
/* ... except between code cells! */
.nblast.container + .nbinput.container {
margin-top: -19px;
}
.admonition > p:before {
margin-right: 4px; /* make room for the exclamation icon */
}
/* Fix math alignment, see https://github.com/rtfd/sphinx_rtd_theme/pull/686 */
.math {
text-align: unset;
}
</style>
<div class="section" id="using-krotov-with-qutip">
<span id="id1"></span><h1>Using Krotov with QuTiP<a class="headerlink" href="#using-krotov-with-qutip" title="Permalink to this headline">¶</a></h1>
<p>The <a class="reference internal" href="API/krotov.html#module-krotov" title="krotov"><code class="xref py py-mod docutils literal notranslate"><span class="pre">krotov</span></code></a> package is designed around <a class="reference external" href="http://qutip.org">QuTiP</a>, a very powerful “Quantum
Toolbox” in Python. This means that all operators and states are expressed as
<a class="reference external" href="http://qutip.org/docs/latest/apidoc/classes.html#qutip.Qobj" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-class docutils literal notranslate"><span class="pre">qutip.Qobj</span></code></a> quantum objects. The <a class="reference internal" href="API/krotov.optimize.html#krotov.optimize.optimize_pulses" title="krotov.optimize.optimize_pulses"><code class="xref py py-func docutils literal notranslate"><span class="pre">optimize_pulses()</span></code></a> interface
for Krotov’s optimization method is closely linked to the interface of QuTiP’s
central <a class="reference external" href="http://qutip.org/docs/latest/apidoc/functions.html#qutip.mesolve.mesolve" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-func docutils literal notranslate"><span class="pre">mesolve()</span></code></a> routine for simulating the system
dynamics of a closed or open quantum system. In particular, when setting up an
optimization, the (time-dependent) system Hamiltonian should be represented by
a nested list. This is, a Hamiltonian of the form <span class="math notranslate nohighlight">\(\Op{H} = \Op{H}_0 +
\epsilon(t) \Op{H}_1\)</span> is represented as <code class="docutils literal notranslate"><span class="pre">H</span> <span class="pre">=</span> <span class="pre">[H0,</span> <span class="pre">[H1,</span> <span class="pre">eps]]</span></code> where <code class="docutils literal notranslate"><span class="pre">H0</span></code>
and <code class="docutils literal notranslate"><span class="pre">H1</span></code> are <a class="reference external" href="http://qutip.org/docs/latest/apidoc/classes.html#qutip.Qobj" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Qobj</span></code></a> operators, and <code class="docutils literal notranslate"><span class="pre">eps</span></code> is a function with
signature <code class="docutils literal notranslate"><span class="pre">eps(t,</span> <span class="pre">args)</span></code>, or an array of control values with the length of the
time grid (<cite>tlist</cite> parameter in <a class="reference external" href="http://qutip.org/docs/latest/apidoc/functions.html#qutip.mesolve.mesolve" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-func docutils literal notranslate"><span class="pre">mesolve()</span></code></a>). The operator
can depend on multiple controls, resulting in expressions of the form <code class="docutils literal notranslate"><span class="pre">H</span> <span class="pre">=</span>
<span class="pre">[H0,</span> <span class="pre">[H1,</span> <span class="pre">eps1],</span> <span class="pre">[H2,</span> <span class="pre">eps2],</span> <span class="pre">...]</span></code>.</p>
<p>The central routine provided by the <a class="reference internal" href="API/krotov.html#module-krotov" title="krotov"><code class="xref py py-mod docutils literal notranslate"><span class="pre">krotov</span></code></a> package is
<a class="reference internal" href="API/krotov.optimize.html#krotov.optimize.optimize_pulses" title="krotov.optimize.optimize_pulses"><code class="xref py py-func docutils literal notranslate"><span class="pre">optimize_pulses()</span></code></a>. It takes as input a list of objectives, each of which
is an instance of <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective" title="krotov.objectives.Objective"><code class="xref py py-class docutils literal notranslate"><span class="pre">Objective</span></code></a>. Each objective has an
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.initial_state" title="krotov.objectives.Objective.initial_state"><code class="xref py py-attr docutils literal notranslate"><span class="pre">initial_state</span></code></a>, which is a <a class="reference external" href="http://qutip.org/docs/latest/apidoc/classes.html#qutip.Qobj" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-class docutils literal notranslate"><span class="pre">qutip.Qobj</span></code></a> representing
a Hilbert space state or density matrix, a <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.target" title="krotov.objectives.Objective.target"><code class="xref py py-attr docutils literal notranslate"><span class="pre">target</span></code></a> (usually
the target state that the <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.initial_state" title="krotov.objectives.Objective.initial_state"><code class="xref py py-attr docutils literal notranslate"><span class="pre">initial_state</span></code></a> should evolve into
when the objective is fulfilled), and a Hamiltonian <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.H" title="krotov.objectives.Objective.H"><code class="xref py py-attr docutils literal notranslate"><span class="pre">H</span></code></a> in
the nested-list format described above. For dissipative dynamics,
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.H" title="krotov.objectives.Objective.H"><code class="xref py py-attr docutils literal notranslate"><span class="pre">H</span></code></a> should be a Liouvillian, which can be obtained from the
Hamiltonian and a set of Lindblad operators via
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.liouvillian" title="krotov.objectives.liouvillian"><code class="xref py py-func docutils literal notranslate"><span class="pre">krotov.objectives.liouvillian()</span></code></a>. The Liouvillian again is in nested list
format to express time-dependencies. Alternatively, each objective could also
directly include a list <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.c_ops" title="krotov.objectives.Objective.c_ops"><code class="xref py py-attr docutils literal notranslate"><span class="pre">c_ops</span></code></a> of collapse (Lindblad)
operators , where each collapse operator is a <a class="reference external" href="http://qutip.org/docs/latest/apidoc/classes.html#qutip.Qobj" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-class docutils literal notranslate"><span class="pre">Qobj</span></code></a> operator.
However, this only makes sense if the time propagation routine takes the
collapse operators into account explicitly, such as in the Monte-Carlo
<a class="reference external" href="http://qutip.org/docs/latest/apidoc/functions.html#qutip.mcsolve.mcsolve" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-func docutils literal notranslate"><span class="pre">mcsolve()</span></code></a>. Otherwise, the use of
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.c_ops" title="krotov.objectives.Objective.c_ops"><code class="xref py py-attr docutils literal notranslate"><span class="pre">c_ops</span></code></a> is strongly discouraged.</p>
<p>In order to simulate the dynamics of the guess control, you can use
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.mesolve" title="krotov.objectives.Objective.mesolve"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Objective.mesolve()</span></code></a>, which delegates to <a class="reference external" href="http://qutip.org/docs/latest/apidoc/functions.html#qutip.mesolve.mesolve" title="(in QuTiP: Quantum Toolbox in Python v4.4)"><code class="xref py py-func docutils literal notranslate"><span class="pre">qutip.mesolve.mesolve()</span></code></a>.
There is also a related method <a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.propagate" title="krotov.objectives.Objective.propagate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Objective.propagate()</span></code></a> that uses a
different sampling of the control values, see <a class="reference internal" href="API/krotov.propagators.html#module-krotov.propagators" title="krotov.propagators"><code class="xref py py-mod docutils literal notranslate"><span class="pre">krotov.propagators</span></code></a>.</p>
<p>The optimization routine will automatically extract all controls that it can
find in the objectives, and iteratively calculate updates to all controls in
order to meet all <cite>objectives</cite> simultaneously. The result of the optimization
will be in the returned <a class="reference internal" href="API/krotov.result.html#krotov.result.Result" title="krotov.result.Result"><code class="xref py py-class docutils literal notranslate"><span class="pre">Result</span></code></a> object, with a list of the optimized
controls in <a class="reference internal" href="API/krotov.result.html#krotov.result.Result.optimized_controls" title="krotov.result.Result.optimized_controls"><code class="xref py py-attr docutils literal notranslate"><span class="pre">optimized_controls</span></code></a>.
The <code class="xref py py-attr docutils literal notranslate"><span class="pre">optimized_objectives</span></code> property contains a copy of the
objectives with the <a class="reference internal" href="API/krotov.result.html#krotov.result.Result.optimized_controls" title="krotov.result.Result.optimized_controls"><code class="xref py py-attr docutils literal notranslate"><span class="pre">optimized_controls</span></code></a> plugged into the
Hamiltonian or Liouvillian and/or collapse operators. The dynamics under the
optimized controls can then again be simulated through
<a class="reference internal" href="API/krotov.objectives.html#krotov.objectives.Objective.mesolve" title="krotov.objectives.Objective.mesolve"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Objective.mesolve()</span></code></a>.</p>
<p>While the guess controls that are in the <cite>objectives</cite> on input may be
functions, or an array of control values on the time grid, the output
<a class="reference internal" href="API/krotov.result.html#krotov.result.Result.optimized_controls" title="krotov.result.Result.optimized_controls"><code class="xref py py-attr docutils literal notranslate"><span class="pre">optimized_controls</span></code></a> will always be an array of control values.</p>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="08_examples.html" class="btn btn-neutral float-right" title="Examples" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="06_krotovs_method.html" class="btn btn-neutral float-left" title="Krotov’s Method" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2019, Michael Goerz et al.
<span class="lastupdated">
Last updated on Dec 14, 2019.
</span>
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>