pyretis.tools package

Tools which can help with setting up simulations.

This package defines some simple tools which may be useful for creating simulations.

Package structure

Modules

lattice.py (pyretis.tools.lattice)
Defines tools for setting up and generating lattice points.
recalculate_order.py (pyretis.tools.recalculate_order)
Methods for recalculating order parameters on external paths.

Important methods defined in this package

generate_lattice (generate_lattice())
Generates points on a lattice.
recalculate_order (recalculate_order())
Recalculate order parameter(s).

pyretis.tools.lattice module

Some methods for generating initial lattice structures.

Important methods defined here

generate_lattice (generate_lattice())
Generate points on a simple lattice.

Examples

>>> from pyretis.tools.lattice import generate_lattice
>>> xyz, size = generate_lattice('diamond', [1, 1, 1], lcon=1)
pyretis.tools.lattice.generate_lattice(lattice, repeat=None, lcon=None, density=None)[source]

Generate points on a simple lattice.

The lattice is one of the defined keys in the global variable UNIT_CELL. This lattice will be repeated a number of times. The lattice spacing can be given explicitly, or it can be given implicitly by the number density.

Parameters:
  • lattice (string) – Select the kind of lattice. The following options are currently defined in UNIT_CELL:

    • 1d : 1D lattice
    • sc : Simple cubic lattice.
    • sq : Square lattice (2D) with one atom in the unit cell.
    • sq2 : Square lattice with two atoms in the unit cell.
    • bcc : Body-centred cubic lattice.
    • fcc : Face-centred cubic lattice.
    • hcp : Hexagonal close-packed lattice.
    • diamond : Diamond structure.
  • repeat (list of integers, optional.) – How many time the cell is replicated.

  • lcon (float, optional) – The lattice constant.

  • density (float, optional) – The desired density. If this is given, lcon is calculated. Note that density will be interpreted as given in internal units.

Returns:

  • positions (numpy.array) – The lattice positions.
  • size (list of floats) – The corresponding size(s), can be used to define a simulation box.

pyretis.tools.recalculate_order module

Method to re-calculate order parameters for external trajectories.

Important methods defined here

recalculate_order (recalculate_order())
Generic method for recalculating order parameters.
recalculate_from_trj (recalculate_from_trj())
Recalculate order parameters using a GROMACS .trr file.
recalculate_from_xyz (recalculate_from_xyz())
Recalculate order parameters using a .xyz file.
recalculate_from_frame (recalculate_from_frame())
Recalculate order parameters using a .gro or .g96 file.
pyretis.tools.recalculate_order.recalculate_from_frame(order_parameter, frame_file, options)[source]

Re-calculate order parameters from a .g96/.gro file.

Here we assume that there is ONE frame in the frame_file.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • frame_file (string) – The path to the frame file we should read.
  • options (dict) – It contains:
    • ext: string File extension for the frame_file.
    • reverse: boolean, optional If True, we reverse the velocities.
Returns:

out (list of lists of floats) – The order parameters for the current frame.

pyretis.tools.recalculate_order.recalculate_from_trj(order_parameter, trr_file, options)[source]

Re-calculate order parameters from a .trr file.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • trr_file (string) – The path to the trr file we should read.
  • options (dict) – It contains:
    • reverse: boolean, optional If True, we reverse the velocities.
    • maxidx: integer, optional This is the maximum frame we will read. Can be used in case the .trr file contains extra frames not needed by us.
    • minidx: integer, optional This is the first frame we will read. Can be used in case we want to skip some frames from the .trr file.
    • idx: integer, optional This allows the selection of a single frame to recompute.
Yields:

out (list of lists of floats) – The order parameters, calculated per frame.

pyretis.tools.recalculate_order.recalculate_from_xyz(order_parameter, traj_file, options)[source]

Re-calculate order parameters from a .xyz file.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • traj_file (string) – The path to the trajectory file we should read.
  • options (dict) – It contains:
    • reverse: boolean, optional If True, we reverse the velocities.
    • maxidx: integer, optional This is the maximum frame we will read. Can be used in case the .trr file contains extra frames not needed by us.
    • minidx: integer, optional This is the first frame we will read. Can be used in case we want to skip some frames from the .trr file.
    • box: list of floats It contains the box vector lenght. It is required in the case that .xyz do not normally contains the simulation box dimension.
Yields:

out (list of lists of floats) – The order parameters as a list.

pyretis.tools.recalculate_order.recalculate_order(order_parameter, traj_file, options)[source]

Re-calculate order parameters.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • traj_file (string) – Path to the trajectory file to recalculate for.
  • options (dict) – It contains:
    • reverse: boolean, optional If True, we reverse the velocities.
    • maxidx: integer, optional This is the maximum frame we will read. Can be used in case the .trr file contains extra frames not needed by us.
    • minidx: integer, optional This is the first frame we will read. Can be used in case we want to skip some frames from the .trr file.