예제 #1
0
def GetOptData(opt):
  """Parses contents of sim file into molecular simulation data.
 
  Many molecular energy minimization parameters can be determined by default, or
  overridden in an optimization file. All listed values below can be set through
  the give keyword arguments.

  The only mandatory value is (str) molecule [file path]. Setting (str) geomout
  and (str) energyout is also strongly recommended.

  Args:
    opt (mmlib.optimize.Optimization): Optimization object to append data.
  """
  infile_array = GetFileStringArray(opt.infile)
  cwd = os.getcwd()
  os.chdir(opt.indir)
  for q in range(len(infile_array)):
    if len(infile_array[q]) < 2:
      continue
    kwarg = infile_array[q][0].lower()
    kwargval = infile_array[q][1]
    kwargarr = infile_array[q][1:]
    if kwarg == 'molecule':
      opt.mol = molecule.Molecule(os.path.realpath(kwargval))
    elif kwarg == 'opttype':
      opt.opt_type = kwargval.lower()
    elif kwarg == 'optcriteria':
      opt.opt_str = kwargval.lower()
    elif kwarg == 'e_converge':
      opt.conv_delta_e = float(kwargval)
    elif kwarg == 'grms_converge':
      opt.conv_grad_rms = float(kwargval)
    elif kwarg == 'gmax_converge':
      opt.conv_grad_max = float(kwargval)
    elif kwarg == 'drms_converge':
      opt.conv_disp_rms = float(kwargval)
    elif kwarg == 'dmax_converge':
      opt.conv_disp_max = float(kwargval)
    elif kwarg == 'nmaxiter':
      opt.n_maxiter = float(kwargval)
    elif kwarg == 'geomout':
      opt.geomout = os.path.realpath(kwargval)
    elif kwarg == 'energyout':
      opt.energyout = os.path.realpath(kwargval)
  os.chdir(cwd)
예제 #2
0
This program takes in a set of molecular coordinates and parameters, infers
bonded topology (if unspecified), computes AMBER94 molecular mechanics energy
components, and outputs the resulting values to screen.

No guarantees are made that the results of this program are correct and the
author assumes no liability for their reliability.
"""

import sys

from mmlib import fileio
from mmlib import molecule

__author__ = 'Trent M. Parker'
__email__ = '*****@*****.**'
__status__ = 'Prototype'
__date__ = '2016-02-15'

if __name__ == '__main__':
    # Check input syntax.
    input_file_name = fileio.ValidateInput(__file__, sys.argv)

    # Read in molecular geometry and topology.
    molecule = molecule.Molecule(input_file_name)

    # Calculate potential energy.
    molecule.GetEnergy('nokinetic')

    # Print results to screen.
    molecule.PrintData()
예제 #3
0
def GetSimData(sim):
  """Parses contents of sim file into molecular simulation data.
  
  Many molecular simulation parameters (dynamics, monte carlo, etc.) can be
  determined by default, or overriden in a simulation file. All listed values
  below can be set through the given keyword arguments.
  
  Mandatory values include (str) molecule [file path], (float) temperature
  [Kelvin], and (float / int) total time/confs [ps / none] (md / mc).
  
  Args:
    sim (mmlib.simulate.Simulation): Simulation object to append data.
  """
  infile_array = GetFileStringArray(sim.infile)
  cwd = os.getcwd()
  os.chdir(sim.indir)
  for q in range(len(infile_array)):
    if len(infile_array[q]) < 2:
      continue
    kwarg = infile_array[q][0].lower()
    kwargval = infile_array[q][1]
    kwargarr = infile_array[q][1:]
    if kwarg == 'molecule':
      sim.mol = molecule.Molecule(os.path.realpath(kwargval))
    elif kwarg == 'temperature':
      sim.temperature = float(kwargval)
    elif kwarg == 'pressure':
      sim.pressure = float(kwargval)
    elif kwarg == 'boundaryspring':
      sim.mol.k_box = float(kwargval)
    elif kwarg == 'boundary':
      sim.mol.boundary = float(kwargval)
      sim.mol.GetVolume()
    elif kwarg == 'boundarytype':
      sim.mol.boundary_type = kwargval.lower()
      sim.mol.GetVolume()
    elif kwarg == 'origin':
      sim.mol.origin = list(map(float, kwargarr[:const.NUMDIM]))
    elif kwarg == 'totaltime':
      sim.tottime = float(kwargval)
    elif kwarg == 'totalconf':
      sim.totconf = int(kwargval)
    elif kwarg == 'timestep':
      sim.timestep = float(kwargval)
    elif kwarg == 'geomtime':
      sim.geomtime = float(kwargval)
    elif kwarg == 'geomconf':
      sim.geomconf = int(kwargval)
    elif kwarg == 'geomout':
      sim.geomout = os.path.realpath(kwargval)
    elif kwarg == 'energytime':
      sim.energytime = float(kwargval)
    elif kwarg == 'energyconf':
      sim.energyconf = int(kwargval)
    elif kwarg == 'energyout':
      sim.energyout = os.path.realpath(kwargval)
    elif kwarg == 'statustime':
      sim.statustime = float(kwargval)
    elif kwarg == 'eqtime':
      sim.eqtime = float(kwargval)
    elif kwarg == 'eqrate':
      sim.eqrate = float(kwargval)
    elif kwarg == 'randomseed':
      sim.random_seed = int(kwargval) % 2**32
  os.chdir(cwd)