예제 #1
0
def pileg(taut, plam=0.5):
  therm = xml.make_node('thermostat', {'mode': 'pile_g'})
  lam_node = xml.make_node('pile_lambda', text=str(plam))
  tnode = xml.make_node('tau', {'units': 'femtosecond'}, str(taut))
  therm.append(lam_node)
  therm.append(tnode)
  return therm
예제 #2
0
def ensemble(tkel, pgpa=None):
  ens = xml.make_node('ensemble')
  tnode = xml.make_node('temperature', {'units': 'kelvin'}, str(tkel))
  ens.append(tnode)
  if pgpa is not None:
    pnode = xml.make_node('pressure', {'units': 'gigapascal'}, str(pgpa))
    ens.append(pnode)
  return ens
예제 #3
0
def barostat(taup, taut):
  baro = xml.make_node('barostat', {'mode': 'isotropic'})
  cell_thermo = xml.make_node('thermostat', {'mode': 'langevin'})
  tnode = xml.make_node('tau', {'units': 'femtosecond'}, str(taut))
  cell_thermo.append(tnode)
  pnode = xml.make_node('tau', {'units': 'femtosecond'}, str(taup))
  baro.append(pnode)
  baro.append(cell_thermo)
  return baro
예제 #4
0
def properties(props=None, **kwargs):
  if props is None:
    quantum = kwargs.pop('quantum', False)
    props = default_properties(quantum=quantum)
  text = text_arr(np.array(props))
  # defaults
  attrib = {
    'stride': str(kwargs.pop('stride', '1')),
    'flush': str(kwargs.pop('flush', '1')),
    'filename': str(kwargs.pop('filename', 'out')),
  }
  prop = xml.make_node('properties', attrib, text)
  return prop
예제 #5
0
def classical_qe(temp, pgpa=None, **kwargs):
  ens_name = 'nvt'
  if pgpa is not None:
    ens_name = 'npt'
  # defaults
  prefix = kwargs.pop('prefix', 'qemd')
  ntherm = kwargs.pop('ntherm', 2)  # property output
  nconf = kwargs.pop('nconf', 20)  # conf. output
  dtfs = kwargs.pop('dtfs', 0.5)  # timestep in fs
  taut = kwargs.pop('taut', 100)  # fs
  taup = kwargs.pop('taup', 100)  # fs
  # make input pieces
  sim = xml.make_node('simulation', {'verbosity': 'high'})
  # <system>: init, forces, ensemble, dynamics
  system = xml.make_node('system')
  init = xml.make_node('initialize', {'nbeads': '1'})
  fnode = xml.make_node('file', {'mode': 'xyz'}, 'init.xyz')
  vnode = xml.make_node('velocities', {
    'mode': 'thermal', 'units': 'kelvin'}, str(temp))
  xml.append(init, [fnode, vnode])
  forces = xml.make_node('forces')
  forces.append(xml.make_node('force', {'forcefield': 'qe'}))
  mot = xml.make_node('motion', {'mode': 'dynamics'})
  dyn = xml.make_node('dynamics', {'mode': ens_name})
  ts = xml.make_node('timestep', {'units': 'femtosecond'}, str(dtfs))
  tnode = pileg(taut)
  dnodes = [ts, tnode]
  if pgpa is not None:
    baro = barostat(taup, taut)
    dnodes.append(baro)
  xml.append(dyn, dnodes)
  mot.append(dyn)
  ens = ensemble(temp, pgpa=pgpa)
  xml.append(system, [init, forces, mot, ens])
  # <output>: properties, trajectory, checkpoint
  output = xml.make_node('output', {'prefix': prefix})
  props = properties(quantum=False, stride=ntherm)
  ptraj = xml.make_node('trajectory', {
    'filename': 'pos',
    'stride': str(nconf),
    'flush': '1',
    'cell_units': 'angstrom',
  }, text='positions{angstrom}')
  ftraj = xml.make_node('trajectory', {
    'filename': 'frc',
    'stride': str(nconf),
    'flush': '1',
    'cell_units': 'angstrom',
  }, text='forces{ev/ang}')
  check = xml.make_node('checkpoint', {'stride': str(nconf)})
  xml.append(output, [props, ptraj, ftraj, check])
  # assemble
  xml.append(sim, [system, output])
  doc = xml.etree.ElementTree(sim)
  # ??? <ffsocket>
  # ??? <prng>
  # ??? <total_steps>
  return doc