See examples in Generic.mw
For mathematical details see Random walk on a lattice: Basic formulas
To cite this code use: A Zhugayevych et al, JPCC 117, 4920 (2013) [pdf]
k k-vectord::posint spatial dimensiono::1..d enumerates dimensionsM::Matrix(d) matrix of Cartesian translation vectors as columns (default is identity matrix)n::posint number of sites in unit cellm::1..n enumerates sites in unit cellmt=[m,t1,...,td] enumerates sites in translationally invariant system, here t denotes integer translationsmtsid indexing table mts[mtsid[mt]]=mtn2::posint size of the extended cell consisting of all sites coupled to unit cell starting from n sites belonging to the unit cellsites::Array(n2,0..d) such that sites[i,0]=mts[i][1] and sites[i,o]=mts[i][1+o]replicas::Vector(n) whose i-th entry is list of all replicas of i-th site including iPoints/points::Matrix(d,n) whose columns are Cartesian/lattice coordinatesW::Matrix(n,n2) transition rate matrix (its diagonal elements will be set to zero if appropriate)Wk::Matrix(n) Fourier transform of WW0,Wp,Wpp are Wk, its derivative diff(Wk(k),I*k), and second derivative all at k=0 and with zero diagonalU::Vector decay rates vectorH::Matrix(n,n2) single-cell real-space HamiltonianHk::Matrix(n) Fourier-transform of HBuilders
BuildW(n,genfun,genopt,{sym::boolean})::W
build transition rates matrix (symmetric if sym),
genfun determines generating function which uses genopt,_rest and can be one of
"Matrix" use Matrix"RandomMatrix" use RandomMatrix"Generate" use RandomTools[Generate]"Sample" use Statistics[Sample]"GamEps" use Gam[i,j](Sample(genopt[1]))*exp(Eps[i](Sample(genopt[2]))) (returns W,Gam,Eps)BuildA(W,/U,$)::Matrix(n) build generator of Markov chain such that P(t)=exp(A*t)BuildH(tbH,k::{name,indexable},{symmetric,printout},$)::H,Hk,mts,mtsid build translationally invariant Hamiltonian matrix,
here tbH::table of translationally unique Hamiltonian elements tbH[m0,m,t1,...,td]Solvers
GreensF(s,W,/U,$)::Matrix compute Green's function G=(s-BuildA(W,U))^(-1) (datatype is derived from s,W)StatSol(W,/i0,simplifyf,{printout},$) find stationary solution,
with respect to site i0::nonnegint:=0 (must be significant site to avoid the loss of precision),
if zero i0 is set to a site with the maximum outflowZeroExpan(W,/i0,simplifyf,{printout},$) expand the resolvent at zeroVelocity(sites,W,/M,replicas,i0,simplifyf,{printout},$) velocity for infinite periodic latticeDiffusionTensor(sites,W,/M,replicas,i0,simplifyf,{printout},$) diffusion tensorDiffusionLength(sites,W,U,points,/M,replicas,{printout},$) mean square displacementAnalyzers
PathExpansion(H,E,oi,of,vmin,Nmax,/subsys,{Lmax,neglect,printout,digits,nprint},$)
::table([seq(L=list([v,o1,o2,...,oL]),L=0..Lmax2)])
perform path expansion of sub-Hamiltonian in perturbation theory over nondiagonal matrix elements
by expanding Hrenorm[oi,of]=H[oi,of]+H[oi,env].(E-Henv)^(-1).H[env,of] in powers of transfer integrals
E::numeric perturbation eigenenergyoi,of::posint indices of a matrix element to be expandedsubsys::list(posint):=[oi,of] list of indices of the subsystem, other indices are considered as environment envvmin::numeric expansion threshold in value of tau-matrix elementsneglect::numeric:=1e-3 threshold for perturbation terms vmin2=neglect*vminNmax::posint maximum value of terms to keep at each iterationLmax::posint:=99 maximum order of expansionLmax2 internal variable defining maximum nonzero term of expansionnprint::posint:=9 number of largest terms to print