Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torchani
Commits
be848453
Commit
be848453
authored
Nov 23, 2019
by
Gao, Xiang
Committed by
Farhad Ramezanghorbani
Nov 23, 2019
Browse files
Improvements on docs (#402)
* Improvements on docs * Add tips
parent
124f239e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
7 deletions
+31
-7
docs/api.rst
docs/api.rst
+2
-0
docs/conf.py
docs/conf.py
+0
-1
docs/index.rst
docs/index.rst
+1
-1
docs/tips.rst
docs/tips.rst
+9
-0
examples/energy_force.py
examples/energy_force.py
+3
-2
torchani/aev.py
torchani/aev.py
+8
-2
torchani/nn.py
torchani/nn.py
+8
-1
No files found.
docs/api.rst
View file @
be848453
...
@@ -5,6 +5,8 @@ TorchANI
...
@@ -5,6 +5,8 @@ TorchANI
:members:
:members:
.. autoclass:: torchani.ANIModel
.. autoclass:: torchani.ANIModel
.. autoclass:: torchani.Ensemble
.. autoclass:: torchani.Ensemble
.. autoclass:: torchani.SpeciesConverter
:members:
.. autoclass:: torchani.EnergyShifter
.. autoclass:: torchani.EnergyShifter
:members:
:members:
.. autoclass:: torchani.nn.Gaussian
.. autoclass:: torchani.nn.Gaussian
...
...
docs/conf.py
View file @
be848453
...
@@ -18,7 +18,6 @@ extensions = [
...
@@ -18,7 +18,6 @@ extensions = [
]
]
templates_path
=
[
'_templates'
]
templates_path
=
[
'_templates'
]
html_static_path
=
[
'_static'
]
source_suffix
=
'.rst'
source_suffix
=
'.rst'
master_doc
=
'index'
master_doc
=
'index'
...
...
docs/index.rst
View file @
be848453
...
@@ -9,6 +9,7 @@ Welcome to TorchANI's documentation!
...
@@ -9,6 +9,7 @@ Welcome to TorchANI's documentation!
:caption: Getting Started
:caption: Getting Started
start
start
tips
.. toctree::
.. toctree::
:maxdepth: 2
:maxdepth: 2
...
@@ -21,7 +22,6 @@ Welcome to TorchANI's documentation!
...
@@ -21,7 +22,6 @@ Welcome to TorchANI's documentation!
examples/load_from_neurochem
examples/load_from_neurochem
examples/nnp_training
examples/nnp_training
examples/nnp_training_force
examples/nnp_training_force
examples/nnp_training_ignite
examples/neurochem_trainer
examples/neurochem_trainer
.. toctree::
.. toctree::
...
...
docs/tips.rst
0 → 100644
View file @
be848453
Tips
====
- Coordinates are in Angstrom, energies are in Hartree
- Therefore, forces are in Hartree/Angstrom
- Species are indexed by 0, 1, 2, 3, ....
- You could use :class:`torchani.SpeciesConverter` to convert from periodic table element index to 0, 1, 2, 3, ...
- Builtin models has an argument ``periodic_table_index`` in its constructor. You can set this to ``True`` when
constructing models to switch to periodic table indexing.
\ No newline at end of file
examples/energy_force.py
View file @
be848453
...
@@ -24,7 +24,8 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
...
@@ -24,7 +24,8 @@ device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
# issue in your application.
# issue in your application.
#
#
# The ``periodic_table_index`` arguments tells TorchANI to use element index
# The ``periodic_table_index`` arguments tells TorchANI to use element index
# in periodic table to index species.
# in periodic table to index species. If not specified, you need to use
# 0, 1, 2, 3, ... to index species
model
=
torchani
.
models
.
ANI1ccx
(
periodic_table_index
=
True
).
to
(
device
)
model
=
torchani
.
models
.
ANI1ccx
(
periodic_table_index
=
True
).
to
(
device
)
###############################################################################
###############################################################################
...
@@ -36,7 +37,7 @@ model = torchani.models.ANI1ccx(periodic_table_index=True).to(device)
...
@@ -36,7 +37,7 @@ model = torchani.models.ANI1ccx(periodic_table_index=True).to(device)
# training. If you have ``N`` different structures to compute, then make it
# training. If you have ``N`` different structures to compute, then make it
# ``N``.
# ``N``.
#
#
# The coordinates are in Angstrom, and the energies you get are in Hartree
#
.. note::
The coordinates are in Angstrom, and the energies you get are in Hartree
coordinates
=
torch
.
tensor
([[[
0.03192167
,
0.00638559
,
0.01301679
],
coordinates
=
torch
.
tensor
([[[
0.03192167
,
0.00638559
,
0.01301679
],
[
-
0.83140486
,
0.39370209
,
-
0.26395324
],
[
-
0.83140486
,
0.39370209
,
-
0.26395324
],
[
-
0.66518241
,
-
0.84461308
,
0.20759389
],
[
-
0.66518241
,
-
0.84461308
,
0.20759389
],
...
...
torchani/aev.py
View file @
be848453
...
@@ -374,6 +374,14 @@ class AEVComputer(torch.nn.Module):
...
@@ -374,6 +374,14 @@ class AEVComputer(torch.nn.Module):
``(C, A, 3)`` where ``C`` is the number of molecules in a chunk,
``(C, A, 3)`` where ``C`` is the number of molecules in a chunk,
and ``A`` is the number of atoms.
and ``A`` is the number of atoms.
.. warning::
The species must be indexed in 0, 1, 2, 3, ..., not the element
index in periodic table. Check :class:`torchani.SpeciesConverter`
if you want periodic table indexing.
.. note:: The coordinates, and cell are in Angstrom.
If you want to apply periodic boundary conditions, then the input
If you want to apply periodic boundary conditions, then the input
would be a tuple of two tensors (species, coordinates) and two keyword
would be a tuple of two tensors (species, coordinates) and two keyword
arguments `cell=...` , and `pbc=...` where species and coordinates are
arguments `cell=...` , and `pbc=...` where species and coordinates are
...
@@ -389,8 +397,6 @@ class AEVComputer(torch.nn.Module):
...
@@ -389,8 +397,6 @@ class AEVComputer(torch.nn.Module):
and pbc is boolean vector of size 3 storing if pbc is enabled
and pbc is boolean vector of size 3 storing if pbc is enabled
for that direction.
for that direction.
The coordinates, and cell are in Angstrom.
Returns:
Returns:
NamedTuple: Species and AEVs. species are the species from the input
NamedTuple: Species and AEVs. species are the species from the input
unchanged, and AEVs is a tensor of shape ``(C, A, self.aev_length())``
unchanged, and AEVs is a tensor of shape ``(C, A, self.aev_length())``
...
...
torchani/nn.py
View file @
be848453
...
@@ -22,7 +22,13 @@ class ANIModel(torch.nn.ModuleDict):
...
@@ -22,7 +22,13 @@ class ANIModel(torch.nn.ModuleDict):
be applied to its AEV, after that, outputs of modules will be reduced along
be applied to its AEV, after that, outputs of modules will be reduced along
different atoms to obtain molecular energies.
different atoms to obtain molecular energies.
The resulting energies are in Hartree.
.. warning::
The species must be indexed in 0, 1, 2, 3, ..., not the element
index in periodic table. Check :class:`torchani.SpeciesConverter`
if you want periodic table indexing.
.. note:: The resulting energies are in Hartree.
Arguments:
Arguments:
modules (:class:`collections.abc.Sequence`): Modules for each atom
modules (:class:`collections.abc.Sequence`): Modules for each atom
...
@@ -124,5 +130,6 @@ class SpeciesConverter(torch.nn.Module):
...
@@ -124,5 +130,6 @@ class SpeciesConverter(torch.nn.Module):
def
forward
(
self
,
input_
:
Tuple
[
Tensor
,
Tensor
],
def
forward
(
self
,
input_
:
Tuple
[
Tensor
,
Tensor
],
cell
:
Optional
[
Tensor
]
=
None
,
cell
:
Optional
[
Tensor
]
=
None
,
pbc
:
Optional
[
Tensor
]
=
None
):
pbc
:
Optional
[
Tensor
]
=
None
):
"""Convert species from periodic table element index to 0, 1, 2, 3, ... indexing"""
species
,
coordinates
=
input_
species
,
coordinates
=
input_
return
SpeciesCoordinates
(
self
.
conv_tensor
[
species
],
coordinates
)
return
SpeciesCoordinates
(
self
.
conv_tensor
[
species
],
coordinates
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment