示例#1
0
from os.path import abspath, dirname, join as path_join

# You probably have to have psi4 installed as a python module for this to work
from computation_cache import ComputationCache

# You will also need a fairly recent version of numpy (which grendel depends on)
import numpy
from grendel import Molecule, Tensor

# Create a (hidden) ComputationCache in a folder named ".comp_cache" in the same
#   directory as this script.
my_dir = dirname(abspath(__file__))
comp_cache = ComputationCache(
    # The path to the root folder that the ComputationCache will store its data in.
    path_join(my_dir, ".comp_cache"),
    # Allow the ComputationCache constructor to create the directory if one does not
    #   already exist (the default for this option is False).
    make_directory=True
)

# Create a CachedComputation object which can retrieve data for a given Molecule
#   in a cached manner.  For larger-scale projects, it is probably better to
#   wrap this as an attribute in a subclass of grendel.Molecule (examples of this
#   will be given elsewhere), but for this simple example, using the bare
#   CachedComputation object will suffice.
comp = comp_cache.get_computation(
    # The first argument can be an xyz string (as shown here) or anything else
    #   for which grendel.Molecule(arg) returns something sensible.  It can
    #   also be a grendel.Molecule instance, which is necessary to access more
    #   complicated features like charge and multiplicity.
    """
示例#2
0
from os.path import abspath, dirname, join as path_join
from computation_cache import ComputationCache
import numpy
from grendel import Molecule, Tensor, DeclareIndexRange

# The first example in schwarz_1.py shows some basic usage of the
#   computation_cache module.  Some more advanced features will be
#   introduced in this script.

# The parts between these markers is unchanged from schwarz_1.py.
#   For brevity, the documentation has been removed from this part.
#   Read through schwarz_1.py first before reading this script.
#------------- Begin documented in schwarz_1.py -------------#
my_dir = dirname(abspath(__file__))
comp_cache = ComputationCache(
    path_join(my_dir, ".comp_cache"),
    make_directory=True
)

comp = comp_cache.get_computation(
    """
    8
    Ethane
    C     0.76500000   0.00000000  -0.00000000
    C    -0.76500000  -0.00000000  -0.00000000
    H     1.12830000  -0.51380000   0.89000000
    H     1.12830000  -0.51380000  -0.89000000
    H     1.12830000   1.02770000   0.00000000
    H    -1.12830000   0.51380000   0.89000000
    H    -1.12830000   0.51380000  -0.89000000
    H    -1.12830000  -1.02770000   0.00000000
    """,