Computing diffusion properties

This sample show how a single atom may be moved in a structure to computer diffusion properties. The sample makes use of a C# lambda expression to move only the atom at the origin:

// Create a fcc structure of 8 atoms by enlarging the primitive cell.
Structure s0 = Structure.CreateFaceCenteredCubicStructure(4.04)
    .Add(Atom.Al, 0.0, 0.0, 0.0)
    .Repeat(2, 2, 2);

Dictionary<double, Structure> structures = new Dictionary<double, Structure>();

// Deviations.
for (double x = 0.0; x <= 0.5; x += 0.1)
{
    // Create transformed structure where only the atom at the origin is moved.
    Structure s = s0.Transform((Position position) => position.Coordinates == SpaceVector.Zero ? new Position(x, 0.0, 0.0) : position);
    structures.Add(x, s);
}

// Visualize all structures. One atom is moved.
Structure.Show(structures.Values);

foreach (KeyValuePair<double, Structure> s in structures)
{
    // Prepare VASP with default options.
    VaspProblem vasp = new VaspProblem();
    vasp.Structure = s.Value;

    // Run VASP. An object is generated containing relevant output.
    VaspResult result = vasp.Run();
    Console.WriteLine("{0} {1}", s.Key, result.PotentialEnergy);
}

Last edited Sep 13, 2013 at 7:03 PM by bakkedal, version 2