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, 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:

    • 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.
  • lcon (float) – The lattice constant.
  • density (float, optional) – A desired density. If this is given, lcon is calculated. Note that density will be interpreted as given in internal units.
  • repeat (list of integers) – repeat[i] is the number of repetitions in the i direction.
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_trr (recalculate_from_trr())
Recalculate order parameters using a GROMACS .trr file.
recalculate_from_xyz (recalculate_from_xyz())
Recalculate order parameters using a .xyz file.
recalculate_from_gro (recalculate_from_gro())
Recalculate order parameters using a .gro or .g96 file.
pyretis.tools.recalculate_order.recalculate_from_trr(order_parameter, trr_file, reverse=False, maxidx=None, minidx=None)[source]

Re-calculate order parameters from a .trr file.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • trr_file (string) – Path to the trr_file we should read.
  • reverse (boolean) – 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.
Returns:

out – The order parameters as a list for each frame in the .trr file.

Return type:

list of lists of floats

pyretis.tools.recalculate_order.recalculate_from_xyz(order_parameter, traj_file, reverse=False, maxidx=None, minidx=None)[source]

Re-calculate order parameters from a .xyz file.

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • traj_file (string) – Path to the trajectory file we should read.
  • reverse (boolean) – If True, we reverse the velocities.
  • maxidx (integer, optional) – This is the maximum frame we will read. Can be used in case the 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 file.
Returns:

out – The order parameters as a list for each frame in the file.

Return type:

list of lists of floats

pyretis.tools.recalculate_order.recalculate_from_gro(order_parameter, traj_file, ext, reverse=False)[source]

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

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

Parameters:
  • order_parameter (object like OrderParameter) – The order parameter to use.
  • traj_file (string) – Path to the trajectory file we should read.
  • ext (string) – File extension for the traj_file.
  • reverse (boolean) – If True, we reverse the velocities.
Returns:

out – The order parameters as a list for each frame.

Return type:

list of lists of floats

pyretis.tools.recalculate_order.recalculate_order(order_parameter, traj_file, reverse=False, maxidx=None, minidx=None)[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.
  • reverse (boolean) – If True, we assume that we are reading a time-reversed trajectory.
  • maxidx (integer, optional) – The maximum frame number we will read from traj_file.
  • minidx (integer, optional) – The minimum frame number we will read from traj_file