Fortran utilities

vasp module

Description

This module provides utilities in order to manipulate a crystal object. Crystal object can be created from POSCAR/CONTCAR VASP files. In all functions and subroutines, angle are given or returned in degrees. If needed they are converted in radian localy.

Quick access

Types:atom, crystal
Variables:pi, vtrans, trans
Routines:inverse(), cleancrystal(), computeredcoord(), computexyzcoord(), getcomposition(), fromconfig(), toposcar(), fromposcar(), red2cart(), allneighbor(), neighbor(), computelatticevectors(), computelatticeparameters(), fillmatrix(), cart2red(), image(), computevolume(), dist_i(), dist_r(), dist_x()

Types

  • type crysmod/atom

    atom type object

    Type fields:
    • % x (3) [real]
    • % r (3) [real]
    • % atname [character]
  • type crysmod/crystal

    crystal type object

    Type fields:
    • % natoms [integer]
    • % vecb (3) [real]
    • % vecc (3) [real]
    • % veca (3) [real]
    • % ntype [integer]

    :f atom atoms(:) [allocatable]: :f real gam: :f character atomtype(:) [allocatable]: :f real mred2cart(3,3): :f real alpha: :f real a: :f real mcart2red(3,3): :f real c: :f real b: :f real beta: :f character cname: :f integer natompertype(:) [allocatable]:

Variables

  • crysmod/pi [real,private/parameter=3.14159265359d0]
  • crysmod/vtrans (81) [real,private/parameter=(/0.d0,1.d0,1.d0,0.d0,1.d0,0.d0,0.d0,1.d0,-1.d0,0.d0,0.d0,1.d0,0.d0,0.d0,0.d0,0.d0,0.d0,-1.d0,0.d0,-1.d0,1.d0,0.d0,-1.d0,0.d0,0.d0,-1.d0,-1.d0,1.d0,1.d0,1.d0,1.d0,1.d0,0.d0,1.d0,1.d0,-1.d0,1.d0,0.d0,1.d0,1.d0,0.d0,0.d0,1.d0,0.d0,-1.d0,1.d0,-1.d0,1.d0,1.d0,-1.d0,0.d0,1.d0,-1.d0,-1.d0,-1.d0,1.d0,1.d0,-1.d0,1.d0,0.d0,-1.d0,1.d0,-1.d0,-1.d0,0.d0,1.d0,-1.d0,0.d0,0.d0,-1.d0,0.d0,-1.d0,-1.d0,-1.d0,1.d0,-1.d0,-1.d0,0.d0,-1.d0,-1.d0,-1.d0/)]
  • crysmod/trans (3,27) [real,parameter=reshape(vtrans,(/3,27/))]

Subroutines and functions

subroutine crysmod/cleancrystal(cell)

Clean crystal type :

  • deallocate array if allocated
  • set default value to all attributes
Parameters:cell [crystal,inout]
subroutine crysmod/computelatticevectors(cell[, verbose])

Compute lattice vectors from lattice parameters. Lattice parameters must be known. By default, lattice vector veca is along x, vecb is in the xOy plane and z is choosen such as [veca, vecb, vecc] is positive.

Parameters:cell [crystal,inout] :: Crystal structure
Options:verbose [logical,in,optional] :: manage verbosity
subroutine crysmod/computelatticeparameters(cell[, verbose])

Compute lattice parameters from lattice vectors. Lattice vectors must be known.

Parameters:cell [crystal,inout] :: crystal structure
Options:verbose [logical,in,optional] :: manage verbosity
Called from:fromconfig(), fromposcar()
subroutine crysmod/fillmatrix(cell[, verbose])

fill transformation matrix from lattice vectors.

  • Mred2cart : reduce -> cartesian
  • Mcart2red : cartesian -> reduce

Lattice vectors must be knwon and must be consistent with coordinates.

Parameters:cell [crystal,inout] :: crystal structure
Options:verbose [logical,in,optional] :: manage verbosity
Called from:fromconfig(), fromposcar()
Call to:inverse()
function crysmod/red2cart(cell, r)

convert cartesian coordinate into reduce coordinate.

Parameters:
  • cell [crystal,in] :: crystal structure
  • r (3) [real,in] :: reduce coordinate
Return:

red2cart (3) [real] :: cartesian coordinate

Called from:

dist_r(), computexyzcoord(), neighbor(), dist_i(), dist_x(), allneighbor()

function crysmod/cart2red(cell, x)

convert cartesian coordinate into reduce coordinate.

Parameters:
  • cell [crystal,in] :: crystal structure
  • x (3) [real,in] :: cartesian coordinate
Return:

cart2red (3) [real] :: reduce coordinate

Called from:

dist_x(), computeredcoord()

subroutine crysmod/computexyzcoord(cell)

compute cartesian coordinates from reduce coordinates of all atoms into the crystal structure.

Parameters:cell [crystal,inout] :: Crystal structure
Called from:fromposcar()
Call to:red2cart()
subroutine crysmod/computeredcoord(cell)

compute reduce coordinates from cartesian coordinates of all atoms into the crystal structure.

Parameters:cell [crystal,inout] :: Crystal structure
Called from:fromconfig(), fromposcar()
Call to:cart2red()
function crysmod/dist_i(cell, iat, jat)

Compute the minimum distance between atoms iat and jat considering periodic boundary conditions. This function needs that reduce coordinates of atoms iat and jat are known.

