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
2 changes: 2 additions & 0 deletions ThermoScreening/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""ThermoScreening: DFTB+ thermochemistry screening package."""

import logging
import os
import time
Expand Down
4 changes: 3 additions & 1 deletion ThermoScreening/calculator/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from .dftbplus import Geoopt, Hessian, Modes
"""Calculator backends for ThermoScreening."""

from .dftbplus import Geoopt, Hessian, Modes
7 changes: 2 additions & 5 deletions ThermoScreening/calculator/dftbplus.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""DFTB+ calculators: geometry optimisation, Hessian, and vibrational modes."""

import os
import shutil
import subprocess
Expand Down Expand Up @@ -121,7 +123,6 @@ def __init__(

self.calculate(atoms)

return None

def potential_energy(self):
"""
Expand Down Expand Up @@ -221,7 +222,6 @@ def __init__(

self.calculate(atoms)

return None

def read(self):
"""
Expand Down Expand Up @@ -278,7 +278,6 @@ def __init__(self, geometry="geo_opt.gen", hessian="hessian.out"):
# read the vibrational modes
self.wave_numbers = self.read()

return None

def write(self):
"""
Expand All @@ -304,7 +303,6 @@ def write(self):
with open("modes_in.hsd", "w") as f:
f.write(string)

return None

def calculate(self):
"""
Expand All @@ -328,7 +326,6 @@ def calculate(self):
with open("modes.out", "w") as output:
subprocess.run(["modes"], stdout=output, check=True)

return None

def read(self):
"""
Expand Down
4 changes: 3 additions & 1 deletion ThermoScreening/cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
"""Command-line interface for ThermoScreening."""

from .thermo import main
from ..utils import print_header

print_header()
print_header()
2 changes: 2 additions & 0 deletions ThermoScreening/cli/thermo.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""The ``thermo`` command-line entry point."""

from argparse import ArgumentParser
import sys
import time
Expand Down
4 changes: 2 additions & 2 deletions ThermoScreening/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class ThermoScreeningException(Exception):
"""Base class for exceptions in this package."""

class TSValueError(ThermoScreeningException):
"""Exception raised for errors in the input value."""

class TSNotImplementedError(ThermoScreeningException):
"""Exception raised for not implemented methods."""
4 changes: 3 additions & 1 deletion ThermoScreening/thermo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"""Thermochemistry API for ThermoScreening."""

from .api import read_xyz, read_gen, read_vib_file, read_coord, read_vibrational, unit_length, unit_energy, unit_mass, run_thermo, execute
from .atoms import Atom
from .cell import Cell
from .inputFileReader import InputFileReader
from .system import System
from .thermo import Thermo
from .screening import screen
from .screening import screen
49 changes: 23 additions & 26 deletions ThermoScreening/thermo/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""High-level thermochemistry functions: coordinate/frequency I/O and run helpers."""

import logging
import os
from contextlib import contextmanager
Expand Down Expand Up @@ -181,14 +183,13 @@ def read_coord(coord_file: str, engine: str):
if coord_file.endswith(".xyz"):
data_N, data_atoms, data_xyz, cell, pbc = read_xyz(coord_file)
return data_N, data_atoms, data_xyz, cell, pbc
elif coord_file.endswith(".gen"):
if coord_file.endswith(".gen"):
data_N, data_atoms, data_xyz, cell_vectors, pbc = read_gen(coord_file)
return data_N, data_atoms, data_xyz, cell_vectors, pbc
else:
logger.error(
"The input file is not supported.",
exception=TSNotImplementedError
)
logger.error(
"The input file is not supported.",
exception=TSNotImplementedError
)

else:
logger.error(
Expand Down Expand Up @@ -251,11 +252,10 @@ def unit_length(engine: str):
"""
if engine == "dftb+":
return "Angstrom"
else:
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)


def unit_energy(engine: str):
Expand All @@ -279,11 +279,10 @@ def unit_energy(engine: str):
"""
if engine == "dftb+":
return "Hartree"
else:
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)


def unit_mass(engine: str):
Expand All @@ -307,11 +306,10 @@ def unit_mass(engine: str):
"""
if engine == "dftb+":
return "amu"
else:
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)


