Ejemplo n.º 1
0
# This file is part of i-PI.
# i-PI Copyright (C) 2014-2015 i-PI developers
# See the "licenses" directory for full license information.


import re
from ipi.engine.atoms import Atoms
from ipi.engine.cell import Cell
from ipi.utils.units import unit_to_internal
from ipi.engine.properties import Trajectories as Traj

# Regular expressions initialization for read_xyz function
cell_unit_re = re.compile(r'cell\{([a-z]*)\}')             # cell unit pattern
traj_dict = Traj().traj_dict                             # trajectory dictionary
traj_re = [re.compile('%s%s' % (key, r'\{[a-z]*\}'))
           for key in traj_dict.keys()]  # trajectory patterns

def process_units(comment, cell, qatoms, names, masses, output='objects'):
    """ Converts the data in the file according to the units written in the ipi format.
    """
    # Extracting trajectory units
    family, unit = 'undefined', ''
    is_comment_useful = filter(None, [key.search(comment.strip())
                                      for key in traj_re])
    if len(is_comment_useful) > 0:
        traj = is_comment_useful[0].group()[:-1].split('{')
        family, unit = traj_dict[traj[0]]['dimension'], traj[1]

    # Extracting cell units
    cell_unit = ''
    tmp = cell_unit_re.search(comment)
Ejemplo n.º 2
0
# See the "licenses" directory for full license information.

import re
from ipi.utils.messages import verbosity, info
from ipi.engine.atoms import Atoms
from ipi.engine.cell import Cell
from ipi.utils.units import unit_to_internal
from ipi.engine.properties import Trajectories as Traj

__all__ = ["auto_units", "process_units"]
# Regular expressions initialization for read_xyz function
cell_unit_re = re.compile(r"cell\{([A-Za-z_]*)\}")  # cell unit pattern
traj_dict = Traj().traj_dict  # trajectory dictionary
traj_re = [
    re.compile("%s%s" % (key, r"\{[A-Za-z_]*\}"))
    for key in list(traj_dict.keys())
]  # trajectory patterns


def auto_units(
    comment="",
    dimension="automatic",
    units="automatic",
    cell_units="automatic",
    mode="xyz",
):
    """Processes comment line and requested units to determine how to interpret the I/O conversion."""
    # heuristics to detect units
    if mode in ("pdb", "ase"):  # these are the default units
        auto_cell = "angstrom"
        auto_units = "angstrom"
Ejemplo n.º 3
0
"""


import sys
import re
from ipi.utils.io import read_file, print_file, read_file_raw
from ipi.utils.depend import *
from ipi.utils.units import *
from ipi.utils.io.io_units import process_units
from ipi.engine.properties import Trajectories as Traj
from ipi.utils.messages import verbosity

cell_unit_re = re.compile(r'cell\{([A-Za-z_]*)\}')       # cell unit pattern
traj_dict = Traj().traj_dict                             # trajectory dictionary
traj_re = [re.compile('%s%s' % (key, r'\{[A-Za-z_]*\}')) for key in traj_dict.keys()]  # trajectory patterns
verbosity.level = "low"


def get_cell_units(comment, mode):

    # default units
    if mode == "pdb":
        auto_cell = "angstrom"
    else:
        auto_cell = "atomic_unit"

    cunit = cell_unit_re.search(comment)
    if cunit is not None:
        auto_cell = cunit.group(1)
    return auto_cell
Ejemplo n.º 4
0
# i-PI Copyright (C) 2014-2015 i-PI developers
# See the "licenses" directory for full license information.

import re
from ipi.utils.messages import verbosity, info, warning
from ipi.engine.atoms import Atoms
from ipi.engine.cell import Cell
from ipi.utils.units import unit_to_internal
from ipi.engine.properties import Trajectories as Traj

__all__ = ["auto_units", "process_units"]
# Regular expressions initialization for read_xyz function
cell_unit_re = re.compile(r'cell\{([A-Za-z_]*)\}')  # cell unit pattern
traj_dict = Traj().traj_dict  # trajectory dictionary
traj_re = [
    re.compile('%s%s' % (key, r'\{[A-Za-z_]*\}')) for key in traj_dict.keys()
]  # trajectory patterns


def auto_units(comment="",
               dimension="automatic",
               units="automatic",
               cell_units="automatic",
               mode="xyz"):
    """ Processes comment line and requested units to determine how to interpret the I/O conversion. """\

    # heuristics to detect units
    if mode == "pdb":  # these are the default units
        auto_cell = "angstrom"
        auto_units = "angstrom"
        auto_dimension = "length"
Ejemplo n.º 5
0
# See the "licenses" directory for full license information.


import re
from ipi.utils.messages import verbosity, info, warning
from ipi.engine.atoms import Atoms
from ipi.engine.cell import Cell
from ipi.utils.units import unit_to_internal
from ipi.engine.properties import Trajectories as Traj

__all__ = ["auto_units", "process_units"]
# Regular expressions initialization for read_xyz function
cell_unit_re = re.compile(r'cell\{([A-Za-z_]*)\}')       # cell unit pattern
traj_dict = Traj().traj_dict                             # trajectory dictionary
traj_re = [re.compile('%s%s' % (key, r'\{[A-Za-z_]*\}'))
           for key in traj_dict.keys()]  # trajectory patterns


def auto_units(comment="", dimension="automatic", units="automatic", cell_units="automatic", mode="xyz"):
    """ Processes comment line and requested units to determine how to interpret the I/O conversion. """\

    # heuristics to detect units
    if mode == "pdb":  # these are the default units
        auto_cell = "angstrom"
        auto_units = "angstrom"
        auto_dimension = "length"
    else:
        auto_cell = "atomic_unit"
        auto_units = "atomic_unit"
        auto_dimension = "undefined"