Skip to content

Commit d32b01f

Browse files
ifilotjoerivan
andauthored
Patch v1.2.0 (#62)
* Explicitly copying positions when building Cython CGF objects from Python variant * Adding example for symmetry adapted bases * Implementing MOPA and fixing Blender implementation for latest LTS version * Small tweaks * Adding nuclei to FB dic * Adding meson * Updating meson * Updating meson.build * Updating meson.build * Updating meson.build * Fixing source files * Fixing source files * Fixing meson.build * Changing build procedure * Removing manifest * Adding M_PI * Another try for M_PI support * Adding settings for Windows compilation * Adding M_PI * Changing extension name * Changing extension name * Another attempt * Renaming once more * Changing init procedure * Changing Windows compiler * Changing instructions * Changing instructions * Changing instructions * Updating version * Changing instructions * Changing instructions * Changing instructions * Changing instructions * Changing instructions * Changing instructions * Changing instructions * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Another attempt * Adding comments * Removing universal2 * Adding contour plotter * Improving Geometry Optimization class and adding molecules * Fix version retrieval for pyqint package * Remove Windows compiler from build workflow Remove CIBW_WINDOWS_COMPILER environment variable. * Adding more molecules and propagating camera scale * Adding camera features for BlenderRender * Adding default camera position and improving TEI evaluation * Tuning settings * Migrating sources * Fixing build system * Changing function name * Adding molecules * Refactoring API to make input more consistent * Population analysis (#61) * Add Mulliken and Löwdin population analysis * remove debug print * Adding unit tests and integrating all population analysis techniques into one class * Updating manual * Fixing unit test --------- Co-authored-by: ifilot <ivo@ivofilot.nl> * Adding contour plot visualization to manuaL * Adding PyMoDia to manual * Adding matrix visualization class * Adding symmetry adaptation to the manual --------- Co-authored-by: Joeri van Limpt <114054404+joerivan@users.noreply.github.com>
1 parent 7802a63 commit d32b01f

File tree

125 files changed

+6006
-2740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+6006
-2740
lines changed

.github/workflows/build_wheels.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ on:
1111
types: [published]
1212

1313
env:
14-
# macOS universal and arm64 wheels build on Intel
15-
CIBW_ARCHS_MACOS: "x86_64 universal2 arm64"
14+
CIBW_ARCHS_MACOS: "x86_64 arm64"
1615
CIBW_ARCHS_WINDOWS: "AMD64"
17-
CIBW_SKIP: "cp36-* cp37-* cp38-*"
16+
CIBW_SKIP: "cp38-*"
1817
CIBW_BUILD_VERBOSITY: 1
1918

2019
jobs:
@@ -97,7 +96,7 @@ jobs:
9796
- uses: actions/checkout@v4
9897

9998
- name: Build wheels
100-
uses: pypa/cibuildwheel@v3.2.1
99+
uses: pypa/cibuildwheel@v3.3.0
101100

102101
- uses: actions/upload-artifact@v4
103102
with:

.github/workflows/paper.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: paper
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- paper
48

59
jobs:
610
paper:

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ dmypy.json
136136

137137
# Cython debug symbols
138138
cython_debug/
139-
*.xyz
139+
!src/pyqint/molecules/*.xyz
140140

141141
# Spynx documentation
142142
docs/build/*
@@ -152,4 +152,7 @@ anaconda-upload/*
152152

153153
# managlyph .abo files
154154
*.abo
155-
.vscode
155+
.vscode
156+
157+
*.jpg
158+
*.png

COMPILATION.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,16 @@ To upload, run
3939

4040
```bash
4141
python -m twine upload wheelhouse/*
42+
```
43+
44+
## Editable install
45+
46+
Make sure `methon-python` is installed:
47+
48+
```
49+
pip install meson-python
50+
```
51+
52+
```bash
53+
pip install -e .
4254
```

MANIFEST.in

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/_static/img/mo_co_canonical.svg

Lines changed: 126 additions & 0 deletions
Loading

docs/_static/img/mo_co_localized.svg

Lines changed: 119 additions & 0 deletions
Loading

docs/basis_functions.rst

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
.. index:: basis-functions
2+
3+
Basis functions
4+
###############
5+
6+
.. contents:: Table of Contents
7+
:depth: 3
8+
9+
Gaussian type orbitals (GTO)
10+
============================
11+
12+
:program:`PyQInt` uses cartesian Gaussian type orbitals as given by
13+
14+
.. math::
15+
16+
\Phi(\alpha,l,m,n,\vec{R}) = N (x - X)^{l} (y - Y)^{m} (z - Z)^{n} \exp \left(- \alpha |\vec{r} - \vec{R}|^{2} \right)
17+
18+
wherein :math:`\alpha` is the exponent, :math:`\vec{R} = \left(X,Y,Z\right)` the
19+
position of the orbital, :math:`(l,m,n)` the orders of the pre-exponential
20+
polynomial, and :math:`N` a normalization constant such that
21+
22+
.. math::
23+
24+
\left< \Phi | \Phi \right> = 1
25+
26+
GTOs are a fundamental building block of CGF (see below) and typically a user
27+
would not directly work with them (a notable exception is provided below).
28+
Nevertheless, GTO objects can be constructed as follows::
29+
30+
from pyqint import PyQInt, CGF, GTO
31+
32+
coeff = 1.0 # coefficients only have meaning for GTOs within a CGF
33+
alpha = 0.5
34+
l,m,n = 0,0,0
35+
p = (0,0,0)
36+
G = GTO(coeff, p, alpha, l, m, n)
37+
38+
.. note::
39+
* The normalization constant is automatically calculated by `PyQInt` based
40+
on the value of :math:`\alpha` and :math:`(l,m,n)` and does not have
41+
to be supplied by the user.
42+
* If you work with individual GTOs, the first parameter to construct the GTO
43+
should have a value of 1.0. This first parameter corresponds to the linear
44+
expansion coefficient used in the formulation of Contracted Gaussian Functions
45+
(see below).
46+
47+
Contracted Gaussian Functions (CGF)
48+
===================================
49+
50+
Several GTOs can be combined to produce a so-called Contracted Gaussian Functional which
51+
is esentially a linear combination of GTOs as given by
52+
53+
.. math::
54+
55+
\phi = \sum_{i} c_{i} \Phi_{i}(\alpha,l,m,n,\vec{R})
56+
57+
To build a CGF, we first have to produce the CGF object and then
58+
add GTOs to it::
59+
60+
from pyqint import PyQInt, CGF
61+
62+
cgf = CGF([0.0, 0.0, 0.0])
63+
64+
cgf.add_gto(0.154329, 3.425251, 0, 0, 0)
65+
cgf.add_gto(0.535328, 0.623914, 0, 0, 0)
66+
cgf.add_gto(0.444635, 0.168855, 0, 0, 0)
67+
68+
.. note::
69+
The first argument of the :code:`add_gto` function is the linear expansion coefficient
70+
:math:`c_{i}` and the second argument is :math:`\alpha`.
71+
72+
Position Handling and Advanced Usage
73+
************************************
74+
75+
A :code:`CGF` object carries an explicit spatial position :math:`\vec{R}`,
76+
which is specified when the object is constructed. This position is used as
77+
the *default center* for all Gaussian Type Orbitals (GTOs) added to the CGF via
78+
the standard :code:`add_gto` method.
79+
80+
When using
81+
82+
.. code-block:: python
83+
84+
cgf.add_gto(c, alpha, l, m, n)
85+
86+
the position of the CGF itself is implicitly copied to the newly created GTO.
87+
This is the typical and intended usage pattern for atom-centered basis sets,
88+
where all primitive Gaussians contributing to a contracted function are located
89+
on the same atomic center. Under this assumption, the CGF represents a single
90+
atomic basis function composed of multiple primitives sharing a common center.
91+
92+
Non-Atom-Centered GTOs and Mixed-Center CGFs
93+
********************************************
94+
95+
In more advanced scenarios, it may be desirable to construct contracted
96+
functions composed of GTOs located at *different spatial positions*. This can
97+
arise, for example, when building symmetry-adapted basis functions or other
98+
non-standard orbital constructions.
99+
100+
For such cases, the :code:`CGF` class provides the method
101+
:code:`add_gto_with_position`, which allows explicit specification of the GTO
102+
center:
103+
104+
.. code-block:: python
105+
106+
cgf.add_gto_with_position(c, p, alpha, l, m, n)
107+
108+
where :code:`p` is a three-component array specifying the Cartesian coordinates
109+
of the GTO center.
110+
111+
When this method is used, the position stored in the CGF object itself is
112+
*ignored* for that particular GTO, and the explicitly provided position is
113+
stored with the primitive instead.
114+
115+
Integral Evaluation and Position Resolution
116+
*******************************************
117+
118+
It is important to emphasize that **all integral evaluations are performed using
119+
the positions of the individual GTOs**, not the position stored in the CGF
120+
object. The CGF position serves only as a convenient default when adding
121+
atom-centered primitives via :code:`add_gto`. Consequently, CGFs containing GTOs
122+
at mixed centers are handled correctly by the integral engine, provided that
123+
:code:`add_gto_with_position` is used where appropriate.
124+
125+
Users are therefore encouraged to:
126+
127+
- Use :code:`add_gto` for standard atom-centered basis functions
128+
- Use :code:`add_gto_with_position` when constructing non-standard or
129+
symmetry-adapted contracted functions
130+
- Rely on GTO positions - **not CGF positions** — when reasoning about integral
131+
evaluation

docs/basis_sets_and_molecules.rst

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
.. index:: basis-sets-and-molecules
2+
3+
Basis sets and molecules
4+
========================
5+
6+
.. contents:: Table of Contents
7+
:depth: 3
8+
9+
Building molecules
10+
------------------
11+
12+
Molecules can be efficiently built from the :code:`Molecule` class. For example,
13+
to build the H\ :sub:`2` molecule, one can run the script below.
14+
15+
.. code-block:: python
16+
17+
from pyqint import PyQInt, Molecule
18+
import numpy as np
19+
20+
# construct integrator object
21+
integrator = PyQInt()
22+
23+
# build hydrogen molecule
24+
mol = Molecule('H2')
25+
mol.add_atom('H', 0.0, 0.0, 0.0)
26+
mol.add_atom('H', 0.0, 0.0, 1.4)
27+
print(mol)
28+
29+
The output of the above script is::
30+
31+
Molecule: H2
32+
H (0.000000,0.000000,0.000000)
33+
H (0.000000,0.000000,1.400000)
34+
35+
36+
Using the MoleculeBuilder class
37+
-------------------------------
38+
39+
Next to constructing molecules from scratch, one can also use the
40+
:code:`MoleculeBuilder` class which contains a number of pre-generated molecules.
41+
42+
To see which molecules are available in the MoleculeBuilder class, run
43+
44+
.. code-block:: python
45+
46+
from pyqint import MoleculeBuilder
47+
mol = MoleculeBuilder.print_list_molecules()
48+
49+
To load any of these molecules, one uses the :code:`from_name` function
50+
as shown in the script below
51+
52+
.. code-block:: python
53+
54+
from pyqint import MoleculeBuilder
55+
mol = MoleculeBuilder.from_name('ch4')
56+
print(mol)
57+
58+
The output of the above script shows the elements and the atom positions::
59+
60+
Molecule: methane
61+
C 0.000000 0.000000 0.000000
62+
H 1.195756 1.195756 1.195756
63+
H -1.195756 -1.195756 1.195756
64+
H -1.195756 1.195756 -1.195756
65+
H 1.195756 -1.195756 -1.195756
66+
67+
.. note::
68+
Naming a molecule is completely optional and has no further implications
69+
on any of the calculations. To name a molecule, populate the :code:`name`
70+
member of the :code:`Molecule` class.
71+
72+
Alternatively, one can load molecules from a :code:`.xyz` file via the
73+
:code:`from_file` routine.
74+
75+
.. code-block:: python
76+
77+
mol = MoleculeBuilder.from_file('ch4.xyz')
78+
79+
.. warning::
80+
It is assumed that the positions inside the `.xyz` file are stored in
81+
**angstroms**. Internally, :program:`PyQInt` uses Bohr distances and the
82+
distances as reported in the :code:`.xyz` file are automatically converted.
83+
84+
Constructing basis functions for a molecule
85+
-------------------------------------------
86+
87+
To construct the basis functions for a given molecule, one first needs to
88+
construct the molecule after which the :code:`build_basis` function can be used
89+
to construct a basis.
90+
91+
The following basis sets are supported. For each basis set, the range of atoms
92+
that are supported are given:
93+
94+
* :code:`sto3g` (H-I)
95+
* :code:`sto6g` (H-Kr)
96+
* :code:`p321` (H-Cs)
97+
* :code:`p631` (H-Zn)
98+
99+
The example code below builds the basis functions for the H\ :sub:`2` molecule:
100+
101+
.. code-block:: python
102+
103+
from pyqint import PyQInt, Molecule
104+
import numpy as np
105+
106+
# construct integrator object
107+
integrator = PyQInt()
108+
109+
# build hydrogen molecule
110+
mol = Molecule('H2')
111+
mol.add_atom('H', 0.0, 0.0, 0.0)
112+
mol.add_atom('H', 0.0, 0.0, 1.4)
113+
cgfs, nuclei = mol.build_basis('sto3g')
114+
115+
for cgf in cgfs:
116+
print(cgfs)
117+
118+
for nucleus in nuclei:
119+
print(nucleus)
120+
121+
The output of the above script is::
122+
123+
[CGF; R=(0.000000,0.000000,0.000000)
124+
01 | GTO : c=0.154329, alpha=3.425251, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
125+
02 | GTO : c=0.535328, alpha=0.623914, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
126+
03 | GTO : c=0.444635, alpha=0.168855, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
127+
, CGF; R=(0.000000,0.000000,1.400000)
128+
01 | GTO : c=0.154329, alpha=3.425251, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
129+
02 | GTO : c=0.535328, alpha=0.623914, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
130+
03 | GTO : c=0.444635, alpha=0.168855, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
131+
]
132+
[CGF; R=(0.000000,0.000000,0.000000)
133+
01 | GTO : c=0.154329, alpha=3.425251, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
134+
02 | GTO : c=0.535328, alpha=0.623914, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
135+
03 | GTO : c=0.444635, alpha=0.168855, l=0, m=0, n=0, R=(0.000000,0.000000,0.000000)
136+
, CGF; R=(0.000000,0.000000,1.400000)
137+
01 | GTO : c=0.154329, alpha=3.425251, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
138+
02 | GTO : c=0.535328, alpha=0.623914, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
139+
03 | GTO : c=0.444635, alpha=0.168855, l=0, m=0, n=0, R=(0.000000,0.000000,1.400000)
140+
]
141+
(array([0., 0., 0.]), 1)
142+
(array([0. , 0. , 1.4]), 1)
143+
144+
Parallel evaluation of integrals
145+
--------------------------------
146+
147+
From a collection of Contracted Gaussian Functions, the complete set of overlap,
148+
kinetic, nuclear attraction and two-electron integrals can be quickly evaluated
149+
using the `build_integrals_openmp` function. The function will automatically determine
150+
the number of available cores to allocate for this process.
151+
152+
.. code-block:: python
153+
154+
from pyqint import PyQInt, Molecule
155+
import numpy as np
156+
157+
# construct integrator object
158+
integrator = PyQInt()
159+
160+
# build hydrogen molecule
161+
mol = Molecule()
162+
mol.add_atom('H', 0.0, 0.0, 0.0)
163+
mol.add_atom('H', 0.0, 0.0, 1.4)
164+
cgfs, nuclei = mol.build_basis('sto3g')
165+
166+
# evaluate all integrals
167+
S, T, V, teint = integrator.build_integrals_openmp(cgfs, nuclei)
168+
169+
print(S)
170+
print(T)
171+
print(V)
172+
print(teint)
173+
174+
The output of the above script is given by::
175+
176+
[[1.00000011 0.6593185 ]
177+
[0.6593185 1.00000011]]
178+
[[0.76003161 0.23645446]
179+
[0.23645446 0.76003161]]
180+
[[-1.88044067 -1.19483464]
181+
[-1.19483464 -1.88044067]]
182+
[0.7746057639733748, 0.4441076656879813, 0.29702859983423036, 0.5696758530951017, 0.44410766568798105, 0.7746057639733748]

docs/community_guidelines.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.. _community_guidelines:
21
.. index:: Community Guidelines
32

43
Community guidelines

0 commit comments

Comments
 (0)