Relative path

../fullrmc/Examples/molecularTHF/

Description

A cubic box of tetrahydrofuran molecules used to model liquid tetrahydrofuran battery electrolyte x-rays pair distribution function. In this example, it was necessary to use many kinds of move generators in order to be able to converge. TranslationGenerator, TranslationAlongSymmetryAxisGenerator, RotationGenerator, RotationAboutSymmetryAxisGenerator, DistanceAgitationGenerator, AngleAgitationGenerator, and a collection of those using MoveGeneratorCollector are used at some point. Also, different type of selectors are used RandomSelector, DefinedOrderSelector and RecursiveGroupSelector with different fitting modes (recur, refine and explore). This example was used to generate the simulation video as seen in the online documentation.

Files

  1. create_pdb.py: Script used to create initial configuration.
  2. thf.pdb: The initial configuration input file.
  3. thf_pdf.exp: The x-rays experimental pair distribution function data.
  4. run.py: The script file used to run the simulation.
  5. plot.py: The script file to plot the last saved engine state of PairCorrelationConstraint constraint data.
  6. multiplot.py: The script file to plot the last saved engine state of PairCorrelationConstraint constraint data in three different axes showing multiple zooming to data.
  7. visualize.py: The script file to visualize the last save configuration using VMD. if installed.

run.py explained

IMPORTING USEFUL DEFINITIONS:

All useful packages, modules and definitions are imported.

CREATE ENGINE:

Check if engine already saved on disk. In the affirmative load it to continue fitting from last saved configuration. Otherwise, build the engine and the needed constraints. Also, in this example we decided to make it a bit more difficult and to fit a pair correlation function using PairCorrelationConstraint instead of a pair distribution function. As ‘thf_pdf.exp’ is a pair distribution function data file, we used ‘convert_Gr_to_gr’ function to convert the latter to pair correlation function. Also it makes sense to neglect all initial ‘N’ negative data points, hence a dataWeights array is created where all its values are equal to 1 except for the first ‘N’ elements.

DIFFERENT RUNS:

Define functions to run the fitting engine. All of the following functions finish running the engine using Engine.run method.

  1. bonds_CH: Groups are created by C-H pair of atoms using their indexes. DistanceAgitationGenerator is assigned to each group. A RecursiveGroupSelector is used if any of refine or explore flags are set to True.
  2. angles_HCH: Groups are created by C-H-H triplets of atoms using their indexes. class:.AngleAgitationGenerator is assigned to each group. A RecursiveGroupSelector is used if any of refine or explore flags are set to True.
  3. atoms_type: Groups of single atoms are created using atom type. A RecursiveGroupSelector is used if any of refine or explore flags are set to True.
  4. atoms: set_groups_as_atoms method is used to creating a group per atom. A RecursiveGroupSelector is used if any of refine or explore flags are set to True.
  5. about0: set_groups_as_molecules method is used to create molecular groups. RotationAboutSymmetryAxisGenerator with axis=0 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  6. about1: set_groups_as_molecules method is used to create molecular groups. RotationAboutSymmetryAxisGenerator with axis=1 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  7. about2: set_groups_as_molecules method is used to create molecular groups. RotationAboutSymmetryAxisGenerator with axis=2 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  8. along0: set_groups_as_molecules method is used to create molecular groups. TranslationAlongSymmetryAxisGenerator with axis=0 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  9. along1: set_groups_as_molecules method is used to create molecular groups. TranslationAlongSymmetryAxisGenerator with axis=1 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  10. along2: set_groups_as_molecules method is used to create molecular groups. TranslationAlongSymmetryAxisGenerator with axis=2 is assigned to each group. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box.
  11. molecules: set_groups_as_molecules method is used to create molecular groups. A collection MoveGeneratorCollector of move generators is created and set to every group. RotationGenerator and TranslationGenerator are added to this collection. RecursiveGroupSelector is used allowing to refine or explore fitting.
  12. shrink: set_groups_as_molecules method is used to create molecular groups. A collection MoveGeneratorCollector of move generators is created and set to every group. RotationGenerator and TranslationGenerator are added to this collection. DefinedOrderSelector wrapped with a RecursiveGroupSelector with the order of selection being the sorted groups indexes list computed in a such a way ordering groups from the further to the closest to the center of the simulation box. New boundary condition is set using set_boundary_conditions method.

RUN SIMULATION:

run the different functions to fit the system.

PLOT PDF CONSTRAINT:

Plotting PairCorrelationConstraint data after fitting.

Table of Contents