View Single Page Version

# Post Processing
## Using Dissolve as a post-processor

20 minutes

Summary

Sometimes it’s useful to apply Dissolve’s analysis capabilities to external data, e.g. from a molecular dynamics simulation. Dissolve can import coordinates from single configuration “snapshots” or from trajectories, and can thus apply any of its functions (e.g. calculation of weighted structure factors, application of analysis layers) in the standard way. Essentially, this involves setting up a standard simulation in Dissolve but instead of evolving the system with an evolution layer, we use an import layer instead.

Just as with any standard simulation in Dissolve, species, their isotopologues (if required), and analysis sites must be defined in order to calculate what you need. In particular, the order of atoms within species must match those in the data file, as must the ordering of species/molecules in the configuration the data file represents. The only thing that isn’t really important is which forcefield you apply to the species, since we won’t be performing any evolution on the system ourselves. However, the forcefield of course guides the atom type that we see, and so has a direct effect on, for instance, the NeutronSQ and is output.

For this example we have a pre-run DL_POLY molecular dynamics simulation of 9 mol% isopropanol in water which we’ll import into Dissolve.

Preparation

Download the example data as a zip or tar.gz and unpack it if you haven’t done so already. Alternatively, download the data files listed below and save them to a location of your choice.

File ⇨ New

File ⇨ Save As…

Save your input file under a sensible name in same directory as the example data

Step 1 - Set up the Species

Create the Species

We can import the two species we need from some xyz datafiles supplied in the example data:

Species ⇨ Import ⇨ From XYZ…

Choose the ipa.xyz file.

Change the name to IPA by double clicking the   NewSpecies   tab

Species ⇨ Add Forcefield Terms…

From the available forcefields choose OPLS-AA/Alcohols or UFF (your choice!) and click Next

Leave all other settings as default and click Next until finished

Now for the water:

Species ⇨ Import ⇨ From XYZ…

Change the name to water by double clicking the   NewSpecies   tab

Species ⇨ Import ⇨ From XYZ…

From the available forcefields choose SPC/Fw and click Next

Leave all other settings as default and click Next until finished

Each species needs to have a suitable forcefield applied since Dissolve demands that, at the very least, atom types to be assigned to all atoms.

Create Analysis Sites

How many analysis sites you define will of course depend on what you want to calculate - if, indeed, you are calculating anything at all (beyond using the standard correlation function modules). For the sake of example we’ll calculate some centre-of-mass RDFs here, so you’ll need a centre-of-mass site defined for each of the two species. If you want to define more than that, or add orientation to the centre-of-mass sites, etc., please feel free to do so!

To create a center-of-mass site:

Go to the   IPA   species tab

Select the molecule in the viewer (drag-click over it)

Right click the selection and click Create site fromAtoms to create a new site

Click on the Sites section on the bottom-left of the window

Enable the Weight origin by mass option

Repeat for the water molecule!


Step 2 - Create Configuration

Of course we need a configuration to use as our calculation / analysis target, and which must represent exactly the data file we’re going to read in terms of atom / species ordering, box size etc. The reference system is a 9 mol% isopropanol in water mix, with 3234 molecules - 291 isopropanol followed by 2943 water. The atom coordinates of the xyz species you used in the previous step also reflect the atom ordering within molecules. The periodic box of the reference simulation is cubic with a side length of 48.6080 Å.

So, let’s set up a random mix to mirror all of this:

Configuration ⇨ Create…

Choose both species and press Next

Leave the configuration type as Mixture and press Next

Set the box style to Fixed Geometry and Size and set all three axis lengths A, B, and C to 48.608, then press Next

In the species table change the Population / Ratio of water to 2943 and isopropanol to 291

Set the Multiplier to 1 - this is really important, as otherwise you’ll end up with a huge system with around five million molecules in it!

Press Finish to complete the wizard.

Double-click on the configuration tab’s title and change its name to   Bulk

With this set-up, the Parameters node is in fact redundant since our density is defined by our imposed box volume and the populations of the species. The CoordinateSets nodes also no longer have any purpose since we will be overwriting the configuration coordinates with our reference data, so if you wanted to you could reduce the number of generated sets in those nodes to 1.


Step 3 - Import Reference Data

At this point we would normally add an evolution layer in order to move our configuration contents around, but here we’ll import a trajectory instead.

Layer ⇨ Create… ⇨ Empty

Double-click the layer tab and rename it to   Import

Show the module palette for the current layer by clicking the Show Available Modules button at the bottom of the module list on the left

Drag an ImportTrajectory module from the Import section into the layer

An important thing to note here is that the ImportTrajectory module should run every iteration - otherwise, there is the risk of averaging calculated quantities over identical configuration snapshots in the trajectory and polluting your results.

Set the target file of the ImportTrajectory module to the 9molpcnt-IPA-water.xyz trajectory

Now we’re ready to add some calculation layers. Note that the ImportTrajectory has a configuration target just as many other modules do. Here it is the target configuration whose coordinates we are going to overwrite.


Step 4 - RDF and Structure Factors

Let’s create our correlation layer:

Layer ⇨ Create ⇨ Correlations ⇨ RDF and Neutron S(Q)

Recall that our ImportTrajectory module is running every iteration, so our correlation calculation layer needs to do the same:

Go to the   G(r) / Neutron S(Q)   layer tab

Change the frequency in the Layer Control at the top-left of the tab from 5 to 1

Let’s do a quick, single iteration to make sure everything is working as expected:

Ctrl-1

What will have happened in this iteration is that a single frame will have been read in from the trajectory into the configuration and, if we’ve got everything else set up correctly, from which some sensible-looking radial distribution functions and (neutron-weighted) structure factors will have been calculated.

Go to the NeutronSQ module and open its Output tab

The total F(Q) should look like this:

Total neutron-weighted structure factor from the first frame of the reference trajectory


Step 5 - Set Up Analysis

We’ll add a basic analysis layer and calculate the IPA-water centre-of-mass RDF as an example - feel free to add others into the layer as your curiosity dictates, but bear in mind that the test trajectory is quite small, so properties requiring a lot of statistics will not do well here.

Layer ⇨ Create… ⇨ Empty

Double-click the layer tab and rename it to Analyse

Show the module palette for the current layer by clicking the Show Available Modules button at the bottom of the module list on the left

Drag a SiteRDF module from the Import section into the layer

In the SiteRDF module itself:

Set SiteA to the centre-of-mass site for IPA you created earlier

Set SiteB to the centre-of-mass site for water


Step 6 - Run the Analysis

At this point, you can set the simulation running (although it is a pure analysis pipeline rather than a simulation):

Ctrl-R

Dissolve will churn through the trajectory file until it hits iteration 21, at which point you will encounter some errors. This is because, for practical distribution reasons, the trajectory file only has twenty steps in it, hence attempting to read past the end of the twentieth frame (in step 21) causes an error.

Also, our SiteRDF module missed data from the first frame (which we used to test the RDF/F(Q) calculation). So let’s reset everything and do it again:

Simulation ⇨ Clear Module Data

Be brave, and click OK

This removes all of the calculated data (RDFs, S(Q), F(Q), and the analysed data) but also crucially gets rid of any information the ImportTrajectory module had on where it was looking at in the file. So, if you now run Dissolve again, the import will begin at the first frame of the file. Of course, it will still fail at iteration 21!