| 1 |
Collocation Example |
| 2 |
=================== |
| 3 |
|
| 4 |
Single Collocation |
| 5 |
------------------ |
| 6 |
|
| 7 |
A collocation grid between a single basis and a Cartesian grid can be computed |
| 8 |
with the :func:`~gau2grid.collocation` function. For example, we will use a grid |
| 9 |
starting at the origin along the ``z`` axis: |
| 10 |
|
| 11 |
.. code-block:: python |
| 12 |
|
| 13 |
>>> import gau2grid |
| 14 |
>>> import numpy as np |
| 15 |
>>> xyz = np.zeros((3, 5)) |
| 16 |
>>> xyz[2] = np.arange(5) |
| 17 |
|
| 18 |
We can then create a gaussian with only a single coefficient and exponent of 1 |
| 19 |
centered on the origin: |
| 20 |
|
| 21 |
.. code-block:: python |
| 22 |
|
| 23 |
>>> L = 0 |
| 24 |
>>> coef = [1] |
| 25 |
>>> exp = [1] |
| 26 |
>>> center = [0, 0, 0] |
| 27 |
|
| 28 |
The collocation grid can then be computed as: |
| 29 |
|
| 30 |
.. code-block:: python |
| 31 |
|
| 32 |
>>> ret = gau2grid.collocation(xyz, L, coef, exp, center) |
| 33 |
>>> ret["PHI"] |
| 34 |
[[ 1.00000e+00 3.67879e-01 1.83156e-02 1.23409e-04 1.12535e-07]] |
| 35 |
|
| 36 |
The ``p`` gaussian can be also be computed. Note that since our grid points are |
| 37 |
along the ``z`` axis, the ``x`` and ``y`` components are orthogonal and thus |
| 38 |
zero. |
| 39 |
|
| 40 |
.. code-block:: python |
| 41 |
|
| 42 |
>>> L = 1 |
| 43 |
>>> ret = gau2grid.collocation(xyz, L, coef, exp, center, spherical=False, grad=1) |
| 44 |
>>> ret["PHI"] |
| 45 |
[[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] # P_x |
| 46 |
[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] # P_y |
| 47 |
[ 0.00000e+00 3.67879e-01 3.66312e-02 3.70229e-04 4.50140e-07]] # P_z |
| 48 |
|
| 49 |
As the previous execution used ``grad=1``, the ``X``, ``Y``, and ``Z`` |
| 50 |
cartesian gradients are also available and can be accessed as: |
| 51 |
|
| 52 |
.. code-block:: python |
| 53 |
|
| 54 |
>>> ret["PHI_Z"] |
| 55 |
[[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] |
| 56 |
[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] |
| 57 |
[ 1.00000e+00 -3.67879e-01 -1.28209e-01 -2.09797e-03 -3.48859e-06]] |
| 58 |
|
| 59 |
Basis Collocation |
| 60 |
----------------- |
| 61 |
|
| 62 |
Often it is beneficial to compute the collocation matrix between several basis |
| 63 |
functions and a set of grid points at once the |
| 64 |
:func:`~gau2grid.collocation_basis` helper function provides this |
| 65 |
functionality. To begin, a set of basis sets can be constructed with the |
| 66 |
following form: |
| 67 |
|
| 68 |
.. code-block:: python |
| 69 |
|
| 70 |
>>> basis = [{ |
| 71 |
'center': [0., 0., 0.], |
| 72 |
'exp': [38, 6, 1], |
| 73 |
'coef': [0.4, 0.6, 0.7], |
| 74 |
'am': 0 |
| 75 |
}, { |
| 76 |
'center': [0., 0., 0.], |
| 77 |
'exp': [0.3], |
| 78 |
'coef': [0.3], |
| 79 |
'am': 1 |
| 80 |
}] |
| 81 |
|
| 82 |
Execution of this basis results in a collocation matrix where basis results are |
| 83 |
vertically stacked on top of each other: |
| 84 |
|
| 85 |
.. code-block:: python |
| 86 |
|
| 87 |
>>> ret = gau2grid.collocation_basis(xyz, basis, spherical=False) |
| 88 |
>>> ret["PHI"] |
| 89 |
[[ 1.70000e+00 2.59003e-01 1.28209e-02 8.63869e-05 7.87746e-08] # S |
| 90 |
[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] # P_x |
| 91 |
[ 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00 0.00000e+00] # P_y |
| 92 |
[ 0.00000e+00 2.22245e-01 1.80717e-01 6.04850e-02 9.87570e-03]] # P_z |