-
Notifications
You must be signed in to change notification settings - Fork 1
/
qml.html
1456 lines (1301 loc) · 95 KB
/
qml.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!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>Python API documentation — QML 0.4.0 documentation</title>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Examples" href="examples.html" />
<script src="_static/js/modernizr.min.js"></script>
</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"> QML
</a>
<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">GETTING STARTED:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installing QML</a></li>
<li class="toctree-l1"><a class="reference internal" href="citation.html">Citing use of QML</a></li>
<li class="toctree-l1"><a class="reference internal" href="tutorial.html">QML Tutorial</a></li>
<li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
</ul>
<p class="caption"><span class="caption-text">SOURCE DOCUMENTATION:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Python API documentation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.representations">qml.representations module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.kernels">qml.kernels module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.distance">qml.distance module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.math">qml.math module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#qml-compound-class">qml.Compound class</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.fchl">qml.fchl module</a></li>
<li class="toctree-l2"><a class="reference internal" href="#module-qml.wrappers">qml.wrappers module</a></li>
</ul>
</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">QML</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>Python API documentation</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/qml.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="python-api-documentation">
<h1>Python API documentation<a class="headerlink" href="#python-api-documentation" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-qml.representations">
<span id="qml-representations-module"></span><h2>qml.representations module<a class="headerlink" href="#module-qml.representations" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="qml.representations.generate_atomic_coulomb_matrix">
<code class="descclassname">qml.representations.</code><code class="descname">generate_atomic_coulomb_matrix</code><span class="sig-paren">(</span><em>nuclear_charges</em>, <em>coordinates</em>, <em>size=23</em>, <em>sorting='distance'</em>, <em>central_cutoff=1000000.0</em>, <em>central_decay=-1</em>, <em>interaction_cutoff=1000000.0</em>, <em>interaction_decay=-1</em>, <em>indices=None</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.generate_atomic_coulomb_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Coulomb Matrix representation of the local environment of a central atom.
For each central atom <span class="math notranslate nohighlight">\(k\)</span>, a matrix <span class="math notranslate nohighlight">\(M\)</span> is constructed with elements</p>
<div class="math notranslate nohighlight">
\[\begin{split}M_{ij}(k) =
\begin{cases}
\tfrac{1}{2} Z_{i}^{2.4} \cdot f_{ik}^2 & \text{if } i = j \\
\frac{Z_{i}Z_{j}}{\| {\bf R}_{i} - {\bf R}_{j}\|} \cdot f_{ik}f_{jk}f_{ij} & \text{if } i \neq j
\end{cases},\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(i\)</span>, <span class="math notranslate nohighlight">\(j\)</span> and <span class="math notranslate nohighlight">\(k\)</span> are atom indices, <span class="math notranslate nohighlight">\(Z\)</span> is nuclear charge and
<span class="math notranslate nohighlight">\(\bf R\)</span> is the coordinate in euclidean space.</p>
<p><span class="math notranslate nohighlight">\(f_{ij}\)</span> is a function that masks long range effects:</p>
<div class="math notranslate nohighlight">
\[\begin{split}f_{ij} =
\begin{cases}
1 & \text{if } \|{\bf R}_{i} - {\bf R}_{j} \| \leq r - \Delta r \\
\tfrac{1}{2} \big(1 + \cos\big(\pi \tfrac{\|{\bf R}_{i} - {\bf R}_{j} \|
- r + \Delta r}{\Delta r} \big)\big)
& \text{if } r - \Delta r < \|{\bf R}_{i} - {\bf R}_{j} \| \leq r - \Delta r \\
0 & \text{if } \|{\bf R}_{i} - {\bf R}_{j} \| > r
\end{cases},\end{split}\]</div>
<p>where the parameters <code class="docutils literal notranslate"><span class="pre">central_cutoff</span></code> and <code class="docutils literal notranslate"><span class="pre">central_decay</span></code> corresponds to the variables
<span class="math notranslate nohighlight">\(r\)</span> and <span class="math notranslate nohighlight">\(\Delta r\)</span> respectively for interactions involving the central atom,
and <code class="docutils literal notranslate"><span class="pre">interaction_cutoff</span></code> and <code class="docutils literal notranslate"><span class="pre">interaction_decay</span></code> corresponds to the variables
<span class="math notranslate nohighlight">\(r\)</span> and <span class="math notranslate nohighlight">\(\Delta r\)</span> respectively for interactions not involving the central atom.</p>
<p>if <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'row-norm'</span></code>, the atom indices are ordered such that</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\sum_j M_{1j}(k)^2 \geq \sum_j M_{2j}(k)^2 \geq ... \geq \sum_j M_{nj}(k)^2\)</span></div></blockquote>
<p>if <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'distance'</span></code>, the atom indices are ordered such that</p>
<div class="math notranslate nohighlight">
\[\|{\bf R}_{1} - {\bf R}_{k}\| \leq \|{\bf R}_{2} - {\bf R}_{k}\|
\leq ... \leq \|{\bf R}_{n} - {\bf R}_{k}\|\]</div>
<p>The upper triangular of M, including the diagonal, is concatenated to a 1D
vector representation.</p>
<p>The representation can be calculated for a subset by either specifying
<code class="docutils literal notranslate"><span class="pre">indices</span> <span class="pre">=</span> <span class="pre">[0,1,...]</span></code>, where <span class="math notranslate nohighlight">\([0,1,...]\)</span> are the requested atom indices,
or by specifying <code class="docutils literal notranslate"><span class="pre">indices</span> <span class="pre">=</span> <span class="pre">'C'</span></code> to only calculate central carbon atoms.</p>
<p>The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>nuclear_charges</strong> (<em>numpy array</em>) – Nuclear charges of the atoms in the molecule</li>
<li><strong>coordinates</strong> (<em>numpy array</em>) – 3D Coordinates of the atoms in the molecule</li>
<li><strong>size</strong> (<em>integer</em>) – The size of the largest molecule supported by the representation</li>
<li><strong>sorting</strong> (<em>string</em>) – How the atom indices are sorted (‘row-norm’, ‘distance’)</li>
<li><strong>central_cutoff</strong> (<em>float</em>) – The distance from the central atom, where the coulomb interaction
element will be zero</li>
<li><strong>central_decay</strong> (<em>float</em>) – The distance over which the the coulomb interaction decays from full to none</li>
<li><strong>interaction_cutoff</strong> (<em>float</em>) – The distance between two non-central atom, where the coulomb interaction
element will be zero</li>
<li><strong>interaction_decay</strong> (<em>float</em>) – The distance over which the the coulomb interaction decays from full to none</li>
<li><strong>indices</strong> (<em>Nonetype/array/string</em>) – Subset indices or atomtype</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">nD representation - shape (<span class="math notranslate nohighlight">\(N_{atoms}\)</span>, size(size+1)/2)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.generate_bob">
<code class="descclassname">qml.representations.</code><code class="descname">generate_bob</code><span class="sig-paren">(</span><em>nuclear_charges</em>, <em>coordinates</em>, <em>atomtypes</em>, <em>size=23</em>, <em>asize={'C': 7</em>, <em>'H': 16</em>, <em>'N': 3</em>, <em>'O': 3</em>, <em>'S': 1}</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.generate_bob" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Bag of Bonds (BOB) representation of a molecule.
The representation expands on the coulomb matrix representation.
For each element a bag (vector) is constructed for self interactions
(e.g. (‘C’, ‘H’, ‘O’)).
For each element pair a bag is constructed for interatomic interactions
(e.g. (‘CC’, ‘CH’, ‘CO’, ‘HH’, ‘HO’, ‘OO’)), sorted by value.
The self interaction of element <span class="math notranslate nohighlight">\(I\)</span> is given by</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\tfrac{1}{2} Z_{I}^{2.4}\)</span>,</div></blockquote>
<p>with <span class="math notranslate nohighlight">\(Z_{i}\)</span> being the nuclear charge of element <span class="math notranslate nohighlight">\(i\)</span>
The interaction between atom <span class="math notranslate nohighlight">\(i\)</span> of element <span class="math notranslate nohighlight">\(I\)</span> and
atom <span class="math notranslate nohighlight">\(j\)</span> of element <span class="math notranslate nohighlight">\(J\)</span> is given by</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\frac{Z_{I}Z_{J}}{\| {\bf R}_{i} - {\bf R}_{j}\|}\)</span></div></blockquote>
<p>with <span class="math notranslate nohighlight">\(R_{i}\)</span> being the euclidean coordinate of atom <span class="math notranslate nohighlight">\(i\)</span>.
The sorted bags are concatenated to an 1D vector representation.
The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>nuclear_charges</strong> (<em>numpy array</em>) – Nuclear charges of the atoms in the molecule</li>
<li><strong>coordinates</strong> (<em>numpy array</em>) – 3D Coordinates of the atoms in the molecule</li>
<li><strong>size</strong> (<em>integer</em>) – The maximum number of atoms in the representation</li>
<li><strong>asize</strong> (<em>dictionary</em>) – The maximum number of atoms of each element type supported by the representation</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">1D representation</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.generate_coulomb_matrix">
<code class="descclassname">qml.representations.</code><code class="descname">generate_coulomb_matrix</code><span class="sig-paren">(</span><em>nuclear_charges</em>, <em>coordinates</em>, <em>size=23</em>, <em>sorting='row-norm'</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.generate_coulomb_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Coulomb Matrix representation of a molecule.
Sorting of the elements can either be done by <code class="docutils literal notranslate"><span class="pre">sorting="row-norm"</span></code> or <code class="docutils literal notranslate"><span class="pre">sorting="unsorted"</span></code>.
A matrix <span class="math notranslate nohighlight">\(M\)</span> is constructed with elements</p>
<div class="math notranslate nohighlight">
\[\begin{split}M_{ij} =
\begin{cases}
\tfrac{1}{2} Z_{i}^{2.4} & \text{if } i = j \\
\frac{Z_{i}Z_{j}}{\| {\bf R}_{i} - {\bf R}_{j}\|} & \text{if } i \neq j
\end{cases},\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(i\)</span> and <span class="math notranslate nohighlight">\(j\)</span> are atom indices, <span class="math notranslate nohighlight">\(Z\)</span> is nuclear charge and
<span class="math notranslate nohighlight">\(\bf R\)</span> is the coordinate in euclidean space.
If <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'row-norm'</span></code>, the atom indices are reordered such that</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\sum_j M_{1j}^2 \geq \sum_j M_{2j}^2 \geq ... \geq \sum_j M_{nj}^2\)</span></div></blockquote>
<p>The upper triangular of M, including the diagonal, is concatenated to a 1D
vector representation.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'unsorted</span></code>, the elements are sorted in the same order as the input coordinates
and nuclear charges.</p>
<p>The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>nuclear_charges</strong> (<em>numpy array</em>) – Nuclear charges of the atoms in the molecule</li>
<li><strong>coordinates</strong> (<em>numpy array</em>) – 3D Coordinates of the atoms in the molecule</li>
<li><strong>size</strong> (<em>integer</em>) – The size of the largest molecule supported by the representation</li>
<li><strong>sorting</strong> (<em>string</em>) – How the atom indices are sorted (‘row-norm’, ‘unsorted’)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">1D representation - shape (size(size+1)/2,)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.generate_eigenvalue_coulomb_matrix">
<code class="descclassname">qml.representations.</code><code class="descname">generate_eigenvalue_coulomb_matrix</code><span class="sig-paren">(</span><em>nuclear_charges</em>, <em>coordinates</em>, <em>size=23</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.generate_eigenvalue_coulomb_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates an eigenvalue Coulomb Matrix representation of a molecule.
A matrix <span class="math notranslate nohighlight">\(M\)</span> is constructed with elements</p>
<div class="math notranslate nohighlight">
\[\begin{split}M_{ij} =
\begin{cases}
\tfrac{1}{2} Z_{i}^{2.4} & \text{if } i = j \\
\frac{Z_{i}Z_{j}}{\| {\bf R}_{i} - {\bf R}_{j}\|} & \text{if } i \neq j
\end{cases},\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(i\)</span> and <span class="math notranslate nohighlight">\(j\)</span> are atom indices, <span class="math notranslate nohighlight">\(Z\)</span> is nuclear charge and
<span class="math notranslate nohighlight">\(\bf R\)</span> is the coordinate in euclidean space.
The molecular representation of the molecule is then the sorted eigenvalues of M.
The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>nuclear_charges</strong> (<em>numpy array</em>) – Nuclear charges of the atoms in the molecule</li>
<li><strong>coordinates</strong> (<em>numpy array</em>) – 3D Coordinates of the atoms in the molecule</li>
<li><strong>size</strong> (<em>integer</em>) – The size of the largest molecule supported by the representation</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">1D representation - shape (size, )</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.generate_slatm">
<code class="descclassname">qml.representations.</code><code class="descname">generate_slatm</code><span class="sig-paren">(</span><em>coordinates, nuclear_charges, mbtypes, unit_cell=None, local=False, sigmas=[0.05, 0.05], dgrids=[0.03, 0.03], rcut=4.8, alchemy=False, pbc='000', rpower=6</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.generate_slatm" title="Permalink to this definition">¶</a></dt>
<dd><p>Generate Spectrum of London and Axillrod-Teller-Muto potential (SLATM) representation.
Both global (<code class="docutils literal notranslate"><span class="pre">local=False</span></code>) and local (<code class="docutils literal notranslate"><span class="pre">local=True</span></code>) SLATM are available.</p>
<p>A version that works for periodic boundary conditions will be released soon.</p>
<p>NOTE: You will need to run the <code class="docutils literal notranslate"><span class="pre">get_slatm_mbtypes()</span></code> function to get the <code class="docutils literal notranslate"><span class="pre">mbtypes</span></code> input (or generate it manually).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>coordinates</strong> (<em>numpy array</em>) – Input coordinates</li>
<li><strong>nuclear_charges</strong> (<em>numpy array</em>) – List of nuclear charges.</li>
<li><strong>mbtypes</strong> (<em>list</em>) – Many-body types for the whole dataset, including 1-, 2- and 3-body types. Could be obtained by calling <code class="docutils literal notranslate"><span class="pre">get_slatm_mbtypes()</span></code>.</li>
<li><strong>local</strong> (<em>bool</em>) – Generate a local representation. Defaulted to False (i.e., global representation); otherwise, atomic version.</li>
<li><strong>sigmas</strong> (<em>list</em>) – Controlling the width of Gaussian smearing function for 2- and 3-body parts, defaulted to [0.05,0.05], usually these do not need to be adjusted.</li>
<li><strong>dgrids</strong> (<em>list</em>) – The interval between two sampled internuclear distances and angles, defaulted to [0.03,0.03], no need for change, compromised for speed and accuracy.</li>
<li><strong>rcut</strong> (<em>float</em>) – Cut-off radius, defaulted to 4.8 Angstrom.</li>
<li><strong>alchemy</strong> (<em>bool</em>) – Swith to use the alchemy version of SLATM. (default=False)</li>
<li><strong>pbc</strong> (<em>string</em>) – defaulted to ‘000’, meaning it’s a molecule; the three digits in the string corresponds to x,y,z direction</li>
<li><strong>rpower</strong> (<em>float</em>) – The power of R in 2-body potential, defaulted to London potential (=6).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">1D SLATM representation</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.get_slatm_mbtypes">
<code class="descclassname">qml.representations.</code><code class="descname">get_slatm_mbtypes</code><span class="sig-paren">(</span><em>nuclear_charges</em>, <em>pbc='000'</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.get_slatm_mbtypes" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the list of minimal types of many-body terms in a dataset. This resulting list
is necessary as input in the <code class="docutils literal notranslate"><span class="pre">generate_slatm_representation()</span></code> function.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>nuclear_charges</strong> (<em>list of numpy arrays</em>) – A list of the nuclear charges for each compound in the dataset.</li>
<li><strong>pbc</strong> (<em>string</em>) – periodic boundary condition along x,y,z direction, defaulted to ‘000’, i.e., molecule</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A list containing the types of many-body terms.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">list</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.representations.vector_to_matrix">
<code class="descclassname">qml.representations.</code><code class="descname">vector_to_matrix</code><span class="sig-paren">(</span><em>v</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.representations.vector_to_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts a representation from 1D vector to 2D square matrix.
:param v: 1D input representation.
:type v: numpy array
:return: Square matrix representation.
:rtype: numpy array</p>
</dd></dl>
</div>
<div class="section" id="module-qml.kernels">
<span id="qml-kernels-module"></span><h2>qml.kernels module<a class="headerlink" href="#module-qml.kernels" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="qml.kernels.gaussian_kernel">
<code class="descclassname">qml.kernels.</code><code class="descname">gaussian_kernel</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>sigma</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.gaussian_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Gaussian kernel matrix K, where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = \exp \big( -\frac{\|A_i - B_j\|_2^2}{2\sigma^2} \big)\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of representations - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of representations - shape (M, representation size).</li>
<li><strong>sigma</strong> (<em>float</em>) – The value of sigma in the kernel matrix.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Gaussian kernel matrix - shape (N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.get_local_kernels_gaussian">
<code class="descclassname">qml.kernels.</code><code class="descname">get_local_kernels_gaussian</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>na</em>, <em>nb</em>, <em>sigmas</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.get_local_kernels_gaussian" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Gaussian kernel matrix K, for a local representation where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = \sum_{a \in i} \sum_{b \in j} \exp \big( -\frac{\|A_a - B_b\|_2^2}{2\sigma^2} \big)\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{a}\)</span> and <span class="math notranslate nohighlight">\(B_{b}\)</span> are representation vectors.</p>
<p>Note that the input array is one big 2D array with all atoms concatenated along the same axis.
Further more a series of kernels is produced (since calculating the distance matrix is expensive
but getting the resulting kernels elements for several sigmas is not.)</p>
<p>K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (total atoms A, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (total atoms B, representation size).</li>
<li><strong>na</strong> (<em>numpy array</em>) – 1D array containing numbers of atoms in each compound.</li>
<li><strong>nb</strong> (<em>numpy array</em>) – 1D array containing numbers of atoms in each compound.</li>
<li><strong>sigma</strong> (<em>float</em>) – The value of sigma in the kernel matrix.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Gaussian kernel matrix - shape (nsigmas, N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.get_local_kernels_laplacian">
<code class="descclassname">qml.kernels.</code><code class="descname">get_local_kernels_laplacian</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>na</em>, <em>nb</em>, <em>sigmas</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.get_local_kernels_laplacian" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Local Laplacian kernel matrix K, for a local representation where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = \sum_{a \in i} \sum_{b \in j} \exp \big( -\frac{\|A_a - B_b\|_1}{\sigma} \big)\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{a}\)</span> and <span class="math notranslate nohighlight">\(B_{b}\)</span> are representation vectors.</p>
<p>Note that the input array is one big 2D array with all atoms concatenated along the same axis.
Further more a series of kernels is produced (since calculating the distance matrix is expensive
but getting the resulting kernels elements for several sigmas is not.)</p>
<p>K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (M, representation size).</li>
<li><strong>na</strong> (<em>numpy array</em>) – 1D array containing numbers of atoms in each compound.</li>
<li><strong>nb</strong> (<em>numpy array</em>) – 1D array containing numbers of atoms in each compound.</li>
<li><strong>sigmas</strong> (<em>list</em>) – List of the sigmas.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Laplacian kernel matrix - shape (nsigmas, N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.laplacian_kernel">
<code class="descclassname">qml.kernels.</code><code class="descname">laplacian_kernel</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>sigma</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.laplacian_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Laplacian kernel matrix K, where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = \exp \big( -\frac{\|A_i - B_j\|_1}{\sigma} \big)\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of representations - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of representations - shape (M, representation size).</li>
<li><strong>sigma</strong> (<em>float</em>) – The value of sigma in the kernel matrix.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Laplacian kernel matrix - shape (N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.linear_kernel">
<code class="descclassname">qml.kernels.</code><code class="descname">linear_kernel</code><span class="sig-paren">(</span><em>A</em>, <em>B</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.linear_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the linear kernel matrix K, where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = A_i \cdot B_j\)</span></div></blockquote>
<p>VWhere <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.</p>
<p>K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of representations - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of representations - shape (M, representation size).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Gaussian kernel matrix - shape (N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.matern_kernel">
<code class="descclassname">qml.kernels.</code><code class="descname">matern_kernel</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>sigma</em>, <em>order=0</em>, <em>metric='l1'</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.matern_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Matern kernel matrix K, where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><dl class="docutils">
<dt>for order = 0:</dt>
<dd><span class="math notranslate nohighlight">\(K_{ij} = \exp\big( -\frac{d}{\sigma} \big)\)</span></dd>
<dt>for order = 1:</dt>
<dd><span class="math notranslate nohighlight">\(K_{ij} = \exp\big( -\frac{\sqrt{3} d}{\sigma} \big) \big(1 + \frac{\sqrt{3} d}{\sigma} \big)\)</span></dd>
<dt>for order = 2:</dt>
<dd><span class="math notranslate nohighlight">\(K_{ij} = \exp\big( -\frac{\sqrt{5} d}{d} \big) \big( 1 + \frac{\sqrt{5} d}{\sigma} + \frac{5 d^2}{3\sigma^2} \big)\)</span></dd>
</dl>
</div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_i\)</span> and <span class="math notranslate nohighlight">\(B_j\)</span> are representation vectors, and d is a distance measure.</p>
<p>K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of representations - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of representations - shape (M, representation size).</li>
<li><strong>sigma</strong> (<em>float</em>) – The value of sigma in the kernel matrix.</li>
<li><strong>order</strong> (<em>integer</em>) – The order of the polynomial (0, 1, 2)</li>
<li><strong>metric</strong> (<em>string</em>) – The distance metric (‘l1’, ‘l2’)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Matern kernel matrix - shape (N, M)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.kernels.sargan_kernel">
<code class="descclassname">qml.kernels.</code><code class="descname">sargan_kernel</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>sigma</em>, <em>gammas</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.kernels.sargan_kernel" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Sargan kernel matrix K, where <span class="math notranslate nohighlight">\(K_{ij}\)</span>:</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(K_{ij} = \exp \big( -\frac{\| A_i - B_j \|_1)}{\sigma} \big) \big(1 + \sum_{k} \frac{\gamma_{k} \| A_i - B_j \|_1^k}{\sigma^k} \big)\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
K is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of representations - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of representations - shape (M, representation size).</li>
<li><strong>sigma</strong> (<em>float</em>) – The value of sigma in the kernel matrix.</li>
<li><strong>gammas</strong> (<em>numpy array</em>) – 1D array of parameters in the kernel matrix.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Sargan kernel matrix - shape (N, M).</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-qml.distance">
<span id="qml-distance-module"></span><h2>qml.distance module<a class="headerlink" href="#module-qml.distance" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="qml.distance.l2_distance">
<code class="descclassname">qml.distance.</code><code class="descname">l2_distance</code><span class="sig-paren">(</span><em>A</em>, <em>B</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.distance.l2_distance" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the L2 distances, D, between two
Numpy arrays of representations.</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(D_{ij} = \|A_i - B_j\|_2\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
D is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (M, representation size).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The L2-distance matrix.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.distance.manhattan_distance">
<code class="descclassname">qml.distance.</code><code class="descname">manhattan_distance</code><span class="sig-paren">(</span><em>A</em>, <em>B</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.distance.manhattan_distance" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the Manhattan distances, D, between two
Numpy arrays of representations.</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(D_{ij} = \|A_i - B_j\|_1\)</span></div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
D is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (M, representation size).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The Manhattan-distance matrix.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.distance.p_distance">
<code class="descclassname">qml.distance.</code><code class="descname">p_distance</code><span class="sig-paren">(</span><em>A</em>, <em>B</em>, <em>p=2</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.distance.p_distance" title="Permalink to this definition">¶</a></dt>
<dd><p>Calculates the p-norm distances between two
Numpy arrays of representations.
The value of the keyword argument <code class="docutils literal notranslate"><span class="pre">p</span> <span class="pre">=</span></code> sets the norm order.
E.g. <code class="docutils literal notranslate"><span class="pre">p</span> <span class="pre">=</span> <span class="pre">1.0</span></code> and <code class="docutils literal notranslate"><span class="pre">p</span> <span class="pre">=</span> <span class="pre">2.0</span></code> with yield the Manhattan and L2 distances, respectively.</p>
<blockquote>
<div><div class="math notranslate nohighlight">
\[D_{ij} = \|A_i - B_j\|_p\]</div>
</div></blockquote>
<p>Where <span class="math notranslate nohighlight">\(A_{i}\)</span> and <span class="math notranslate nohighlight">\(B_{j}\)</span> are representation vectors.
D is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (N, representation size).</li>
<li><strong>B</strong> (<em>numpy array</em>) – 2D array of descriptors - shape (M, representation size).</li>
<li><strong>p</strong> (<em>float</em>) – The norm order</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The distance matrix.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="module-qml.math">
<span id="qml-math-module"></span><h2>qml.math module<a class="headerlink" href="#module-qml.math" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="qml.math.bkf_invert">
<code class="descclassname">qml.math.</code><code class="descname">bkf_invert</code><span class="sig-paren">(</span><em>A</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.math.bkf_invert" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the inverse of a positive definite matrix, using a Cholesky decomposition
via calls to LAPACK dpotrf and dpotri in the F2PY module.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>A</strong> (<em>numpy array</em>) – Matrix (symmetric and positive definite, left-hand side).</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The inverse matrix</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">numpy array</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.math.bkf_solve">
<code class="descclassname">qml.math.</code><code class="descname">bkf_solve</code><span class="sig-paren">(</span><em>A</em>, <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.math.bkf_solve" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves the equation</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(A x = y\)</span></div></blockquote>
<p>for x using a Cholesky decomposition via calls to LAPACK dpotrf and dpotrs in the F2PY module. Preserves the input matrix A.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – Matrix (symmetric and positive definite, left-hand side).</li>
<li><strong>y</strong> (<em>numpy array</em>) – Vector (right-hand side of the equation).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The solution vector.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.math.cho_invert">
<code class="descclassname">qml.math.</code><code class="descname">cho_invert</code><span class="sig-paren">(</span><em>A</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.math.cho_invert" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the inverse of a positive definite matrix, using a Cholesky decomposition
via calls to LAPACK dpotrf and dpotri in the F2PY module.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>A</strong> (<em>numpy array</em>) – Matrix (symmetric and positive definite, left-hand side).</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">The inverse matrix</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">numpy array</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="function">
<dt id="qml.math.cho_solve">
<code class="descclassname">qml.math.</code><code class="descname">cho_solve</code><span class="sig-paren">(</span><em>A</em>, <em>y</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.math.cho_solve" title="Permalink to this definition">¶</a></dt>
<dd><p>Solves the equation</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(A x = y\)</span></div></blockquote>
<p>for x using a Cholesky decomposition via calls to LAPACK dpotrf and dpotrs in the F2PY module. Preserves the input matrix A.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>A</strong> (<em>numpy array</em>) – Matrix (symmetric and positive definite, left-hand side).</li>
<li><strong>y</strong> (<em>numpy array</em>) – Vector (right-hand side of the equation).</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The solution vector.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
</div>
<div class="section" id="qml-compound-class">
<h2>qml.Compound class<a class="headerlink" href="#qml-compound-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="qml.Compound">
<em class="property">class </em><code class="descclassname">qml.</code><code class="descname">Compound</code><span class="sig-paren">(</span><em>xyz=None</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.Compound" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>The <code class="docutils literal notranslate"><span class="pre">Compound</span></code> class is used to store data from</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>xyz</strong> (<em>string</em>) – Option to initialize the <code class="docutils literal notranslate"><span class="pre">Compound</span></code> with data from an XYZ file.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="qml.Compound.generate_atomic_coulomb_matrix">
<code class="descname">generate_atomic_coulomb_matrix</code><span class="sig-paren">(</span><em>size=23</em>, <em>sorting='row-norm'</em>, <em>central_cutoff=1000000.0</em>, <em>central_decay=-1</em>, <em>interaction_cutoff=1000000.0</em>, <em>interaction_decay=-1</em>, <em>indices=None</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.Compound.generate_atomic_coulomb_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Coulomb Matrix representation of the local environment of a central atom.
For each central atom <span class="math notranslate nohighlight">\(k\)</span>, a matrix <span class="math notranslate nohighlight">\(M\)</span> is constructed with elements</p>
<div class="math notranslate nohighlight">
\[\begin{split}M_{ij}(k) =
\begin{cases}
\tfrac{1}{2} Z_{i}^{2.4} \cdot f_{ik}^2 & \text{if } i = j \\
\frac{Z_{i}Z_{j}}{\| {\bf R}_{i} - {\bf R}_{j}\|} \cdot f_{ik}f_{jk}f_{ij} & \text{if } i \neq j
\end{cases},\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(i\)</span>, <span class="math notranslate nohighlight">\(j\)</span> and <span class="math notranslate nohighlight">\(k\)</span> are atom indices, <span class="math notranslate nohighlight">\(Z\)</span> is nuclear charge and
<span class="math notranslate nohighlight">\(\bf R\)</span> is the coordinate in euclidean space.</p>
<p><span class="math notranslate nohighlight">\(f_{ij}\)</span> is a function that masks long range effects:</p>
<div class="math notranslate nohighlight">
\[\begin{split}f_{ij} =
\begin{cases}
1 & \text{if } \|{\bf R}_{i} - {\bf R}_{j} \| \leq r - \Delta r \\
\tfrac{1}{2} \big(1 + \cos\big(\pi \tfrac{\|{\bf R}_{i} - {\bf R}_{j} \|
- r + \Delta r}{\Delta r} \big)\big)
& \text{if } r - \Delta r < \|{\bf R}_{i} - {\bf R}_{j} \| \leq r - \Delta r \\
0 & \text{if } \|{\bf R}_{i} - {\bf R}_{j} \| > r
\end{cases},\end{split}\]</div>
<p>where the parameters <code class="docutils literal notranslate"><span class="pre">central_cutoff</span></code> and <code class="docutils literal notranslate"><span class="pre">central_decay</span></code> corresponds to the variables
<span class="math notranslate nohighlight">\(r\)</span> and <span class="math notranslate nohighlight">\(\Delta r\)</span> respectively for interactions involving the central atom,
and <code class="docutils literal notranslate"><span class="pre">interaction_cutoff</span></code> and <code class="docutils literal notranslate"><span class="pre">interaction_decay</span></code> corresponds to the variables
<span class="math notranslate nohighlight">\(r\)</span> and <span class="math notranslate nohighlight">\(\Delta r\)</span> respectively for interactions not involving the central atom.</p>
<p>if <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'row-norm'</span></code>, the atom indices are ordered such that</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\sum_j M_{1j}(k)^2 \geq \sum_j M_{2j}(k)^2 \geq ... \geq \sum_j M_{nj}(k)^2\)</span></div></blockquote>
<p>if <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'distance'</span></code>, the atom indices are ordered such that</p>
<div class="math notranslate nohighlight">
\[\|{\bf R}_{1} - {\bf R}_{k}\| \leq \|{\bf R}_{2} - {\bf R}_{k}\|
\leq ... \leq \|{\bf R}_{n} - {\bf R}_{k}\|\]</div>
<p>The upper triangular of M, including the diagonal, is concatenated to a 1D
vector representation.</p>
<p>The representation can be calculated for a subset by either specifying
<code class="docutils literal notranslate"><span class="pre">indices</span> <span class="pre">=</span> <span class="pre">[0,1,...]</span></code>, where <span class="math notranslate nohighlight">\([0,1,...]\)</span> are the requested atom indices,
or by specifying <code class="docutils literal notranslate"><span class="pre">indices</span> <span class="pre">=</span> <span class="pre">'C'</span></code> to only calculate central carbon atoms.</p>
<p>The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>size</strong> (<em>integer</em>) – The size of the largest molecule supported by the representation</li>
<li><strong>sorting</strong> (<em>string</em>) – How the atom indices are sorted (‘row-norm’, ‘distance’)</li>
<li><strong>central_cutoff</strong> (<em>float</em>) – The distance from the central atom, where the coulomb interaction
element will be zero</li>
<li><strong>central_decay</strong> (<em>float</em>) – The distance over which the the coulomb interaction decays from full to none</li>
<li><strong>interaction_cutoff</strong> (<em>float</em>) – The distance between two non-central atom, where the coulomb interaction
element will be zero</li>
<li><strong>interaction_decay</strong> (<em>float</em>) – The distance over which the the coulomb interaction decays from full to none</li>
<li><strong>indices</strong> (<em>Nonetype/array/string</em>) – Subset indices or atomtype</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">nD representation - shape (<span class="math notranslate nohighlight">\(N_{atoms}\)</span>, size(size+1)/2)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="qml.Compound.generate_bob">
<code class="descname">generate_bob</code><span class="sig-paren">(</span><em>size=23</em>, <em>asize={'C': 7</em>, <em>'H': 16</em>, <em>'N': 3</em>, <em>'O': 3</em>, <em>'S': 1}</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.Compound.generate_bob" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Bag of Bonds (BOB) representation of a molecule.
The representation expands on the coulomb matrix representation.
For each element a bag (vector) is constructed for self interactions
(e.g. (‘C’, ‘H’, ‘O’)).
For each element pair a bag is constructed for interatomic interactions
(e.g. (‘CC’, ‘CH’, ‘CO’, ‘HH’, ‘HO’, ‘OO’)), sorted by value.
The self interaction of element <span class="math notranslate nohighlight">\(I\)</span> is given by</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\tfrac{1}{2} Z_{I}^{2.4}\)</span>,</div></blockquote>
<p>with <span class="math notranslate nohighlight">\(Z_{i}\)</span> being the nuclear charge of element <span class="math notranslate nohighlight">\(i\)</span>
The interaction between atom <span class="math notranslate nohighlight">\(i\)</span> of element <span class="math notranslate nohighlight">\(I\)</span> and
atom <span class="math notranslate nohighlight">\(j\)</span> of element <span class="math notranslate nohighlight">\(J\)</span> is given by</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\frac{Z_{I}Z_{J}}{\| {\bf R}_{i} - {\bf R}_{j}\|}\)</span></div></blockquote>
<p>with <span class="math notranslate nohighlight">\(R_{i}\)</span> being the euclidean coordinate of atom <span class="math notranslate nohighlight">\(i\)</span>.
The sorted bags are concatenated to an 1D vector representation.
The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>asize</strong> – The maximum number of atoms of each element type supported by the representation</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">1D representation</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">numpy array</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="qml.Compound.generate_coulomb_matrix">
<code class="descname">generate_coulomb_matrix</code><span class="sig-paren">(</span><em>size=23</em>, <em>sorting='row-norm'</em>, <em>indices=None</em><span class="sig-paren">)</span><a class="headerlink" href="#qml.Compound.generate_coulomb_matrix" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a Coulomb Matrix representation of a molecule.
A matrix <span class="math notranslate nohighlight">\(M\)</span> is constructed with elements</p>
<div class="math notranslate nohighlight">
\[\begin{split}M_{ij} =
\begin{cases}
\tfrac{1}{2} Z_{i}^{2.4} & \text{if } i = j \\
\frac{Z_{i}Z_{j}}{\| {\bf R}_{i} - {\bf R}_{j}\|} & \text{if } i \neq j
\end{cases},\end{split}\]</div>
<p>where <span class="math notranslate nohighlight">\(i\)</span> and <span class="math notranslate nohighlight">\(j\)</span> are atom indices, <span class="math notranslate nohighlight">\(Z\)</span> is nuclear charge and
<span class="math notranslate nohighlight">\(\bf R\)</span> is the coordinate in euclidean space.
if <code class="docutils literal notranslate"><span class="pre">sorting</span> <span class="pre">=</span> <span class="pre">'row-norm'</span></code>, the atom indices are reordered such that</p>
<blockquote>
<div><span class="math notranslate nohighlight">\(\sum_j M_{1j}^2 \geq \sum_j M_{2j}^2 \geq ... \geq \sum_j M_{nj}^2\)</span></div></blockquote>
<p>The upper triangular of M, including the diagonal, is concatenated to a 1D
vector representation.
The representation is calculated using an OpenMP parallel Fortran routine.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>size</strong> (<em>integer</em>) – The size of the largest molecule supported by the representation</li>
<li><strong>sorting</strong> (<em>string</em>) – How the atom indices are sorted (‘row-norm’, ‘unsorted’)</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">1D representation - shape (size(size+1)/2,)</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy array</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">