Skip to content
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: 1 addition & 2 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
check_formatting:
uses: NWChemEx/.github/.github/workflows/check_formatting.yaml@master
with:
license_config: ".github/.licenserc.yaml"
license_config: ".licenserc.yaml"
cpp_source_dirs: ""

# test_nwx_docs:
Expand All @@ -36,4 +36,3 @@ jobs:
uses: NWChemEx/.github/.github/workflows/test_nwx_library.yaml@master
with:
compilers: '["gcc-11", "clang-14"]'

1 change: 1 addition & 0 deletions .github/.licenserc.yaml → .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ header:
- LICENSE
- version.txt
- docs/source/nitpick_exceptions
- build/

comment: never
4 changes: 2 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sphinx==v7.2.6
sphinx-autoapi
sphinx_rtd_theme==1.3.0
sphinxcontrib-bibtex
sphinx_tabs
sphinx-autoapi
sphinxcontrib-bibtex
81 changes: 47 additions & 34 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,33 @@
# http://www.sphinx-doc.org/en/master/config

import os
import sys

# -- Project information -----------------------------------------------------

project = u'StructureFinder'
copyright = u'2024, NWChemEx Community'
author = u'NWChemEx Community'
project = "StructureFinder"
copyright = "2024, NWChemEx Community"
author = "NWChemEx Community"

# Get the version from version.txt
version = '1.0.0'
version = "1.0.0"
# The full version, including alpha/beta/rc tags
release = version

# -- General configuration ---------------------------------------------------

# We use numref which is introduced in Sphinx 1.3
needs_sphinx = '1.3'
needs_sphinx = "1.3"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage',
'sphinx.ext.mathjax', 'sphinx.ext.githubpages', 'autoapi.extension'
"sphinx.ext.doctest",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.githubpages",
"autoapi.extension",
]
dir_path = os.path.dirname(os.path.realpath(__file__))
doc_path = os.path.dirname(dir_path)
Expand All @@ -57,25 +60,25 @@
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = 'en'
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
pygments_style = "sphinx"

# Should figures be numbered?
numfig = True
Expand All @@ -85,7 +88,7 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme = "sphinx_rtd_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -111,23 +114,20 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = project + 'doc'
htmlhelp_basename = project + "doc"

# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -137,49 +137,62 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, project + '.tex', project + ' Documentation', author,
'manual'),
(
master_doc,
project + ".tex",
project + " Documentation",
author,
"manual",
),
]

# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [(master_doc, project.lower(), project + ' Documentation',
[author], 1)]
man_pages = [
(master_doc, project.lower(), project + " Documentation", [author], 1)
]

# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, project, project + ' Documentation', author, project,
'One line description of project.', 'Miscellaneous'),
(
master_doc,
project,
project + " Documentation",
author,
project,
"One line description of project.",
"Miscellaneous",
),
]

# -- Extension configuration -------------------------------------------------
autoapi_dirs = [
'../../src',
"../../src",
# '../../tests',
]
autoapi_add_toctree_entry = False
autoapi_options = [
'members',
'undoc-members',
'private-members',
'show-inheritance',
'show-module-summary',
'special-members',
"members",
"undoc-members",
"private-members",
"show-inheritance",
"show-module-summary",
"special-members",
# 'imported-members',
]


# This skips classes that derived from ModuleBase, because those classes will
# have Module API documentation producable by PluginPlay
def skip_pluginplay_modules(app, what, name, obj, skip, options):
bases = obj.obj['bases'] if 'bases' in obj.obj.keys() else []
if 'pluginplay.ModuleBase' in bases:
bases = obj.obj["bases"] if "bases" in obj.obj.keys() else []
if "pluginplay.ModuleBase" in bases:
skip = True
return skip

Expand All @@ -191,7 +204,7 @@ def setup(sphinx):
# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {"https://docs.python.org/": None}

# -- Options for todo extension ----------------------------------------------

Expand All @@ -203,7 +216,7 @@ def setup(sphinx):
# Nitpick requires all references to be resolved
# This will ignore those that references that can't be linked
nitpick_ignore = []
for line in open('nitpick_exceptions'):
for line in open("nitpick_exceptions"):
if line.strip() == "" or line.startswith("#"):
continue
dtype, target = line.split(None, 1)
Expand Down
4 changes: 3 additions & 1 deletion src/python/structurefinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from .lj_potential.lennard_jones_potential_module import (
load_lennard_jones_potential,
)
from .pyberny import load_pyberny_modules
from .lj_potential.lennard_jones_potential_module import load_lennard_jones_potential


def load_modules(mm):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import numpy as np
import pluginplay as pp
from simde import TotalEnergy
import tensorwrapper as tw
from simde import TotalEnergy


