(*--------------------------------------------------------------------------*)
(*----------------------------- INTERACT -----------------------------------*)
(*--------------------------------------------------------------------------*)
(* This package contains functions, examples of configurations and transi- *)
(* tion rates for the simulation of spin system on two-dimensional grids *)
(* The grids are supposed to be toric (periodic boundary conditions), and *)
(* the flip rates at one site depend on the state (0 or 1) of the site as *)
(* well as the number of its neighbors in state 1. *)
BeginPackage["UVW`Interact`"]
(* Version 2.0, 08/15/97 *)
(*----------------- Examples of basic configurations -----------------------*)
(* All configurations are two-dimensional arrays of 0's and 1's. The element*)
(* config[[x,y]] is interpreted as the state of site (x,y). *)
(*--------------------------------------------------------------------------*)
Checkerboard::usage="
Checkerboard returns a 40-by-40 configuration of 0's and 1's arranged in
10 by 10 squares."
Diagonals::usage="
Diagonals returns a 40-by-40 configuration of 0's and 1's arranged in
diagonal stripes."
RConfig::usage="
RConfig[p,width,height] returns a width-by-height array of independent
random 0's and 1's, 1 being chosen with probability p."
(*------------------------ Examples of rates -------------------------------*)
(* All lists of rates are returned as a 2-by-5 list of reals. in such a *)
(* list, rate[[i,j]] represents the rate at which the configuration will *)
(* change at a site in state i (0 or 1) having j (from 0 to 4) neighbors in *)
(* state 1. *)
(*--------------------------------------------------------------------------*)
Uniform::usage="
Uniform[lambda,mu] are the rates corresponding to the case where the
configuration changes from 0 to 1 at rate lambda and from 1 to 0 at rate mu,
independently from the number of neighbors in state 1."
Ising::usage="
Ising[Alpha,Beta] returns the rates corresponding to the symmetric
Stochastic Ising Model, admitting a Gibbs measure as a reversible state.
Alpha is the potential of a site alone, Beta is the potential of a pair
of neighboring sites."
Contact::usage="
Contact[lambda] returns the rates of the contact process. The transition
rates from 1 to 0 (curing) is constant. The rate of transition from
0 to 1 is proportional to the number of neighbors at 1 (infecting)."
Voter::usage="
Voter returns the rates of the Voter Model, where the transition rate from 0
to 1 is proportional to the number of neighbors in state 1 and vice versa."
(*------------------- Treatment of a configuration -------------------------*)
Cyclic::usage="
Cyclic[n,bound] returns bound if n is 0, 1 if n is bound+1 , n in any other
case. (Periodic boundary conditions are assumed for all configurations.)"
RepartConfig::usage="
RepartConfig[config] returns a 2-by-5 list of integers. Its element
[[i,j]] is the number of sites in state i (0 or 1) having j (from 0 to 4)
neighbors in state 1."
Evolution::usage="
Evolution[initialconfig,rates,niter] simulates the evolution of a
configuration according to the spin system corresponding to rates. niter
iteration are performed. One iteration consists of picking up a site at
random and decide to flip its state or not."
(*-------------------- Graphical representation ----------------------------*)
DrawConfig::usage="
DrawConfig[config,opts] plots config as a rectangular array of back and
white squares."
(*--------------------------------------------------------------------------*)
(*--------------------------------------------------------------------------*)
Begin["`Private`"]
(*----------------- Examples of basic configurations -----------------------*)
Checkerboard :=
Block[{i,j},
Return[Table[If[ Xor[ Mod[Quotient[i,5],2]==0,
Mod[Quotient[j,5],2]==0 ]
,1,0],
{i,0,39},{j,0,39}]
];
];
Diagonals :=
Block[{i,j},
Return[Table[If[ Mod[i+j,10]<5
,1,0],
{i,0,39},{j,0,39}]
];
];
RConfig[p_Real,height_Integer,width_Integer] :=
Table[If[Random[]True,
FrameTicks->None,
AspectRatio->
N[Length[config]/Length[Transpose[config]]]
]
End[ ] (* End of Private Context-------------------------------------*)
EndPackage[ ]
(*--------------------------------------------------------------------------*)