Skip to content

Commit

Permalink
Merge pull request #6 from molssi-seamm/structure
Browse files Browse the repository at this point in the history
Updated to the new system classes.
  • Loading branch information
seamm authored Sep 28, 2020
2 parents e42a374 + 8f9ea2a commit 2666477
Show file tree
Hide file tree
Showing 9 changed files with 292 additions and 164 deletions.
8 changes: 5 additions & 3 deletions devtools/conda-envs/test_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: test

channels:
- default
- conda-forge

dependencies:
# Base depends
Expand All @@ -10,6 +11,7 @@ dependencies:
- configargparse
- psutil
- py-cpuinfo
- openbabel

# Testing
- coverage
Expand All @@ -20,9 +22,9 @@ dependencies:

# Pip-only installs
- pip:
- seamm>=0.9
- seamm-util>=0.9
- seamm-widgets>=0.9
- seamm>=2020.9.23
- seamm-util>=2020.9.23
- seamm-widgets>=2020.8.1

# Testing
- codecov
Expand Down
94 changes: 48 additions & 46 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# directory, add these directories to sys.path here. If the directory is
# relative to the documentation root, use os.path.abspath to make it
# absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
# sys.path.insert(0, os.path.abspath('.'))

# Get the project root dir, which is the parent dir of this
cwd = os.getcwd()
Expand All @@ -31,16 +31,18 @@
# version is used.
sys.path.insert(0, project_root)

import psi4_step
import psi4_step # noqa: E402

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

# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# needs_sphinx = '1.0'

# 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.autodoc', 'sphinx.ext.viewcode']
extensions = [
'sphinx.ext.napoleon', 'sphinx.ext.autodoc', 'sphinx.ext.viewcode'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -49,7 +51,7 @@
source_suffix = '.rst'

# The encoding of source files.
#source_encoding = 'utf-8-sig'
# source_encoding = 'utf-8-sig'

# The master toctree document.
master_doc = 'index'
Expand All @@ -69,42 +71,42 @@

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#language = None
# language = None

# There are two options for replacing |today|: either, you set today to
# some non-false value, then it is used:
#today = ''
# today = ''
# Else, today_fmt is used as the format for a strftime call.
#today_fmt = '%B %d, %Y'
# today_fmt = '%B %d, %Y'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
exclude_patterns = ['_build']

# The reST default role (used for this markup: `text`) to use for all
# documents.
#default_role = None
# default_role = None

# If true, '()' will be appended to :func: etc. cross-reference text.
#add_function_parentheses = True
# add_function_parentheses = True

# If true, the current module name will be prepended to all description
# unit titles (such as .. function::).
#add_module_names = True
# add_module_names = True

# If true, sectionauthor and moduleauthor directives will be shown in the
# output. They are ignored by default.
#show_authors = False
# show_authors = False

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

# A list of ignored prefixes for module index sorting.
#modindex_common_prefix = []
# modindex_common_prefix = []

# If true, keep warnings as "system message" paragraphs in the built
# documents.
#keep_warnings = False
# keep_warnings = False


# -- Options for HTML output -------------------------------------------
Expand All @@ -116,27 +118,27 @@
# 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
# documentation.
#html_theme_options = {}
# html_theme_options = {}

# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# html_theme_path = []

# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None
# html_title = None

# A shorter title for the navigation bar. Default is the same as
# html_title.
#html_short_title = None
# html_short_title = None

# The name of an image file (relative to this directory) to place at the
# top of the sidebar.
#html_logo = None
# html_logo = None

# The name of an image file (within the static path) to use as favicon
# of the docs. This file should be a Windows icon file (.ico) being
# 16x16 or 32x32 pixels large.
#html_favicon = None
# html_favicon = None

# Add any paths that contain custom static files (such as style sheets)
# here, relative to this directory. They are copied after the builtin
Expand All @@ -146,46 +148,46 @@

# If not '', a 'Last updated on:' timestamp is inserted at every page
# bottom, using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y'
# html_last_updated_fmt = '%b %d, %Y'

# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
#html_use_smartypants = True
# html_use_smartypants = True

# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# html_sidebars = {}

# Additional templates that should be rendered to pages, maps page names
# to template names.
#html_additional_pages = {}
# html_additional_pages = {}

# If false, no module index is generated.
#html_domain_indices = True
# html_domain_indices = True

# If false, no index is generated.
#html_use_index = True
# html_use_index = True

# If true, the index is split into individual pages for each letter.
#html_split_index = False
# html_split_index = False

# If true, links to the reST sources are added to the pages.
#html_show_sourcelink = True
# html_show_sourcelink = True

# If true, "Created using Sphinx" is shown in the HTML footer.
# Default is True.
#html_show_sphinx = True
# html_show_sphinx = True

# If true, "(C) Copyright ..." is shown in the HTML footer.
# Default is True.
#html_show_copyright = True
# html_show_copyright = True

# If true, an OpenSearch description file will be output, and all pages
# will contain a <link> tag referring to it. The value of this option
# must be the base URL from which the finished HTML is served.
#html_use_opensearch = ''
# html_use_opensearch = ''

# This is the file name suffix for HTML files (e.g. ".xhtml").
#html_file_suffix = None
# html_file_suffix = None

# Output file base name for HTML help builder.
htmlhelp_basename = 'psi4_stepdoc'
Expand All @@ -195,13 +197,13 @@

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

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

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

# Grouping the document tree into LaTeX files. List of tuples
Expand All @@ -215,23 +217,23 @@

# The name of an image file (relative to this directory) to place at
# the top of the title page.
#latex_logo = None
# latex_logo = None

# For "manual" documents, if this is true, then toplevel headings
# are parts, not chapters.
#latex_use_parts = False
# latex_use_parts = False

# If true, show page references after internal links.
#latex_show_pagerefs = False
# latex_show_pagerefs = False

# If true, show URL addresses after external links.
#latex_show_urls = False
# latex_show_urls = False

# Documents to append as an appendix to all manuals.
#latex_appendices = []
# latex_appendices = []

# If false, no module index is generated.
#latex_domain_indices = True
# latex_domain_indices = True


# -- Options for manual page output ------------------------------------
Expand All @@ -245,7 +247,7 @@
]

