Examples#

List simulation examples (mostly in order of increasing complexity).

The simulations in the examples are very short to ensure fast execution; however, you might want to make them longer.

When testing is performed, the files generated by the example scripts are removed, so rename or move if you want to keep any such files.

Basic#

  • minimal.py : Minimal example simulating a single component Lennard-Jones (LJ) system using the NVT integrator.

Atomistic models#

  • bcc_lattice.py : How to set up other initial structures (bcc lattice of LJ particles).

  • D2.py : Simulating a 2D system (Lennard-Jones particle in a hexagonal lattice).

  • D4.py : Simulating a 4D system

  • D8.py : Simulating a 8D system (harmonic repulsions)

  • kablj.py : Simulating the Kob-Andersen binary LJ mixture. Also showing how to apply a temperature ramp for cooling.

  • zbl.py : Simulation of Cu using universal Ziegler–Biersack–Littmark (ZBL) potential.

  • tethered_particles.py : Simulation of tethered particles.

  • poiseuille.py : Simulation of a nano-scale Poiseuille flow in a slit-pore.

  • yukawa.py : Example of implementing a user-defined potential, exemplified by the Yukawa potential.

  • hydrocorr.py : Calculation of the hydrodynamic correlation function for a LJ liquid

  • lennard_jones_argon.py : Lennard-Jones conversion from Argon units to real units

  • lennard_jones_argon_real_units.py : Simulation of Lennard-Jones Argon using real units

Molecular models#

  • ASD.py : ASymmetric Dumbbells (toy model of toluene).

  • LJchain.py : LJ chains (coarse grained polymer model).

  • LJchain_continue.py : Continuation of LJ chains simulation.

  • molecules.py: Simulation of a star polymer with bond, angle, and dihedral potentials

  • molecules_polydisperse.py: Mixture of different types of molecules, here linear molecules of different length.

  • water.py: Simulation of the SPC/Fw model

Integrators#

  • minimal_NPT.py : Minimal example simulating a single component Lennard-Jones (LJ) system using the NPT integrator.

  • minimal_NVU.py : Minimal example simulating a single component Lennard-Jones (LJ) system using the NVU integrator.

  • quench_restarts_gradient_descent.py : Using the gradient descent integrator to minimize potential energy.

  • NVU_example.py : Example simulating a Kob-Andersen binary Lennard-Jones system using the NVU integrator. Two NVT simulations are performed before hand to gather the constant-potential energy.

  • brownian.py : Brownian dynamics of colloids with harmonic repulsions.

  • active_ornstein_uhlenbeck.py : Purely repulsive active particles forming dense clusters (MIPS).

Post-processing#

The following examples of data analysis scripts need a filename as a commandline argument, e.g. “python3 analyze_structure.py filename”.

  • analyze_structure.py Calculates rdf (radial distribution function) for configurations in filename.h5, and stores it in filename_rdf.pdf and filename_rdf.pkl (a pickle file with the computed data).

  • analyze_dynamics.py Calculates several dynamical properties (mean squared displacement, non-Gaussian parameter, and incoherent intermediate scattering function) from the trajectory stored in filename.h5. Resulting data is stored in filename_dynamics.pkl and plotted in filename_dynamics.pdf.

  • analyze_thermodynamics.py Calculates thermodynamical properties. Results plotted in filename_thermodynamics.pdf.

  • analyze_NVT_thermodynamics.py Calculates thermodynamical properties of a constant NVT simulation.

  • analyze_NpT_thermodynamics.py Calculates thermodynamical properties of a constant NpT simulation.

Other examples of postprocessing. Some of these scripts require the output produced with minimal.py.

  • plot_pkls.h5 Generate a python script which plots data stored in pickle files, as generated eg. by analyze_dynamics.py and analyze_structure.py above.

  • read_scalar_data_from_h5.py : Read data saved by ScalarSaver, eg. potential and kinetic energies

  • calc_rdf_from_h5.py : Read a simulation saved as h5 and calculate the RDF.

  • calc_sq_from_h5.py : Read a simulation saved as h5 and calculate the structure factor S(q).

Runtime analysis#

  • thermodynamics.py : Calculate thermodynamic properties.

  • isochore.py : Performing several simulations (an isochore) in one script.

  • isomorph.py : An isomorph is traced out using the gamma method. Results can be plotted with plot_isomorph.py. The script demonstrates the possibility of keeping the output of the simulation in memory (storage=’memory’), useful when a lot of short simulations are performed.

  • isomorph_forcemethod.py : An isomorph is traced out using the force method. Results can be plotted with plot_isomorph.py.

  • structure_factor.py : Calculate the structure factor of a Lennard-Jones system and plot it.

  • consistency_NPT.py Calcuate several thermodynamic quantities (dP/dT|V, \(\beta\)P, cV, cP, KT) and check consistency of NVT and NPT fluctuations.

  • widoms_particle_insertion.py Widom’s particle insertion method for calculating the chemical potential.

  • evaluator_inverse_powerlaw.py Simulate a Lennard-Jones system and evaluate the inverse power law potential.

  • evaluator_einstein_crystal.py Simulate a Lennard-Jones crystal and evaluate the harmonic tether potential.

Miscellaneous#

  • visualize.py 3D visualization of saved restarts using ovito (needs to be installed). Usage: python3 visualize.py filename.h5

  • write_to_lammps.py : Write a dump file in LAMMPS format. Can be open by external tools like OVITO or VMD.

  • minimal_cpu.py : Like minimal.py but running on the cpu using numba CUDA simulator.

  • xy_model.py : The classical XY model of rotators on a 2D square lattice

  • rubber_cube.py: A rubber cube modeled as particles connected by springs