Skip to content

Commit

Permalink
Update docstrings & comments
Browse files Browse the repository at this point in the history
  • Loading branch information
FarnazH committed Aug 29, 2020
1 parent 7d3f67f commit 61c6b91
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions iodata/formats/mwfn.py
Expand Up @@ -18,6 +18,7 @@
# --
"""Multiwfn MWFN file format."""


from typing import Tuple

import numpy as np
Expand All @@ -27,10 +28,13 @@
from ..orbitals import MolecularOrbitals
from ..utils import LineIterator, angstrom


__all__ = []


PATTERNS = ['*.mwfn']


# From the MWFN chemrxiv paper
# https://chemrxiv.org/articles/Mwfn_A_Strict_Concise_and_Extensible_Format
# _for_Electronic_Wavefunction_Storage_and_Exchange/11872524
Expand Down Expand Up @@ -64,7 +68,7 @@


def _load_helper_opener(lit: LineIterator) -> dict:
"""Read initial variables."""
"""Read initial variables at the beginning of a MWFN file."""
keys = {"Wfntype": int, "Charge": float, "Naelec": float, "Nbelec": float, "E_tot": float,
"VT_ratio": float, "Ncenter": int}
max_count = len(keys)
Expand Down Expand Up @@ -99,7 +103,7 @@ def _load_helper_opener(lit: LineIterator) -> dict:


def _load_helper_basis(lit: LineIterator) -> dict:
"""Read initial variables."""
"""Read basis set information typically labelled '# Basis function information'."""
# Nprims must be last or else it gets read in with Nprimshell
keys = ["Nbasis", "Nindbasis", "Nshell", "Nprimshell", "Nprims"]
count = 0
Expand All @@ -116,9 +120,12 @@ def _load_helper_basis(lit: LineIterator) -> dict:


def _load_helper_atoms(lit: LineIterator, natom: int) -> dict:
"""Read the coordinates of the atoms."""
data = {"atnums": np.empty(natom, int), "atcorenums": np.empty(natom, float),
"atcoords": np.empty((natom, 3), float)}
"""Read atoms section typically labelled '# Atom information'."""
data = {
"atnums": np.empty(natom, int),
"atcorenums": np.empty(natom, float),
"atcoords": np.empty((natom, 3), float),
}

# skip lines until "$Centers" section is reached
line = next(lit)
Expand Down Expand Up @@ -162,7 +169,7 @@ def _load_helper_shells(lit: LineIterator, nshell: int) -> dict:

def _load_helper_section(lit: LineIterator, nprim: int, start: str, skip: int,
dtype: np.dtype) -> np.ndarray:
"""Read SHELL CENTER, SHELL TYPE, and SHELL CONTRACTION DEGREES sections."""
"""Read section."""
section = []
while len(section) < nprim:
line = next(lit)
Expand All @@ -173,7 +180,7 @@ def _load_helper_section(lit: LineIterator, nprim: int, start: str, skip: int,


def _load_helper_mo(lit: LineIterator, n_basis: int, n_mo: int) -> dict:
"""Read one section of MO information."""
"""Read molecular orbitals section typically labelled '# Orbital information'."""

data = {
"mo_numbers": np.empty(n_mo, int),
Expand Down Expand Up @@ -210,17 +217,14 @@ def _load_mwfn_low(lit: LineIterator) -> dict:
The line iterator to read the data from.
"""
# Note:
# ---------
# mwfn is a fortran program which loads *.mwfn by locating the line with the keyword,
# then uses `backspace`, then begins reading. Despite this flexibility, it is stated by
# the authors that the order of section, and indeed, entries in general, must be fixed.
# With this in mind the input utilized some hardcoding since order should be fixed.
#
# mwfn ignores lines beginning with `#`.
# read sections of mwfn file
# This assumes title is on first line which seems to be the standard

# read title
# -----
# 1) mwfn is a fortran program which loads *.mwfn by locating the line with the keyword,
# then uses `backspace`, then begins reading. Despite this flexibility, it is stated by
# the authors that the order of section, and indeed, entries in general, must be fixed.
# With this in mind the input utilized some hard-coding since order should be fixed.
# 2) mwfn ignores lines beginning with `#`.

# read title (assuming title is the 1st line, which seems to be the standard)
data = {"title": next(lit).strip()}

# load Wfntype, Charge, Naelec, Nbelec, E_tot, VT_ratio, & Ncenter
Expand Down Expand Up @@ -254,7 +258,7 @@ def _load_mwfn_low(lit: LineIterator) -> dict:
# load MO information
data.update(_load_helper_mo(lit, num_basis, num_mo))

# TODO: add density matrix and overlap
# TODO: load data in '# Various matrices' section

return data

Expand Down

0 comments on commit 61c6b91

Please sign in to comment.