Skip to content

Commit 8a4b163

Browse files
committed
Remove notebook formatting; moved to format/notebooks-nbfmt
Notebook nbfmt diffs are in a separate PR to merge first for git-blame-ignore-revs. This PR adds only the check script, CI, and deps.
1 parent ac0b89c commit 8a4b163

14 files changed

Lines changed: 456 additions & 642 deletions

docs/fqe/guide/introduction.ipynb

Lines changed: 64 additions & 152 deletions
Large diffs are not rendered by default.

docs/fqe/tutorials/diagonal_coulomb_evolution.ipynb

Lines changed: 45 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,15 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5-
"metadata": {
6-
"id": "b000658d0d2b"
7-
},
5+
"metadata": {},
86
"source": [
97
"##### Copyright 2020 The OpenFermion Developers"
108
]
119
},
1210
{
1311
"cell_type": "code",
1412
"execution_count": null,
15-
"metadata": {
16-
"cellView": "form",
17-
"id": "906e07f6e562"
18-
},
13+
"metadata": {},
1914
"outputs": [],
2015
"source": [
2116
"#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
@@ -33,18 +28,14 @@
3328
},
3429
{
3530
"cell_type": "markdown",
36-
"metadata": {
37-
"id": "7cac3ba4e0b6"
38-
},
31+
"metadata": {},
3932
"source": [
4033
"# FQE vs OpenFermion vs Cirq: Diagonal Coulomb Operators"
4134
]
4235
},
4336
{
4437
"cell_type": "markdown",
45-
"metadata": {
46-
"id": "194e5ebc2e40"
47-
},
38+
"metadata": {},
4839
"source": [
4940
"<table class=\"tfo-notebook-buttons\" align=\"left\">\n",
5041
" <td>\n",
@@ -64,19 +55,15 @@
6455
},
6556
{
6657
"cell_type": "markdown",
67-
"metadata": {
68-
"id": "027a78b74a41"
69-
},
58+
"metadata": {},
7059
"source": [
7160
"Special routines are available for evolving under a diagonal Coulomb operator. This notebook describes how to use these built in routines and how they work."
7261
]
7362
},
7463
{
7564
"cell_type": "code",
7665
"execution_count": null,
77-
"metadata": {
78-
"id": "1b44f1bf44c3"
79-
},
66+
"metadata": {},
8067
"outputs": [],
8168
"source": [
8269
"try:\n",
@@ -88,9 +75,7 @@
8875
{
8976
"cell_type": "code",
9077
"execution_count": null,
91-
"metadata": {
92-
"id": "a623fa4c377a"
93-
},
78+
"metadata": {},
9479
"outputs": [],
9580
"source": [
9681
"from itertools import product\n",
@@ -107,9 +92,7 @@
10792
{
10893
"cell_type": "code",
10994
"execution_count": null,
110-
"metadata": {
111-
"id": "07eb37e66cea"
112-
},
95+
"metadata": {},
11396
"outputs": [],
11497
"source": [
11598
"#Utility function\n",
@@ -168,9 +151,7 @@
168151
},
169152
{
170153
"cell_type": "markdown",
171-
"metadata": {
172-
"id": "4f4ed62f910c"
173-
},
154+
"metadata": {},
174155
"source": [
175156
"The first example we will perform is diagonal Coulomb evolution on the Hartree-Fock state. The diagonal Coulomb operator is defined as\n",
176157
"\n",
@@ -189,9 +170,7 @@
189170
{
190171
"cell_type": "code",
191172
"execution_count": null,
192-
"metadata": {
193-
"id": "2d22924fcb4e"
194-
},
173+
"metadata": {},
195174
"outputs": [],
196175
"source": [
197176
"norbs = 4\n",
@@ -213,19 +192,15 @@
213192
},
214193
{
215194
"cell_type": "markdown",
216-
"metadata": {
217-
"id": "f4b8c93472be"
218-
},
195+
"metadata": {},
219196
"source": [
220197
"Now we can define a random 2-electron operator $V$. To define $V$ we need a $4 \\times 4$ matrix. We will generate this matrix by making a full random two-electron integral matrix and then just take the diagonal elements"
221198
]
222199
},
223200
{
224201
"cell_type": "code",
225202
"execution_count": null,
226-
"metadata": {
227-
"id": "56aa8604a016"
228-
},
203+
"metadata": {},
229204
"outputs": [],
230205
"source": [
231206
"tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))\n",
@@ -246,19 +221,15 @@
246221
},
247222
{
248223
"cell_type": "markdown",
249-
"metadata": {
250-
"id": "5270f0939273"
251-
},
224+
"metadata": {},
252225
"source": [
253226
"Evolution under $V$ can be computed by looking at each bitstring, seeing if $n_{p\\alpha}n_{q\\beta}$ is non-zero and then phasing that string by $V_{pq}$. For the Hartree-Fock state we can easily calculate this phase accumulation. The alpha and beta bitstrings are \"0001\" and \"0001\". "
254227
]
255228
},
256229
{
257230
"cell_type": "code",
258231
"execution_count": null,
259-
"metadata": {
260-
"id": "d7ee0994bdc2"
261-
},
232+
"metadata": {},
262233
"outputs": [],
263234
"source": [
264235
"alpha_occs = [list(range(fci_graph.nalpha()))]\n",
@@ -280,19 +251,15 @@
280251
},
281252
{
282253
"cell_type": "markdown",
283-
"metadata": {
284-
"id": "9797ff1de370"
285-
},
254+
"metadata": {},
286255
"source": [
287256
"We can now try this out for more than 2 electrons. Let's reinitialize a wavefunction on 6-orbitals with 4-electrons $S_{z} = 0$ to a random state."
288257
]
289258
},
290259
{
291260
"cell_type": "code",
292261
"execution_count": null,
293-
"metadata": {
294-
"id": "7a26d169c115"
295-
},
262+
"metadata": {},
296263
"outputs": [],
297264
"source": [
298265
"norbs = 6\n",
@@ -311,19 +278,15 @@
311278
},
312279
{
313280
"cell_type": "markdown",
314-
"metadata": {
315-
"id": "89354765d52a"
316-
},
281+
"metadata": {},
317282
"source": [
318283
"We need to build our Diagoanl Coulomb operator For this bigger system."
319284
]
320285
},
321286
{
322287
"cell_type": "code",
323288
"execution_count": null,
324-
"metadata": {
325-
"id": "eec8fa7be891"
326-
},
289+
"metadata": {},
327290
"outputs": [],
328291
"source": [
329292
"tei_compressed = np.random.randn(tedim**2).reshape((tedim, tedim))\n",
@@ -344,19 +307,15 @@
344307
},
345308
{
346309
"cell_type": "markdown",
347-
"metadata": {
348-
"id": "0bab89d13edf"
349-
},
310+
"metadata": {},
350311
"source": [
351312
"Now we can convert our wavefunction to a cirq wavefunction, evolve under the diagonal_coulomb operator we constructed and then compare the outputs."
352313
]
353314
},
354315
{
355316
"cell_type": "code",
356317
"execution_count": null,
357-
"metadata": {
358-
"id": "e28ac36062b7"
359-
},
318+
"metadata": {},
360319
"outputs": [],
361320
"source": [
362321
"cirq_wfn = fqe.to_cirq(fqe_wfn).reshape((-1, 1))\n",
@@ -368,9 +327,7 @@
368327
{
369328
"cell_type": "code",
370329
"execution_count": null,
371-
"metadata": {
372-
"id": "5a1a81b3c86a"
373-
},
330+
"metadata": {},
374331
"outputs": [],
375332
"source": [
376333
"fqe_wfn = fqe_wfn.time_evolve(1, dc_ham)\n",
@@ -381,9 +338,7 @@
381338
{
382339
"cell_type": "code",
383340
"execution_count": null,
384-
"metadata": {
385-
"id": "866925b171a5"
386-
},
341+
"metadata": {},
387342
"outputs": [],
388343
"source": [
389344
"print(\"From Cirq Evolution\")\n",
@@ -395,19 +350,15 @@
395350
},
396351
{
397352
"cell_type": "markdown",
398-
"metadata": {
399-
"id": "7108f16f2401"
400-
},
353+
"metadata": {},
401354
"source": [
402355
"Finally, we can compare against evolving each term of $V$ individually."
403356
]
404357
},
405358
{
406359
"cell_type": "code",
407360
"execution_count": null,
408-
"metadata": {
409-
"id": "8a5588d11373"
410-
},
361+
"metadata": {},
411362
"outputs": [],
412363
"source": [
413364
"fqe_wfn = fqe.Wavefunction([[n_elec, sz, norbs]])\n",
@@ -421,18 +372,34 @@
421372
" fqe_wfn.get_coeff((n_elec, sz)))\n",
422373
"print(\"Individual term evolution is equivalent\")"
423374
]
375+
},
376+
{
377+
"cell_type": "code",
378+
"execution_count": null,
379+
"metadata": {},
380+
"outputs": [],
381+
"source": []
424382
}
425383
],
426384
"metadata": {
427-
"colab": {
428-
"name": "diagonal_coulomb_evolution.ipynb",
429-
"toc_visible": true
430-
},
431385
"kernelspec": {
432386
"display_name": "Python 3",
387+
"language": "python",
433388
"name": "python3"
389+
},
390+
"language_info": {
391+
"codemirror_mode": {
392+
"name": "ipython",
393+
"version": 3
394+
},
395+
"file_extension": ".py",
396+
"mimetype": "text/x-python",
397+
"name": "python",
398+
"nbconvert_exporter": "python",
399+
"pygments_lexer": "ipython3",
400+
"version": "3.6.8"
434401
}
435402
},
436403
"nbformat": 4,
437-
"nbformat_minor": 0
404+
"nbformat_minor": 4
438405
}

0 commit comments

Comments
 (0)