Skip to content
This repository was archived by the owner on Dec 8, 2024. It is now read-only.

Fchl doc #45

Merged
merged 13 commits into from
Mar 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ group: edge

deploy:
provider: pages
local_dir: ${TRAVIS_BUILD_DIR}/docs/build/html
# local_dir: ${TRAVIS_BUILD_DIR}/docs/build/html
local_dir: /docs/build/html
skip_cleanup: true
repo: qmlcode/qmlcode.github.io
target_branch: master
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ The neighbors keyword is the max number of atoms with the cutoff-distance
Generating the FCHL kernel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The following example demonstrates how to calculate the local FCHL kernel elements between FCHL representations. ``X1`` and ``X2`` are numpy arrays with the shape ``(number_compounds,max_size, 5,neighbors)``, as generated in one of the previous examples. You MUST use the same cut-off distance to generate the representation and calculate the kernel.
The following example demonstrates how to calculate the local FCHL kernel elements between FCHL representations. ``X1`` and ``X2`` are numpy arrays with the shape ``(number_compounds,max_size, 5,neighbors)``, as generated in one of the previous examples. You MUST use the same, or larger, cut-off distance to generate the representation, as to calculate the kernel.


.. code:: python
Expand Down
8 changes: 4 additions & 4 deletions qml/compound.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, xyz = None):
# Information about the compound
self.natoms = float("nan")
self.natypes = {}
self.atomtypes = empty_array
self.atomtypes = []
self.atomtype_indices = collections.defaultdict(list)
self.nuclear_charges = empty_array
self.coordinates = empty_array
Expand Down Expand Up @@ -305,7 +305,7 @@ def read_xyz(self, filename):
f.close()

self.natoms = int(lines[0])
self.atomtypes = np.empty(self.natoms, dtype=str)
self.atomtypes = []
self.nuclear_charges = np.empty(self.natoms, dtype=int)
self.coordinates = np.empty((self.natoms, 3), dtype=float)

Expand All @@ -317,10 +317,10 @@ def read_xyz(self, filename):
if len(tokens) < 4:
break

self.atomtypes[i] = tokens[0]
self.atomtypes.append(tokens[0])
self.atomtype_indices[tokens[0]].append(i)
self.nuclear_charges[i] = NUCLEAR_CHARGE[tokens[0]]

self.coordinates[i] = np.asarray(tokens[1:4], dtype=float)

self.natypes = dict([(key, len(value)) for key,value in self.atomtype_indices.items()])
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
__copyright__ = "Copyright 2016"
__credits__ = ["Anders S. Christensen et al. (2016) https://github.com/qmlcode/qml"]
__license__ = "MIT"
__version__ = "0.4.0.11"
__version__ = "0.4.0.12"

__maintainer__ = "Anders S. Christensen"
__email__ = "andersbiceps@gmail.com"
__status__ = "Beta"
Expand Down
7 changes: 7 additions & 0 deletions tests/data/compound_test.xyz
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
5

C -6.00533 0.91552 0.12550
Cl -4.22806 0.88165 0.08802
Br -6.62335 0.37844 1.87701
H -6.40470 0.21664 -0.63793
H -6.36029 1.94371 -0.09267
50 changes: 49 additions & 1 deletion tests/test_compound.py
Original file line number Diff line number Diff line change
@@ -1 +1,49 @@
# Test
# MIT License
#
# Copyright (c) 2018 Anders Steen Christensen
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from __future__ import print_function

import os

import qml
import numpy as np

def compare_lists(a, b):
for pair in zip(a,b):
if pair[0] != pair[1]:
return False
return True

def test_compound():

test_dir = os.path.dirname(os.path.realpath(__file__))
c = qml.Compound(xyz=test_dir + "/data/compound_test.xyz")

ref_atomtypes = ['C', 'Cl', 'Br', 'H', 'H']
ref_charges = [ 6, 17, 35, 1 , 1]

assert compare_lists(ref_atomtypes, c.atomtypes), "Failed parsing atomtypes"
assert compare_lists(ref_charges, c.nuclear_charges), "Failed parsing nuclear_charges"

if __name__ == "__main__":

test_compound()