This script uses the method developed by Dorenbos and Morohoshi to study diffusion of water in fuel cell membranes. They wanted to study diffusion in mesoscale systems. However, as the DPD interaction is short ranged and soft, it is difficult to get good diffusion coefficients. So, instead of using a DPD interaction, they used the morphology from a DPD simulation but coupled this with a monte-carlo approach to move particles through the pore structure.
A density field and isosurface define the constraints for where water can diffuse in a fuel cell membrane. This morphology is generated using the DPD task in Mesocite.
A monte-carlo algorithm is used to place a probe in the water density field and the probe is moved randomly in each of the 6 directions. The move is accepted if it results in the probe remaining in the density field.
A trajectory is created using sampled frames. This is converted to text and back so that time can be added to the trajectory. Mean squared displacement is used to calculate the diffusivity of the probes.
Note that this only runs on Windows. If you need to run this on Linux, either turn off the trajectory conversion or modify the path to trj2ascii.
From a performance perspective, I have tried to put much of the code in Perl to avoid using MaterialsScript where possible. This includes building a map of field values so that the field probe does not have to be moved every time as this would slow things down.
I strongly recommend you read the paper referenced above if you are intending to use this script.
You can see an example of this script in action in the video below...
Cheers
Stephen
