porereax.molecule_structure

Module for sampling molecular structure statistics.

The module provides MoleculeStructureSampler to sample bonding environments of all atomtypes and reveal the atom structures.

Classes

MoleculeStructureSampler(name_out, ...[, steps])

Sampler class for molecular structure statistics.

class porereax.molecule_structure.MoleculeStructureSampler(name_out, dimension, region, process_id, atom_lib, masses, num_frames, box, system_properties, steps=1)[source]

Bases: Sampler

Sampler class for molecular structure statistics.

Parameters:
  • name_out (str) – Name of the output file of the sampler data

  • dimension (str) – Dimension along which to sample.

  • region (Region) – Region specification for sampling. Can be a string defining a geometric region or a function that takes coordinates and returns a boolean mask.

  • process_id (int) – Process ID for parallel processing.

  • atom_lib (dict) – Dictionary mapping atom type strings to their type IDs.

  • masses (dict) – Dictionary mapping atom type strings to their masses.

  • num_frames (int) – Total number of frames to sample.

  • box (ndarray) – Simulation box dimensions.

  • system_properties (dict | None) – System properties for sampling, if applicable.

  • steps (int) – Number of bonding “steps” from the central atom to search for. Default is 1 (only directly bonded neighbours, e.g. “O(Si+Si)”). Step 2 would include information about the Si neighbours’ in that example, e.g. “O(Si(O+O+O)+Si(O+O+O))”, and so on for larger values.

sample(frame_id, molecule_mask, molecule_bond_atoms, bond_mask, frame, bond_enum, positions_transformed)[source]

Sample data for the current frame.

Parameters:
  • frame_id (int) – Frame index in perspective of the subprocess (starts from 0 for each subprocess).

  • molecule_mask (dict) – Dictionary mapping molecule identifiers to boolean masks indicating which atoms belong to that molecule in the frame.

  • molecule_bond_atoms (dict) – Dictionary mapping molecule identifiers to their bonded atom indices in the frame.

  • bond_mask (dict) – Dictionary mapping bond identifiers to boolean masks indicating which bonds belong to that identifier in the frame.

  • frame (object) – Current frame object from OVITO containing atomic data.

  • bond_enum (object) – OVITO BondsEnumerator object for enumerating bonds in the frame.

  • positions_transformed (ndarray) – Transformed positions of atoms in the current frame.

join_samplers(num_cores)[source]

Collect and combine sampler data from multiple processes. This saves the combined data to a single ‘<name_out>.obj’ file and removes the individual process files. This process is only executed by the main process (process_id == -1).

Parameters:

num_cores (int) – Number of parallel processes used for sampling.

Return type:

None