# If true, show URL addresses after external links.
#man_show_urls = False
# man_show_urls = False


# -- Options for Texinfo output ----------------------------------------
Expand All @@ -263,13 +265,13 @@
]

# Documents to append as an appendix to all manuals.
#texinfo_appendices = []
# texinfo_appendices = []

# If false, no module index is generated.
#texinfo_domain_indices = True
# texinfo_domain_indices = True

# How to display URL addresses: 'footnote', 'no', or 'inline'.
#texinfo_show_urls = 'footnote'
# texinfo_show_urls = 'footnote'

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False
# texinfo_no_detailmenu = False
12 changes: 12 additions & 0 deletions psi4_step/energy_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ class EnergyParameters(seamm.Parameters):
"(UHF, UKS)"
)
},
"freeze-cores": {
"default": "yes",
"kind": "enumeration",
"default_units": "",
"enumeration": ('yes', 'no'),
"format_string": "s",
"description": "Freeze core orbitals:",
"help_text": (
"Whether to freeze the core orbitals in correlated "
"methods"
)
},
"results": {
"default": {},
"kind": "dictionary",
Expand Down
30 changes: 18 additions & 12 deletions psi4_step/psi4.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

import psi4_step
import seamm
from seamm import data # noqa: F401
from seamm_util import ureg, Q_ # noqa: F401
import seamm_util.printing as printing
from seamm_util.printing import FormattedText as __
Expand Down Expand Up @@ -298,7 +297,9 @@ def run(self):
printer.important(self.header)
printer.important('')

if data.structure is None:
system = self.get_variable('_system')
n_atoms = system.n_atoms()
if n_atoms == 0:
logger.error('Psi4 run(): there is no structure!')
raise RuntimeError('Psi4 run(): there is no structure!')

Expand Down Expand Up @@ -483,13 +484,18 @@ def analyze(self, indent='', **kwargs):
with structure_file.open(mode='r') as fd:
structure = json.load(fd)
if 'geom' in structure:
system = seamm.data.structure
atoms = system['atoms']
xyz = []
system = self.get_variable('_system')
xs = []
ys = []
zs = []
it = iter(structure['geom'])
for x in it:
xyz.append([x, next(it), next(it)])
atoms['coordinates'] = xyz
xs.append(x)
ys.append(next(it))
zs.append(next(it))
system.atoms['x'][0:] = xs
system.atoms['y'][0:] = ys
system.atoms['z'][0:] = zs
printer.important(
self.indent +
' Updated the system with the structure from Psi4',
Expand All @@ -499,7 +505,7 @@ def analyze(self, indent='', **kwargs):
def _convert_structure(self, name=None):
"""Convert the structure to the input for Psi4."""

system = seamm.data.structure
system = self.get_variable('_system')

structure = []
if name is None:
Expand Down Expand Up @@ -537,11 +543,11 @@ def _convert_structure(self, name=None):
if 'net_charge' in extras and extras['net_charge'] is not None:
structure.append(f" {extras['net_charge']} 1")

elements = system['atoms']['elements']
coordinates = system['atoms']['coordinates']
elements = system.atoms.symbols()
coordinates = system.atoms.coordinates()

if 'freeze' in system['atoms']:
freeze = system['atoms']['freeze']
if 'freeze' in system.atoms:
freeze = system.atoms['freeze']
else:
freeze = [''] * len(elements)

Expand Down
Loading

0 comments on commit 2666477

Please sign in to comment.