Subject: More Python code for computational chemistry

From: [email-masked] (Konrad HINSEN)
Date: Wed, 6 Mar 1996 14:19:27 -0500

I have made some major additions to the Python code for computational
chemistry that I published earlier on the CCL archive. The most
interesting addition is probably the code that automatically
calculates gradients and force constants for an arbitrary potential
energy function (these are analytic derivatives, not finite-difference
calculations). There are also some minor improvements in the PDB
code; it can now handle compressed files and understands filenames
containing "~" to refer to a home directory (the last two features
are for Unix only).

The code can be found via the URLs

  ftp://www.ccl.net:/pub/chemistry/software/SOURCES/PYTHON/HINSEN
  gopher://www.ccl.net:73/11/software/SOURCES/PYTHON/HINSEN

Here is a short description of the modules:

PDB.py  (requires TextFile.py, Vector.py and umath.py)

  High-level I/O with PDB files. Allows you to deal with PDB files as if they
  were lists of residues and atoms. Example:
     for residue in PDBConfiguration('protein.pdb'):
         for atom in residue:
             print atom.name, atom.position

TextFile.py

  Unified access to compressed and uncompressed files, plus access
  to text files as a sequence of lines. ONLY FOR UNIX SYSTEMS!

Derivatives.py (requires Vector.py and umath.py)

  Automatic derivatives. Calculates analytical derivatives numerically, given
  only the original function, to any order and for any number of
  variables. Example:
     x = DerivVar(1.1,0)
     y = DerivVar(0.44, 1)
     f = exp(x**2+y**2)
     print f
  prints:
     (4.06982499598, [8.95361499116, 3.58144599646])

FirstDerivatives.py (requires Vector.py and umath.py)

  Automatic first-order derivatives. This module is a subset of
  Derivatives.py and compatible as far as possible. The restriction
  to first-order derivatives makes it faster.

Potential.py (requires Derivatives.py, FirstDerivatives.py, Vector.py
              and umath.py)

  Automatic gradient and force constant calculation for potential
  functions (or any function).
  Example:
     def harmonic(k, r1, r2):
          dr = r1-r2
	 return k*dr*dr
     harmonic_g = PotentialWithGradientsAndForceConstants(harmonic)
     energy, gradients, force_constants = \
            harmonic_g(100., Vector(0,3,1), Vector(1,2,0))
     print energy
     print gradients
     print force_constants
  prints:
     300.0
     [Vector(-200.0,200.0,200.0), Vector(200.0,-200.0,-200.0)]
     [[200.0, 0.0, 0.0, -200.0, 0.0, 0.0],
      [0.0, 200.0, 0.0, 0.0, -200.0, 0.0],
      [0.0, 0.0, 200.0, 0.0, 0.0, -200.0],
      [-200.0, 0.0, 0.0, 200.0, 0.0, 0.0],
      [0.0, -200.0, 0.0, 0.0, 200.0, 0.0],
      [0.0, 0.0, -200.0, 0.0, 0.0, 200.0]]

Vector.py (requires umath.py)

  3d-vectors, used by the three other modules.

umath.py

  Simplified substitute for the module "umath" from the
  numerics package. Use only if you don't have the
  numerics package. This module is used by all the other
  modules in this directory.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: [email-masked]
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------