Getting started¶
Installation¶
PoreReax targets Python 3.12+ and is tested on Linux (x86_64) and macOS (arm64). The supported platforms require to run OVITO in combination with multiprocessing for analysis. Running the generated simulations requires a separate LAMMPS installation with the REAXFF package.
python -m pip install porereax
To install the current development version directly from GitHub instead:
python -m pip install git+https://github.com/ProkopK/PoreReax.git@develop
Quickstart¶
This is a minimal example to get started with PoreReax. It covers everything from creating a simulation to analysing the output. For a more detailed explanation of the workflow, see Typical workflow.
1) Create a simulation workflow¶
To create a simulation from a GROMACS structure file (.gro), run the following code. This will generate system.data, run_0.lmp, run_0.job, and ana.py. Define your system matching to your .gro file and set a force field with set_force_field(). Run the simulation with LAMMPS and afterwards analyse the output with the ana.py script.
from porereax import Simulate
# Set up a dictionary to translate GRO atom types to ReaxFF
# atom types as well as masses and charges
gro_lib = {"OM": "O", "OW": "O", "Si": "Si", "HW": "H", "MW": ""}
gro_charges = {"OM": -0.64, "OW": -1.1128, "Si": 1.28, "HW": 0.5564}
atom_masses = {"Si": 28.086, "O": 15.9994, "H": 2.016}
# Create a simulation object
sim = Simulate(gro_lib, gro_charges, atom_masses, structure_file="system.gro")
sim.set_force_field("reax.ffield")
sim.add_sim(type="nvt", nsteps=10000, temp=300)
# Generate the simulation files
sim.generate()
2) Analyse simulation output¶
To run the analysis use the ana.py script generated in the previous step or run the following code. This code will sample the molecule structure, the Si-O-Si angle distribution and the 2D density of O-H bonds of water, and save the results in molecule_structure.obj, angle_Si-O-Si.obj and density_water_2d_yz.obj.
from porereax import Sample
atom_lib = {"Si": 1, "O": 2, "H": 3}
atom_masses = {"Si": 28.086, "O": 15.9994, "H": 2.016}
sampler = Sample(atom_lib, atom_masses, "run_0.lammpstrj", "run_0.bonds")
sampler.add_molecule_structure_sampling("molecule_structure")
sampler.add_angle_sampling(
"angle_Si-O-Si",
atoms=[{"atom": "O", "bonds": ["Si", "Si"]}],
)
sampler.add_bond_density_sampling(
name_out="density_water_2d_yz",
bonds=[
{"bond": "H-O", "bonds_B": ["H"]},
],
dimension="Cartesian2D",
direction="yz",
)
sampler.sample()
3) Visualise results¶
To plot the results, run the following code to plot the results of the previous step.
from porereax import plot_data
plot_data("molecule_structure.obj")
plot_data("angle_Si-O-Si.obj")
plot_data("density_water_2d_yz.obj")
Results of the quickstart example: molecule structure, angle distribution, and a 2D density.¶