class LennardJonesPotential(pp.ModuleBase):
Expand All @@ -31,41 +31,41 @@ def __init__(self):
self.description("Lennard-Jones 1D potential function")
self.satisfies_property_type(TotalEnergy())

#--------------------------------------------------------------------------
# --------------------------------------------------------------------------

# Module run_ member function ---------------------------------------------
def run_(self, inputs, submods):
"""
Parameters
----------
inputs : Diatomic distance,
inputs : Diatomic distance,
TYPE ---> Float

Returns
-------
E: Lennard-Jonnes 1D potential Energy,
TYPE ---> Float
E: Lennard-Jonnes 1D potential Energy,
TYPE ---> Float
"""
pt = TotalEnergy()
chem_sys, = pt.unwrap_inputs(inputs)
(chem_sys,) = pt.unwrap_inputs(inputs)
mol = chem_sys.molecule
coor_0 = np.array([mol.at(0).x, mol.at(0).y, mol.at(0).z])
coor_1 = np.array([mol.at(1).x, mol.at(1).y, mol.at(1).z])
#----------------------------------------------------------------------
assert (mol.size() == 2) #<--- To check molcule size contains 2-atoms
#----------------------------------------------------------------------
# ----------------------------------------------------------------------
assert mol.size() == 2 # <--- To check molcule size contains 2-atoms
# ----------------------------------------------------------------------
r = np.linalg.norm(coor_0 - coor_1)
#-------------- LENNARD-JONES FUNCTION --------------------------------
# -------------- LENNARD-JONES FUNCTION --------------------------------
E = 4 * ((1 / r**12) - (1 / r**6))
#------------- ANALYTIC FORCE -----------------------------------------
DE_x = -24 * ((2 / r**13) - (1 / r**7))
FC = -DE_x
#----------------------------------------------------------------------
# ------------- ANALYTIC FORCE -----------------------------------------
# DE_x = -24 * ((2 / r**13) - (1 / r**7))
# FC = -DE_x
# ----------------------------------------------------------------------
E = tw.Tensor(np.array(E))
rv = self.results()
return pt.wrap_results(rv, E)

#--------------------------------------------------------------------------
# --------------------------------------------------------------------------


def load_lennard_jones_potential(mm):
Expand Down
29 changes: 19 additions & 10 deletions src/python/structurefinder/pyberny/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import chemist
import numpy as np
import pluginplay as pp
from berny import Berny, geomlib
from simde import (
EnergyNuclearGradientStdVectorD,
TotalEnergyNuclearOptimization,
MoleculeFromString,
TotalEnergy,
TotalEnergyNuclearOptimization,
)
from berny import Berny, geomlib
import chemist
import numpy as np


class GeomoptViaPyberny(pp.ModuleBase):

def __init__(self):
pp.ModuleBase.__init__(self)
self.satisfies_property_type(TotalEnergyNuclearOptimization())
Expand All @@ -43,10 +42,18 @@ def run_(self, inputs, submods):
xyz = ""
xyz += str(molecule.size()) + "\n\n"

#TODO ensure points == molecule.nuclei.charges.point_set
# TODO ensure points == molecule.nuclei.charges.point_set
for i in range(points.size()):
xyz += (molecule.at(i).name + " " + str(points.at(i).x) + " " +
str(points.at(i).y) + " " + str(points.at(i).z) + "\n")
xyz += (
molecule.at(i).name
+ " "
+ str(points.at(i).x)
+ " "
+ str(points.at(i).y)
+ " "
+ str(points.at(i).z)
+ "\n"
)

# Loads the geometry string into the Berny optimizer
# object.
Expand All @@ -58,15 +65,17 @@ def run_(self, inputs, submods):
lines = geom2xyz.split("\n")
mol_string = "\n".join(lines[2:])
xyz2chem_mol = submods["StringConv"].run_as(
MoleculeFromString(), mol_string)
MoleculeFromString(), mol_string
)
geom = chemist.ChemicalSystem(xyz2chem_mol)
geom_nuclei = geom.molecule.nuclei.as_nuclei()
geom_points = geom_nuclei.charges.point_set.as_point_set()

# Main optimizer operation
energy = submods["Energy"].run_as(TotalEnergy(), geom)
gradients = submods["Gradient"].run_as(
EnergyNuclearGradientStdVectorD(), geom, geom_points)
EnergyNuclearGradientStdVectorD(), geom, geom_points
)
optimizer.send((np.array(energy).item(), gradients))

opt_geom_nuclei = geom.molecule.nuclei.as_nuclei()
Expand Down
Loading