Parameters:
  • cell [crystal,in] :: Crystal structure
  • iat [integer,in] :: atom number
  • jat [integer,in] :: atom number
Return:

dist_i [real]

Called from:

neighbor(), allneighbor()

Call to:

image(), red2cart()

function crysmod/dist_r(cell, ri, rj)

Compute the minimum distance between atoms at coordinate ri and rj considering periodic boundary conditions. ri and rj are reduce coordinates.

Parameters:
  • cell [crystal,in] :: Crystal structure
  • ri (3) [real,in] :: reduce coordinates of atom i
  • rj (3) [real,in] :: reduce coordinates of atom j
Return:

dist_r [real]

Call to:

image(), red2cart()

function crysmod/dist_x(cell, xi, xj)

Compute the minimum distance between atoms at coordinate xi and xj considering periodic boundary conditions. xi and xj are cartesian coordinates.

Parameters:
  • cell [crystal,in] :: Crystal structure
  • xi (3) [real,in] :: cartesian coordinates of atom i
  • xj (3) [real,in] :: cartesian coordinates of atom j
Return:

dist_x [real]

Call to:

image(), cart2red(), red2cart()

function crysmod/image(ri, rj)

Returns the shortest vector in reduce coordinate considering the periodic boundary conditions. This function needs that reduce coordinate had been calculated. Use computeRedCoord if needed.

Parameters:
  • ri (3) [real,in] :: reduce coordinates of atom i
  • rj (3) [real,in] :: reduce coordinates of atom j
Return:

image (3) [real]

Called from:

dist_r(), image(), dist_i(), dist_x()

Call to:

image()

function crysmod/computevolume(cell)

Compute the cell volume

Parameters:cell [crystal,in] :: Crystal structure
Return:computevolume [real]
subroutine crysmod/getcomposition(cell)

look for different atom type and number of each atom type.

Parameters:cell [crystal,inout]
Called from:toposcar()
subroutine crysmod/fromposcar(cell[, poscar[, iunit[, verbose]]])

Build a crystal object from a POSCAR/CONTCAR VASP structure file.

Parameters:

cell [crystal,out] :: built structure

Options:
  • poscar [character,in,optional] :: file name from which the structure is read (default = “POSCAR”)
  • iunit [integer,in,optional] :: file unit for reading
  • verbose [logical,in,optional] :: manage verbosity (default = .False.)
Call to:

computelatticeparameters(), fillmatrix(), computeredcoord(), computexyzcoord()

subroutine crysmod/toposcar(cell[, filename[, iunit]])

print cell into a VASP structure file POSCAR

Parameters:

cell [crystal,inout] :: crystal structure

Options:
  • filename [character,in,optional] :: file name (default : POSCAR)
  • iunit [integer,in,optional] :: file logical unit (default : 64)
Call to:

getcomposition()

subroutine crysmod/fromconfig(cell[, config[, iunit[, verbose]]])

Build a crystal object from a CONFIG/REVCON DLPOLY structure file.

Parameters:

cell [crystal,out] :: built structure

Options:
  • config [character,in,optional] :: file name from which the structure is read (default = “CONFIG”)
  • iunit [integer,in,optional] :: file unit for reading
  • verbose [logical,in,optional] :: manage verbosity (default = .False.)
Call to:

computelatticeparameters(), fillmatrix(), computeredcoord()

subroutine crysmod/neighbor(cell, rcut, ns, nn, iatom, neigh, nneigh[, ligand])

look for neighbors of atoms in the list iatom. If ligand present, only atoms with name ligand are considered. If rcut < cell parameters / 2, the subroutine looks for multiple neighbors by considering all atoms in the 26 adjacent cells around the central the considered cell.

Parameters:
  • cell [crystal,in] :: crystal structure
  • rcut [real,in] :: cut off radius (in Angstrom)
  • ns [integer,in,] :: number of selected atom for which neighbors list is built
  • nn [integer,in] :: maximum number of neighbors
  • iatom (ns) [integer,in] :: list of atom index for which neighbors list is built
  • neigh (ns,nn) [integer,out] :: neighbors list
  • nneigh (ns) [integer,out] :: number of neighbors of each atom in iatom list
Options:

ligand [character,in,optional] :: limit the neighbors list to atoms name ligand (defaut = “#” not any atom is excluded)

Call to:

red2cart(), dist_i()

subroutine crysmod/allneighbor(cell, rcut, nn, neigh, nneigh)

Look for neighbors of all atoms in cell. If rcut > cell parameters/2, the subroutine looks for multiple neighbors by considering all atoms in the 26 adjacent cells around the considered cell.

Parameters:
  • cell [crystal,in] :: crystal structure
  • rcut [real,in] :: cut off radius
  • nn [integer,in] :: maximum number of neighbors
  • neigh (cell%natoms,nn) [integer,out] :: neighbors list
  • nneigh (cell%natoms) [integer,out] :: number of neighbors of each atom
Call to:

red2cart(), dist_i()

subroutine crysmod/inverse(a, c, n)

Inverse matrix

Method :

Based on Doolittle LU factorization for Ax=b

Author :

Alex G. December 2009

Comments :

the original matrix a(n,n) will be destroyed during the calculation

Parameters:
  • a (n,n) [real,inout] :: array of coefficients for matrix A
  • c (n,n) [real,out] :: inverse matrix of a
  • n [integer,in,] :: dimension
Called from:

fillmatrix()

Table Of Contents

Previous topic

Scripts

This Page