### Build lammpsio from source Source: https://lammpsio.readthedocs.io/en/stable/install.html Commands to install the package from a local source directory. ```bash pip install . ``` ```bash pip install -r requirements-dev.txt -r doc/requirements.txt ``` -------------------------------- ### Install lammpsio via package managers Source: https://lammpsio.readthedocs.io/en/stable/install.html Standard commands to install the package using pip or conda. ```bash pip install lammpsio ``` ```bash conda install -c conda-forge lammpsio ``` -------------------------------- ### Get total number of snapshots Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Retrieve the total count of snapshots in the file. Note that this operation requires reading the entire file. ```python num_frames = len(traj) ``` -------------------------------- ### Run tests and build documentation Source: https://lammpsio.readthedocs.io/en/stable/install.html Commands to execute the test suite and generate documentation from the source. ```bash python -m pytest ``` ```bash cd doc make html ``` -------------------------------- ### lammpsio.Snapshot(N, box, step=None, num_types=None) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Initializes a new particle configuration snapshot. ```APIDOC ## Constructor: lammpsio.Snapshot ### Description Creates a new Snapshot object to hold data for N particles, the simulation Box, and the timestep. ### Parameters - **N** (int) - Required - Number of particles in configuration. - **box** (Box) - Required - Simulation box. - **step** (int) - Optional - Simulation time step. - **num_types** (int) - Optional - Number of particle types. ### Example ```python snapshot = lammpsio.Snapshot( N=3, box=lammpsio.Box([-5, -5, -5], [5, 5, 5]), step=10 ) ``` ``` -------------------------------- ### Initialize lammpsio and dependencies Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html Import necessary libraries and load a LAMMPS trajectory file for processing. ```python import lammpsio import numpy import numba traj = lammpsio.DumpFile("traj.lammpstrj") ``` -------------------------------- ### Import lammpsio Source: https://lammpsio.readthedocs.io/en/stable/tutorials/analysis_tutorial/analysis_tutorial.html Initial import of the lammpsio library. ```python import lammpsio ``` -------------------------------- ### Initialize a Snapshot Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Create a new Snapshot instance by specifying the number of particles, the simulation box, and the current timestep. ```python snapshot = lammpsio.Snapshot( N=3, box=lammpsio.Box([-5, -5, -5], [5, 5, 5]), step=10 ) ``` -------------------------------- ### Create simulation snapshot Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Initialize a Snapshot object with total atom count and simulation box dimensions. ```python N_total = N_water * atoms_per_water + N_ethanol * atoms_per_ethanol box = lammpsio.Box([0, 0, 0], [L_box, L_box, L_box]) snap = lammpsio.Snapshot(N_total, box, step=0) ``` -------------------------------- ### Importing dependencies Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Required libraries for lattice generation and data file creation. ```python import lammpsio import numpy ``` -------------------------------- ### lammpsio.Box(low, high, tilt=None) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Constructor for creating a new simulation box instance. ```APIDOC ## lammpsio.Box(low, high, tilt=None) ### Description Constructs a new simulation box. The box is defined by its origin (low), the high parameter used to compute edge lengths, and optional tilt factors for triclinic boxes. ### Parameters - **low** (list) - Required - Origin of the box. - **high** (list) - Required - High parameter used to compute edge lengths. - **tilt** (list) - Optional - Tilt factors (xy, xz, yz) for a triclinic box. Defaults to None (orthorhombic). ``` -------------------------------- ### Defining system parameters Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Set particle diameters, bond lengths, and lattice repetition counts. ```python diameter = 1.0 bond_length = 1.5 lattice_spacing = 2 * diameter + bond_length num_repeat = [10, 10, 10] ``` -------------------------------- ### Initialize a DumpFile object Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Create a new DumpFile instance by providing the path to the LAMMPS dump file. ```python traj = lammpsio.DumpFile(filename) ``` -------------------------------- ### Generate XYZ and PACKMOL input files Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Writes coordinate data to XYZ files and creates a configuration file for PACKMOL using simulation parameters. ```python # write water xyz file with open("water.xyz", "w") as f: f.write(f"{len(water_data["coords"]["data"])}\n") f.write("Angstrom\n") for cords, types in zip(water_data["coords"]["data"], water_data["types"]["data"]): id, x, y, z = cords id, _type = types f.write(f"{_type} {x} {y} {z} \n") # write ethanol xyz file with open("ethanol.xyz", "w") as f: f.write(f"{len(ethanol_data["coords"]["data"])}\n") f.write("Angstrom\n") for cords, types in zip(ethanol_data["coords"]["data"], ethanol_data["types"]["data"]): id, x, y, z = cords id, _type = types f.write(f"{_type} {x} {y} {z} \n") # create PACKMOL input file with open("pack.inp", "w") as f: lines = [ "tolerance 2.0\n", "output mixture.xyz\n", "filetype xyz\n", f"pbc 0 0 0 {L_box} {L_box} {L_box}\n", "structure water.xyz\n", f" number {N_water}\n", f" inside box 0 0 0 {L_box} {L_box} {L_box}\n", "end structure\n", "structure ethanol.xyz\n", f" number {N_ethanol}\n", f" inside box 0 0 0 {L_box} {L_box} {L_box}\n", "end structure\n" ] f.writelines(lines) ``` -------------------------------- ### Importing necessary packages Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Initial imports required for handling JSON data, subprocess execution, lammpsio operations, and numerical arrays. ```python import json import subprocess import lammpsio import numpy ``` -------------------------------- ### Defining system parameters Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Setting the number of molecules and the cubic box dimensions for the mixture. ```python N_water = 125 N_ethanol = 125 L_box = 25 ``` -------------------------------- ### lammpsio.Box.from_matrix(low, matrix, force_triclinic=False) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Creates a Box instance from an origin and a box matrix. ```APIDOC ## lammpsio.Box.from_matrix(low, matrix, force_triclinic=False) ### Description Constructs a simulation box from an origin and an upper triangular matrix. ### Parameters - **low** (list) - Required - Origin of the box. - **matrix** (numpy.ndarray) - Required - Box matrix. - **force_triclinic** (bool) - Optional - If True, forces the box to be triclinic even if tilt factors are zero. ``` -------------------------------- ### Unpacking Box Arrays Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Demonstrates how array values are unpacked into box parameters based on the number of elements. ```python x_lo, y_lo, z_lo, x_hi, y_hi, z_hi = value ``` ```python x_lo, y_lo, z_lo, x_hi, y_hi, z_hi, xy, xz, yz = value ``` -------------------------------- ### Execute PACKMOL Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Runs the PACKMOL executable using the generated input file via a subprocess. ```python subprocess.run("packmol < pack.inp", shell=True, capture_output=True); ``` -------------------------------- ### Creating and Accessing a LabelMap Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.LabelMap.html Initialize a LabelMap with a dictionary of type IDs to labels and perform direct lookups. ```python type_label = lammpsio.topology.LabelMap({1: "A", 2: "B"}) ``` ```python assert type_label[1] == "A" ``` -------------------------------- ### Reorder particles in a snapshot Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Demonstrates how to reorder particle data in a snapshot to match bond ordering, accounting for 1-based indexing in LAMMPS versus 0-based indexing in Python. ```python snapshot.bonds = lammpsio.Bonds(N=3, num_types=1) bond_id = [1, 3, 2] members = [[1, 2], [2, 3], [3, 1]] typeid = [1, 1, 1] snapshot.bonds.id = bond_id snapshot.bonds.typeid = typeid snapshot.bonds.members = members snapshot.bonds.reorder(numpy.sort(numpy.array(bond_id)) - 1, check_order=True) ``` -------------------------------- ### Constructing Boxes from Matrices Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Create simulation boxes from an origin and a matrix, with options to force triclinic behavior. ```python box = lammpsio.Box.from_matrix( low=[0, 0, 0], matrix=[ [1, 0, 0], [0, 1, 0], [0, 0, 1] ], force_triclinic=True) ``` ```python box = lammpsio.Box.from_matrix( low=[0, 0, 0], matrix=[ [1, 1.0, -2.0], [0, 1, 0.5], [0, 0, 1] ]) ``` -------------------------------- ### Benchmark Numba-accelerated analysis Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html Uses the %%timeit magic command to measure the execution time of the JIT-compiled function over a trajectory. ```python %%timeit -n 100 -r 3 rg_sqr = [] for snapshot in traj: pos = snapshot.position + 2 * snapshot.box.high[0] * snapshot.image rg_sqr.append(compute_rg_numba(pos)) ``` -------------------------------- ### Create a LAMMPS data file Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DataFile.html Use the create method to write a snapshot to a new LAMMPS data file. ```python snapshot = lammpsio.Snapshot( N=3, box=lammpsio.Box([-5, -5, -5], [5, 5, 5]), step=10 ) data = lammpsio.DataFile.create(tmp_path / "atoms.data", snapshot) ``` -------------------------------- ### Create system dihedrals Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Processes ethanol dihedral topology to populate the lammpsio Dihedrals object, noting that water molecules are excluded. ```python # get dihedral topology from ethanol JSON data ethanol_dihedrals = ethanol_data["dihedrals"]["data"] # calculate total number of dihedrals in the system N_dihedrals = N_ethanol * len(ethanol_dihedrals) # get dihedral members and types for all ethanol molecules using our helper function dihedral_members, dihedral_types = get_topology( topology_data=[ethanol_data["dihedrals"]["data"]], num_repeats=[N_ethanol], atoms_per_molecule=[atoms_per_ethanol], ) # get unique dihedral types unique_dihedrals = set(dihedral_types) # create and assign the Dihedrals object snap.dihedrals = lammpsio.Dihedrals(N=N_dihedrals, num_types=len(unique_dihedrals)) snap.dihedrals.members = dihedral_members snap.dihedrals.type_label = lammpsio.LabelMap({idx+1: dihedral_type for idx, dihedral_type in enumerate(unique_dihedrals)}) snap.dihedrals.typeid = [snap.dihedrals.type_label.inverse[dihedral_type] for dihedral_type in dihedral_types] ``` -------------------------------- ### lammpsio.DumpFile.create(filename, schema, snapshots) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Creates a new LAMMPS dump file from a list of snapshots. ```APIDOC ## lammpsio.DumpFile.create ### Description Writes one or more snapshots to a new LAMMPS dump file using the provided schema. ### Parameters - **filename** (str) - Required - Path to the new dump file. - **schema** (dict) - Required - Schema defining the column mapping. - **snapshots** (list) - Required - One or more Snapshot objects to write. ``` -------------------------------- ### lammpsio.Dihedrals(N, num_types=None) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Constructor for the Dihedrals class. Initializes a new set of dihedral connections. ```APIDOC ## lammpsio.Dihedrals(N, num_types=None) ### Description Initializes a new Dihedrals object to manage connections between particles. ### Parameters - **N** (int) - Required - Number of dihedrals. - **num_types** (int) - Optional - Number of dihedral types. Defaults to None, determined from unique typeids. ``` -------------------------------- ### Apply Numba JIT to a function Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html Wraps an existing function with numba.njit to enable just-in-time compilation. ```python compute_rg_numba = numba.njit(compute_rg) ``` -------------------------------- ### lammpsio.DataFile.create Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DataFile.html Creates a new LAMMPS data file from a provided snapshot. ```APIDOC ## DataFile.create(filename, snapshot, atom_style=None) ### Description Creates a LAMMPS data file from a snapshot. ### Parameters - **filename** (str) - Required - Path to the data file. - **snapshot** (Snapshot) - Required - The snapshot object to write to the file. - **atom_style** (str) - Optional - The LAMMPS atom style to use. Defaults to None, which infers the style from the snapshot. ### Returns - **DataFile** - The object representing the newly created data file. ``` -------------------------------- ### Constructing Simulation Boxes Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Create orthorhombic or triclinic simulation boxes using the Box constructor. ```python box = lammpsio.Box(low=[-5, -5, -5], high=[5, 5, 5]) ``` ```python box = lammpsio.Box( low=[-5.0, -5.0, -5.0], high=[5.0, 5.0, 5.0], tilt=[1.0, -2.0, 0.5] ) ``` -------------------------------- ### Casting Arrays to Box Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Create a simulation box by casting a 6-element array. ```python box = lammpsio.Box.cast([-5.0, -5.0, -5.0, 5.0, 5.0, 5.0]) ``` -------------------------------- ### Initialize a LAMMPS Snapshot Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Calculate the total number of particles and instantiate the Snapshot object with the specified box dimensions. ```python num_cells = numpy.prod(num_repeat) num_per_unit_cell = unit_cell_coords.shape[0] snap = lammpsio.Snapshot(N=num_cells * num_per_unit_cell, box=box) ``` -------------------------------- ### lammpsio.LabelMap Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.LabelMap.html The LabelMap class constructor initializes a mapping between integer type IDs and string type labels. ```APIDOC ## class lammpsio.LabelMap(map=None) ### Description Initializes a map between integer type IDs and string type names. This is useful for tracking the meaning of type IDs and for interconverting with formats like HOOMD GSD. ### Parameters - **map** (dict) - Optional - A dictionary mapping type IDs (int) to type labels (str). ``` -------------------------------- ### Create bonds in lammpsio Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Bonds.html Initialize a Bonds object and define its IDs, type IDs, and member connections. ```python bonds = lammpsio.topology.Bonds(N=3, num_types=1) bonds.id = [1, 2, 3] bonds.typeid = [1, 1, 1] bonds.members = [[1, 2], [2, 3], [1, 3]] ``` -------------------------------- ### Create Dihedrals Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Initialize a Dihedrals object with a specified number of connections and types, then populate its properties. ```python dihedrals = lammpsio.topology.Dihedrals(N=2, num_types=2) dihedrals.id = [1, 2] dihedrals.typeid = [1, 2] dihedrals.members = [ [1, 2, 3, 4], [2, 3, 4, 5], ] ``` -------------------------------- ### Calculate bond topology and unique types Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Calculate total bonds and generate topology lists for all molecules in the system. ```python # calculate total number of bonds N_bonds = N_water * len(water_bond) + N_ethanol * len(ethanol_bond) # get bond topology for all molecules using our helper function bond_members, bond_types = get_topology( topology_data=[water_data["bonds"]["data"], ethanol_data["bonds"]["data"]], num_repeats=[N_water, N_ethanol], atoms_per_molecule=[atoms_per_water, atoms_per_ethanol], ) # get unique bond types unique_bonds = set(bond_types) ``` -------------------------------- ### Save molecular system to LAMMPS data file Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Uses the lammpsio.DataFile.create method to write the snapshot to a specified file path. ```python # Write to LAMMPS data file lammpsio.DataFile.create( filename="ethanol_water_mixture.data", snapshot=snap ) ``` -------------------------------- ### has_charge() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized charge data. ```APIDOC ## has_charge() ### Description Returns True if charges have been initialized for the configuration, otherwise False. ### Returns - **bool** - True if initialized. ``` -------------------------------- ### Create a new DumpFile Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Generate a new LAMMPS dump file from a list of snapshots using a specified schema. ```python schema = {"id":0, "position":(1, 2, 3), "image": (4, 5, 6)} lammpsio.DumpFile.create(filename, schema, snapshots) ``` -------------------------------- ### has_bonds() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized bond data. ```APIDOC ## has_bonds() ### Description Returns True if bonds are initialized and there is at least one bond present. ### Returns - **bool** - True if initialized and non-empty. ``` -------------------------------- ### Define Bonds in Snapshot Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Initialize the Bonds object and assign type IDs to all bonds in the system. ```python snap.bonds = lammpsio.Bonds(N=num_cells, num_types=1) snap.bonds.typeid = numpy.ones(snap.bonds.N) ``` -------------------------------- ### has_members() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Checks if the configuration has connection members initialized. ```APIDOC ## has_members() ### Description Returns True if particle members have been initialized, otherwise False. ``` -------------------------------- ### Converting to HOOMD-blue Convention Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Convert a LAMMPS simulation box to the HOOMD-blue matrix convention. ```python box = lammpsio.Box([-5, -5, -5], [5, 5, 5]).to_hoomd_convention() ``` -------------------------------- ### Convert HOOMD-blue box to LAMMPS convention Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Demonstrates using from_hoomd_convention to transform box data from the HOOMD-blue format to the LAMMPS format. ```python hoomd_box = numpy.array([10, 10, 10, 0, 0, 0]) lammps_box = lammpsio.Box.from_hoomd_convention( box_data=hoomd_box, low=[0, 0, 0] ) ``` -------------------------------- ### lammpsio.DumpFile(filename, schema=None, sort_ids=True, copy_from=None) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Initializes a new DumpFile object to read a LAMMPS dump file. The schema is automatically deduced from the file header unless manually specified. ```APIDOC ## lammpsio.DumpFile ### Description Initializes a DumpFile object for reading LAMMPS trajectory data. The object is iterable, allowing access to individual snapshots. ### Parameters - **filename** (str) - Required - Path to the dump file. - **schema** (dict) - Optional - Mapping of data keys to column indexes. - **sort_ids** (bool) - Optional - Whether to sort particles by ID in each snapshot (default: True). - **copy_from** (Snapshot) - Optional - Reference snapshot to copy missing topology information from. ``` -------------------------------- ### Create Snapshot from GSD frame Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Convert a HOOMD GSD frame into a lammpsio.Snapshot object. ```python frame = gsd.hoomd.Frame() frame.configuration.box = [10, 10, 10, 0, 0, 0] frame.particles.N = 3 snapshot, type_map = lammpsio.Snapshot.from_hoomd_gsd(frame) ``` -------------------------------- ### Create system angles Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Extracts angle topology from water and ethanol data to populate the lammpsio Angles object. ```python # get angle topology from molecule JSON data water_angles = water_data["angles"]["data"] ethanol_angles = ethanol_data["angles"]["data"] # calculate total number of angles N_angles = N_water * len(water_angles) + N_ethanol * len(ethanol_angles) # get angle members and types for all molecules using our helper function angle_members, angle_types = get_topology( topology_data=[water_data["angles"]["data"], ethanol_data["angles"]["data"]], num_repeats=[N_water, N_ethanol], atoms_per_molecule=[atoms_per_water, atoms_per_ethanol], ) # get unique angle types unique_angles = set(angle_types) # create and assign the Angles object snap.angles = lammpsio.Angles(N=N_angles, num_types=len(unique_angles)) snap.angles.members = angle_members snap.angles.type_label = lammpsio.LabelMap({idx+1:angle_type for idx, angle_type in enumerate(unique_angles)}) snap.angles.typeid = [snap.angles.type_label.inverse[angle_type] for angle_type in angle_types] ``` -------------------------------- ### Read a compressed dump file Source: https://lammpsio.readthedocs.io/en/stable/tutorials/analysis_tutorial/analysis_tutorial.html Load a LAMMPS trajectory file in gzip format. ```python dump_file = lammpsio.DumpFile("traj.lammpstrj.gz") ``` -------------------------------- ### has_mass() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized mass data. ```APIDOC ## has_mass() ### Description Returns True if masses have been initialized for the configuration, otherwise False. ### Returns - **bool** - True if initialized. ``` -------------------------------- ### Assign bond connectivity to snapshot Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Create and assign the Bonds object with connectivity, labels, and type IDs. ```python snap.bonds = lammpsio.Bonds(N=N_bonds, num_types=len(unique_bonds)) snap.bonds.members = bond_members snap.bonds.type_label = lammpsio.LabelMap({idx+1:bond_type for idx, bond_type in enumerate(unique_bonds)}) snap.bonds.typeid = [snap.bonds.type_label.inverse[bond_type] for bond_type in bond_types] ``` -------------------------------- ### Process snapshots in parallel Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Utilize the multiprocessing module to map a processing function across snapshots in the trajectory. ```python import multiprocessing def process_snapshot(snapshot): return snapshot.N if __name__ == '__main__': num_workers = max(2, multiprocessing.cpu_count()) with multiprocessing.Pool(num_workers) as p: num_particles = p.map(process_snapshot, traj) print(num_particles) ``` -------------------------------- ### reorder(order, check_order=True) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Reorders the connections in place. ```APIDOC ## reorder(order, check_order=True) ### Description Reorders the connections in place based on the provided index list. ### Parameters - **order** (list) - Required - New order of indexes. - **check_order** (bool) - Optional - If True, validates the new order before applying. ``` -------------------------------- ### has_molecule() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized molecule tags. ```APIDOC ## has_molecule() ### Description Returns True if molecule tags have been initialized for the configuration, otherwise False. ### Returns - **bool** - True if initialized. ``` -------------------------------- ### Box.from_hoomd_convention Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Creates a LAMMPS simulation box from HOOMD-blue convention data. ```APIDOC ## Box.from_hoomd_convention(box_data, low=None, force_triclinic=False, dimensions=None) ### Description Cast a simulation box from the HOOMD-blue convention to the LAMMPS convention. ### Parameters - **box_data** (list) - Required - An array of box dimensions in HOOMD-blue convention. - **low** (list) - Optional - Origin of the box. If None, the box is centered at the origin. Default is None. - **force_triclinic** (bool) - Optional - If True, forces the box to be triclinic even if the tilt factors are zero. Default is False. - **dimensions** (int) - Optional - The number of dimensions of the box. If None, it is inferred from the box data. Default is None. ### Returns - **box** (Box) - A simulation box in LAMMPS convention. ``` -------------------------------- ### Save configuration to LAMMPS data file Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Writes the current snapshot to a LAMMPS-compatible data file using the molecular atom style. ```python lammpsio.DataFile.create( filename="dimer_lattice.data", snapshot=snap, atom_style="molecular" ) ``` -------------------------------- ### has_id() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Checks if the configuration has connection IDs initialized. ```APIDOC ## has_id() ### Description Returns True if connection IDs have been initialized, otherwise False. ``` -------------------------------- ### Loading molecular structure data Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Reading atomic coordinates and topological information from JSON molecule files. ```python with open("water.json", "r") as f: water_data = json.load(f) with open("ethanol.json", "r") as f: ethanol_data = json.load(f) ``` -------------------------------- ### Iterate over snapshots Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Use the DumpFile object as an iterator to process each snapshot in the trajectory. ```python for snapshot in traj: print(snapshot.step) ``` -------------------------------- ### Configure Bond Members Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Define bond connections between consecutive particle IDs for each dimer. ```python snap.bonds.members = [[2 * i + 1, 2 * i + 2] for i in range(snap.bonds.N)] ``` -------------------------------- ### from_hoomd_gsd(frame) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Creates a Snapshot object from a HOOMD GSD frame. ```APIDOC ## Method: from_hoomd_gsd ### Description Creates a Snapshot from a HOOMD GSD frame. ### Parameters - **frame** (gsd.hoomd.Frame) - Required - HOOMD GSD frame to convert. ### Returns - **Snapshot** - The created snapshot. - **dict** - A map from the Snapshot.typeid to the HOOMD type. ``` -------------------------------- ### to_hoomd_gsd(type_map=None) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Converts the current Snapshot into a HOOMD GSD frame. ```APIDOC ## Method: to_hoomd_gsd ### Description Creates a HOOMD GSD frame from the current Snapshot. ### Parameters - **type_map** (dict) - Optional - A map from the Snapshot.typeid to a HOOMD type. ### Returns - **gsd.hoomd.Frame** - The converted GSD frame. ``` -------------------------------- ### Export snapshot to GSD format Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Uses the gsd library to write the snapshot to a GSD file after applying necessary coordinate transformations. ```python import gsd.hoomd with gsd.hoomd.open("dimer_lattice.gsd", "w") as f: f.append(snap.to_hoomd_gsd()) ``` -------------------------------- ### to_matrix() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Converts the box to an origin and an upper triangular matrix. ```APIDOC ## to_matrix() ### Description Converts the current box instance into an origin and an upper triangular matrix in LAMMPS style. ``` -------------------------------- ### has_property() methods Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Methods to check if specific particle properties have been initialized. ```APIDOC ## Methods: has_* ### Description Checks if specific configuration data (e.g., position, id, mass) has been initialized. Returns True if initialized, False otherwise. ### Available Methods - has_angles() - has_bonds() - has_charge() - has_dihedrals() - has_id() - has_image() - has_impropers() - has_mass() - has_molecule() - has_position() - has_typeid() - has_velocity() ``` -------------------------------- ### Defining the simulation box Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Create the LAMMPS box object by repeating the unit cell vectors. ```python box_matrix = (unit_cell_vectors * num_repeat).T box = lammpsio.Box.from_matrix(low=[0, 0, 0], matrix=box_matrix) ``` -------------------------------- ### to_hoomd_convention() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Converts the box to the HOOMD-blue convention. ```APIDOC ## to_hoomd_convention() ### Description Converts the current LAMMPS simulation box into the HOOMD-blue convention format. ``` -------------------------------- ### Dihedrals.reorder(order, check_order=True) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Reorders the connections in place. ```APIDOC ## Dihedrals.reorder(order, check_order=True) ### Description Reorders the connections in place based on the provided index order. ### Parameters - **order** (list) - Required - New order of indexes. - **check_order** (bool) - Optional - If True, validates the new order before applying. ``` -------------------------------- ### Access and check per-particle properties Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Per-particle arrays are lazily initialized upon access. Use the has_ methods to verify if a specific attribute has been allocated. ```python snapshot.position = [[0, 0, 0], [1, -1, 1], [1.5, 2.5, -3.5]] snapshot.typeid[2] = 2 if not snapshot.has_mass(): snapshot.mass = [2., 2., 10.] ``` -------------------------------- ### Assign type IDs and masses Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Map atom types to integer IDs and assign atomic masses to the snapshot. ```python # assign type IDs snap.typeid = [snap.type_label.inverse[t] for t in types] # assign masses water_mass = [mass for _, mass in water_data["masses"]["data"]] ethanol_mass = [mass for _, mass in ethanol_data["masses"]["data"]] snap.mass = water_mass * N_water + ethanol_mass * N_ethanol ``` -------------------------------- ### Angles.has_members() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Checks if the configuration has initialized connection members. ```APIDOC ## has_members() ### Description Checks if configuration has connection members. ### Returns - **bool** - True if particle members have been initialized. ``` -------------------------------- ### Create Angles Topology Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Initialize an Angles object and define its properties including IDs, type IDs, and particle members. ```python angles = lammpsio.topology.Angles(N=3, num_types=1) angles.id = [1, 2, 3] angles.typeid = [1, 1, 1] angles.members = [[1, 2, 3], [2, 3, 1], [3, 1, 2]] ``` -------------------------------- ### Converting Box to Matrix Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Extract the origin and the upper triangular matrix from a box instance. ```python low, matrix = box.to_matrix() ``` -------------------------------- ### Configure LabelMap for GSD export Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Maps numeric particle and bond type IDs to alphanumeric labels required for HOOMD-blue GSD files. ```python snap.type_label = lammpsio.LabelMap({1: "A", 2: "B"}) snap.bonds.type_label = lammpsio.LabelMap({1: "dimer"}) ``` -------------------------------- ### Dihedrals.has_members() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Checks if the configuration has initialized connection members. ```APIDOC ## Dihedrals.has_members() ### Description Checks if particle members have been initialized. ### Returns - **bool** - True if particle members are initialized. ``` -------------------------------- ### DataFile object representation Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html The output returned after successfully creating a LAMMPS data file. ```text ``` -------------------------------- ### Extract bond data Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Extract bond topology information from loaded molecule data files. ```python water_bond = water_data["bonds"]["data"] ethanol_bond = ethanol_data["bonds"]["data"] ``` -------------------------------- ### Angles.reorder() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Reorders the connections in place. ```APIDOC ## reorder(order, check_order=True) ### Description Reorder the connections in place. ### Parameters - **order** (list) - Required - New order of indexes. - **check_order** (bool) - Optional - If True, validate the new order before applying it. ``` -------------------------------- ### Define atom type labels Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Create a LabelMap to link integer type IDs to unique atom types. ```python unique_types = set(types) snap.type_label = lammpsio.LabelMap({idx+1: atom_type for idx, atom_type in enumerate(unique_types)}) ``` -------------------------------- ### Literal Python implementation of radius of gyration Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html A standard implementation using explicit loops to calculate the center of mass and radius of gyration squared. ```python def compute_rg(pos): N = pos.shape[0] # Compute center of mass rcm = numpy.zeros(3) for i in range(N): rcm += pos[i] rcm /= N # Compute radius of gyration squared rg_sqr = 0 for i in range(N): dr = pos[i] - rcm rg_sqr += dr[0]**2 + dr[1]**2 + dr[2]**2 rg_sqr /= N return rg_sqr ``` -------------------------------- ### lammpsio.DataFile.read Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DataFile.html Reads a LAMMPS data file and returns a snapshot object. ```APIDOC ## DataFile.read() ### Description Reads the contents of the associated LAMMPS data file into a snapshot object. The atom_style is read from the file or must be specified manually. ### Returns - **Snapshot** - The snapshot object populated from the data file. ``` -------------------------------- ### Access snapshots randomly Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DumpFile.html Convert the trajectory into a list to enable random access to specific snapshots. ```python snapshots = [snap for snap in traj] print(snapshots[3].step) ``` -------------------------------- ### lammpsio.Box.cast(value) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html Creates a Box instance from a 6-element or 9-element array. ```APIDOC ## lammpsio.Box.cast(value) ### Description Creates a simulation box by casting an array. If the input has 6 elements, it is treated as an orthorhombic box; if 9 elements, it is treated as a triclinic box. ### Parameters - **value** (list) - Required - 6-element or 9-element array representing the box. ``` -------------------------------- ### reorder(order, check_order=True) Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Reorders the particles in the snapshot in place based on the provided index list. ```APIDOC ## reorder(order, check_order=True) ### Description Reorders the particles in the snapshot in place. This is useful for aligning particle data with other structures like bonds. ### Parameters - **order** (list) - Required - New order of indexes. - **check_order** (bool) - Optional - If True, validate the new order before applying it. ``` -------------------------------- ### has_typeid() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Checks if the configuration has connection type IDs initialized. ```APIDOC ## has_typeid() ### Description Returns True if connection typeids have been initialized, otherwise False. ``` -------------------------------- ### Set Particle Positions Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Iterate through unit cells to calculate and assign particle positions, shifting them relative to the box origin. ```python for i, unit_cell_idx in enumerate(numpy.ndindex(*num_repeat)): first = i * num_per_unit_cell last = first + num_per_unit_cell snap.position[first:last] = ( numpy.array(unit_cell_idx) * lattice_spacing + unit_cell_coords ) snap.position += snap.box.low ``` -------------------------------- ### has_velocity() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized velocity data. ```APIDOC ## has_velocity() ### Description Returns True if velocities have been initialized for the configuration, otherwise False. ### Returns - **bool** - True if initialized. ``` -------------------------------- ### has_angles() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized angle data. ```APIDOC ## has_angles() ### Description Returns True if angles are initialized and there is at least one angle present. ### Returns - **bool** - True if initialized and non-empty. ``` -------------------------------- ### lammpsio.Bonds Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Bonds.html The Bonds class represents bond connections between particles. It allows for the initialization of bond counts and types, and provides access to bond properties like IDs, members, and type IDs. ```APIDOC ## class lammpsio.Bonds(N, num_types=None) ### Description Initializes a new Bonds object to manage bond connections between particles. ### Parameters - **N** (int) - Required - Number of bonds. - **num_types** (int) - Optional - Number of bond types. Defaults to None. ### Attributes - **N** (int) - Number of connections. - **id** (numpy.ndarray) - Unique identifiers for bonds. - **members** (numpy.ndarray) - Connection members. - **num_types** (int) - Number of connection types. - **type_label** (LabelMap) - Labels of connection type IDs. - **typeid** (numpy.ndarray) - Connection type IDs. ### Methods - **has_id()** (bool) - Returns True if connection IDs are initialized. - **has_members()** (bool) - Returns True if connection members are initialized. - **has_typeid()** (bool) - Returns True if connection type IDs are initialized. - **reorder(order, check_order=True)** - Reorders connections in place based on the provided index list. ``` -------------------------------- ### Timing the literal implementation Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html Measures the execution time of the literal radius of gyration function over a trajectory. ```python %%timeit -n 100 -r 3 rg_sqr = [] for snapshot in traj: pos = snapshot.position + 2 * snapshot.box.high[0] * snapshot.image rg_sqr.append(compute_rg(pos)) ``` -------------------------------- ### Dihedrals.has_id() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Checks if the configuration has initialized connection IDs. ```APIDOC ## Dihedrals.has_id() ### Description Checks if connection IDs have been initialized. ### Returns - **bool** - True if connection IDs are initialized. ``` -------------------------------- ### Assign Particle Types and Masses Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Replicate unit cell type IDs and masses across the total number of cells. ```python snap.typeid = numpy.tile(unit_cell_typeids, num_cells) snap.mass = numpy.tile(unit_cell_mass, num_cells) ``` -------------------------------- ### Read a LAMMPS data file Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.DataFile.html Use the read method to load a LAMMPS data file into a snapshot object. ```python snap = data.read() ``` -------------------------------- ### Convert Snapshot to GSD frame Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Export a Snapshot object to a HOOMD GSD frame for use with the HOOMD-blue simulation package. ```python frame = snapshot.to_hoomd_gsd() ``` -------------------------------- ### Timing the NumPy implementation Source: https://lammpsio.readthedocs.io/en/stable/tutorials/numba_tutorial/numba_tutorial.html Measures the execution time of the vectorized NumPy function over a trajectory. ```python %%timeit -n 100 -r 3 rg_sqr = [] for snapshot in traj: pos = snapshot.position + 2 * snapshot.box.high[0] * snapshot.image rg_sqr.append(compute_rg_numpy(pos)) ``` -------------------------------- ### Calculate mean squared displacement Source: https://lammpsio.readthedocs.io/en/stable/tutorials/analysis_tutorial/analysis_tutorial.html Compute and plot the MSD using unwrapped particle positions. ```python msd = freud.msd.MSD(box) msd.compute(positions) msd.plot(); plt.show(); ``` -------------------------------- ### Using Inverse Mapping Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.LabelMap.html Access the inverse attribute to map from a string type label back to its integer type ID. ```python assert type_label.inverse["B"] == 2 ``` -------------------------------- ### has_impropers() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized improper data. ```APIDOC ## has_impropers() ### Description Returns True if impropers are initialized and there is at least one improper present. ### Returns - **bool** - True if initialized and non-empty. ``` -------------------------------- ### has_dihedrals() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized dihedral data. ```APIDOC ## has_dihedrals() ### Description Returns True if dihedrals are initialized and there is at least one dihedral present. ### Returns - **bool** - True if initialized and non-empty. ``` -------------------------------- ### has_typeid() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Snapshot.html Checks if the configuration has initialized type IDs. ```APIDOC ## has_typeid() ### Description Returns True if types have been initialized for the configuration, otherwise False. ### Returns - **bool** - True if initialized. ``` -------------------------------- ### Define topology parsing helper function Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html A helper function to parse topology objects and handle replication across multiple molecules. ```python def get_topology(topology_data, num_repeats, atoms_per_molecule): """Get topology for a mixture of molecules. Args: topology_data: List of topology data for each molecule type from JSON molecule files num_repeats: List of number of molecules for each molecule type atoms_per_molecule: List of atoms per molecule for each molecule type Returns: members_list: List of member atom indices for each topology item types_list: List of topology type labels for each topology item """ members_list = [] types_list = [] if len(topology_data) != len(num_repeats) or len(topology_data) != len(atoms_per_molecule): raise ValueError("Length of topology_data, num_repeats, and atoms_per_molecule must be the same.") offset = 0 for topology, repeats, atoms_per_mol in zip(topology_data, num_repeats, atoms_per_molecule): for _ in range(repeats): for topology_item in topology: topology_type = topology_item[0] member_indices = topology_item[1:] types_list.append(topology_type) members_list.append([offset + idx for idx in member_indices]) offset += atoms_per_mol return members_list, types_list ``` -------------------------------- ### Read packed coordinates Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Load molecular coordinates from an XYZ file and extract positions and types. ```python data = numpy.genfromtxt('mixture.xyz', skip_header=2, dtype=[('type', 'U8'), ('x', float), ('y', float), ('z', float)]) positions = numpy.column_stack((data['x'], data['y'], data['z'])) types = data['type'] atoms_per_water = len(water_data["coords"]["data"]) atoms_per_ethanol = len(ethanol_data["coords"]["data"]) ``` -------------------------------- ### Angles.has_id() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Checks if the configuration has initialized connection IDs. ```APIDOC ## has_id() ### Description Checks if configuration has connection IDs. ### Returns - **bool** - True if connection IDs have been initialized. ``` -------------------------------- ### Create improper dihedrals Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Initializes an Impropers object with a specified number of dihedrals and types, then populates the connection properties. ```python impropers = lammpsio.topology.Impropers(N=2, num_types=2) impropers.id = [1, 2] impropers.typeid = [1, 2] impropers.members = [ [1, 2, 3, 4], [2, 3, 4, 5], ] ``` -------------------------------- ### Dihedrals.has_typeid() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Dihedrals.html Checks if the configuration has initialized connection type IDs. ```APIDOC ## Dihedrals.has_typeid() ### Description Checks if connection type IDs have been initialized. ### Returns - **bool** - True if connection type IDs are initialized. ``` -------------------------------- ### lammpsio.Angles Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Constructor for the Angles class to define angle connections between particles. ```APIDOC ## class lammpsio.Angles(N, num_types=None) ### Description Initializes angle connections between particles. All values follow the LAMMPS 1-indexed convention. ### Parameters - **N** (int) - Required - Number of angles. - **num_types** (int) - Optional - Number of angle types. Defaults to None (determined from unique typeids). ``` -------------------------------- ### Unwrap particle positions Source: https://lammpsio.readthedocs.io/en/stable/tutorials/analysis_tutorial/analysis_tutorial.html Extract and unwrap particle positions from the trajectory for further analysis. ```python import numpy for i, snapshot in enumerate(dump_file): # allocate memory for whole trajectory on first pass if i == 0: positions = numpy.zeros((len(dump_file), snapshot.N, 3), dtype=float) # unwrap each snapshot using freud box = freud.box.Box.from_box(snapshot.box.to_hoomd_convention()) positions[i] = box.unwrap(snapshot.position, snapshot.image) ``` -------------------------------- ### Calculate radial distribution function Source: https://lammpsio.readthedocs.io/en/stable/tutorials/analysis_tutorial/analysis_tutorial.html Compute g(r) using freud by converting LAMMPS box data to HOOMD-blue convention. ```python import freud import matplotlib.pyplot as plt rdf = freud.density.RDF(bins=30, r_max=3.0) for snapshot in dump_file: box = freud.box.Box.from_box(snapshot.box.to_hoomd_convention()) rdf.compute((box, snapshot.position), reset=False) rdf.plot(); plt.show(); ``` -------------------------------- ### Defining the unit cell Source: https://lammpsio.readthedocs.io/en/stable/tutorials/dimer_lattice_tutorial.html Specify vectors, coordinates, type IDs, and masses for the unit cell structure. ```python unit_cell_vectors = numpy.array([ [1, 0, 0], [0, 1, 0], [0, 0, 1] ]) * lattice_spacing unit_cell_coords = numpy.array([ [0, 0, 0], [bond_length, 0, 0] ]) unit_cell_typeids = [1, 2] unit_cell_mass = [1.0, 1.5] ``` -------------------------------- ### Angles.has_typeid() Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Angles.html Checks if the configuration has initialized connection type IDs. ```APIDOC ## has_typeid() ### Description Checks if configuration has connection typeids. ### Returns - **bool** - True if connection typeids have been initialized. ``` -------------------------------- ### lammpsio.Impropers Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Impropers.html Constructor for the Impropers class to define improper dihedral connections. ```APIDOC ## class lammpsio.Impropers(N, num_types=None) ### Description Initializes a new collection of improper dihedral connections. ### Parameters - **N** (int) - Required - Number of improper dihedrals. - **num_types** (int) - Optional - Number of improper dihedral types. ``` -------------------------------- ### Assign atomic positions Source: https://lammpsio.readthedocs.io/en/stable/tutorials/ethanol-water-tutorial/ethanol_water_mixture.html Assign the packed coordinates to the snapshot position attribute. ```python snap.position = positions ``` -------------------------------- ### Representing Box Matrices Source: https://lammpsio.readthedocs.io/en/stable/generated/lammpsio.Box.html The structure of the upper triangular matrix used in LAMMPS style. ```python [[lx, xy, xz], [0, ly, yz], [0, 0, lz]] ```