def unit_frequency(engine: str):
Expand All @@ -335,11 +333,10 @@ def unit_frequency(engine: str):
"""
if engine == "dftb+":
return "cm^-1"
else:
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)
logger.error(
"The engine is not supported.",
exception=TSNotImplementedError
)


def _atoms_from_ase(atoms):
Expand Down
16 changes: 9 additions & 7 deletions ThermoScreening/thermo/atoms.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Atom representation and element reference data."""

import logging

import numpy as np
Expand Down Expand Up @@ -45,7 +47,7 @@ class Atom:
>>> atom.position
array([0., 0., 0.])
"""

logger = logging.getLogger(__package_name__).getChild(__qualname__)
logger = setup_logger(logger)

Expand Down Expand Up @@ -96,7 +98,7 @@ def __init__(
self._symbol = atomic_Symbol[int(number)].capitalize()
except:
self.logger.error(
"The atomic number %s is not known." % number,
f"The atomic number {number} is not known.",
exception=TSValueError
)
self._mass = atomicMasses[self._symbol.lower()]
Expand All @@ -107,7 +109,7 @@ def __init__(
self._number = atomicNumbers[symbol.lower()]
except:
self.logger.error(
"The chemical symbol %s is not known." % symbol,
f"The chemical symbol {symbol} is not known.",
exception=TSValueError
)
self._mass = atomicMasses[symbol.lower()]
Expand Down Expand Up @@ -225,7 +227,7 @@ def change_atom(
self._number = atomicNumbers[self._symbol.lower()]
except:
self.logger.error(
"The chemical symbol %s is not known." % symbol,
f"The chemical symbol {symbol} is not known.",
exception=TSValueError
)

Expand All @@ -238,14 +240,14 @@ def change_atom(
self._symbol = atomic_Symbol[int(number)].capitalize()
except:
self.logger.error(
"The atomic number %s is not known." % number,
f"The atomic number {number} is not known.",
exception=TSValueError
)
self._mass = atomicMasses[self._symbol.lower()]
self._configuration = atomicElectronConfigurations[self._symbol.lower()]
if position is not None:
self.position = position

self.position = position


atomic_Symbol = atomicNumbersReverse
Expand Down
2 changes: 2 additions & 0 deletions ThermoScreening/thermo/cell.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Periodic cell helpers."""

import numpy as np


Expand Down
17 changes: 7 additions & 10 deletions ThermoScreening/thermo/inputFileReader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Reader for ThermoScreening key=value input files."""

import logging

from ThermoScreening.exceptions import TSValueError
Expand All @@ -14,7 +16,7 @@ class InputFileReader:
The input file.

"""

logger = logging.getLogger(__package_name__).getChild(__qualname__)
logger = setup_logger(logger)

Expand Down Expand Up @@ -58,7 +60,6 @@ def __init__(
self._read()
self._check()

return None

def _read(self):
"""
Expand All @@ -84,7 +85,6 @@ def _read(self):
key, value = line.split("=", maxsplit=1)
self._dictionary[key.strip()] = value.strip()

return None

def _check(self):
"""
Expand All @@ -101,8 +101,7 @@ def _check(self):
"""
self._check_required_keys()
self._check_known_keys()

return None


def _check_required_keys(self):
"""
Expand All @@ -120,11 +119,10 @@ def _check_required_keys(self):
for key in self.required_keys:
if key not in self._dictionary.keys():
self.logger.error(
"The key {} is not set in the input file.".format(key),
f"The key {key} is not set in the input file.",
exception=TSValueError
)

return None


def _check_known_keys(self):
"""
Expand All @@ -142,8 +140,7 @@ def _check_known_keys(self):
for key in self._dictionary.keys():
if key not in self.required_keys:
self.logger.error(
"The key {} is not known.".format(key),
f"The key {key} is not known.",
exception=TSValueError
)

return None
Loading
Loading