Relative path



A box of 3375 Nickel atoms and 3375 Titanium which makes a total of 6750 arranged in a body centred cubic crystal of length \(3.05 \AA\). x-rays pair distribution function and Atomic Structure Factor are used simultaneously to build and fit a model. In this example, it was necessary to use SwapPositionsGenerator in order to fit long ranger ordering. This example was used to generate the swap video as seen in the online documentation.


  1. system.pdb: The initial configuration input file.
  2. The x-rays experimental pair distribution function data.
  3. experimental.fq: The x-rays experimental reduced structure factor data.
  4. The script file used to run the simulation.
  5. The script file to plot the last saved engine state of PairDistributionConstraint and ReducedStructureFactorConstraint constraints data.
  6. The script file to visualize the last save configuration using VMD. if installed. explained


All useful packages, modules and definitions are imported.


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. In this particular example, ‘experimental.fq’ has no regular bins. Therefore, rebinning it needs to be rebinned using ‘fullrmc.Core.Collection.rebin’ function. Even though engine contains AtomicCoordinationNumberConstraint we decided to discard this constraint upon fitting by using set_used method and assigned ‘used’ flag to False.


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

  1. run_normal: used set_groups(None) which is equivalent to creating a group per atom. Here the engine runs traditional RMC with random selection of groups using RandomSelector and random atomic translations using TranslationGenerator move generator.
  2. run_swap: used set_groups(None) which is equivalent to creating a group per atom. Create two swapping lists. The first one containing only all Nickel atoms indexes and the second only Titanium atoms indexes. Create two SwapPositionsGenerator for swapping Nickel atoms with Titanium and the other the opposite. Loop over all engine’s groups, check whether group’s atom is Nickel or Titanium and assign it respectively SwapPositionsGenerator to Titanium atoms and another SwapPositionsGenerator to Nickel atoms. Advanced users can change AtomicCoordinationNumberConstraint used flag to True and try playing with the given coordination number definition and improve the fit quality and the physical meaning of the final structure.


run_normal several times with different number of steps and saving frequencies. This sampling is not needed but it was done as such for the purpose of saving different pdb file snapshots at different stages of the fitting. At the end run_swap is called to fit long range order correlations.


Plotting simultaneously PairDistributionConstraint and ReducedStructureFactorConstraint data after fitting.

Table of Contents