1 """ Engine base class from which all ForceBalance MD engines are derived. """ 9 from collections
import OrderedDict
15 from forcebalance.output
import getLogger
16 logger = getLogger(__name__)
18 class Engine(forcebalance.BaseClass):
21 Base class for all engines. 25 In ForceBalance an Engine represents a molecular dynamics code 26 and the calculations that may be carried out with that code. 30 Previously system calls to MD software have been made by the 31 Target. Duplication of code was occurring, because different 32 Targets were carrying out the same type of calculation. 36 Target objects should contain Engine objects, because OpenMM 37 Engine objects need to be initialized at the start of a 42 def __init__(self, name="engine", **kwargs):
43 self.valkwd += [
'mol',
'coords',
'name',
'target',
'pbc',
'FF',
'nonbonded_method',
'nonbonded_cutoff']
44 kwargs = {i:j
for i,j
in kwargs.items()
if j
is not None and i
in self.valkwd}
47 if 'verbose' in kwargs:
52 if 'target' in kwargs:
53 self.
target = kwargs[
'target']
58 warn_once(
"Running without a target, using current directory.")
59 self.
root = os.getcwd()
63 self.
FF = kwargs[
'FF']
64 if hasattr(self,
'target')
and not hasattr(self,
'FF'):
84 printcool_dictionary(OrderedDict([(i, self.__dict__[i])
for i
in sorted(self.__dict__.keys())]), title=
"Attributes for engine %s" % self.__class__.__name__)
Nifty functions, intended to be imported by any module within ForceBalance.
def readsrc(self, kwargs)
def __init__(self, name="engine", kwargs)
def setopts(self, kwargs)
def printcool_dictionary(Dict, title="Dictionary Keys : Values", bold=False, color=2, keywidth=25, topwidth=50, center=True, leftpad=0)
See documentation for printcool; this is a nice way to print out keys/values in a dictionary...
def prepare(self, kwargs)
def warn_once(warning, warnhash=None)
Prints a warning but will only do so once in a given run.
target
Engines can get properties from the Target that creates them.
Base class for all engines.