# Code

My GitHub page provides tools for working with common discrete statistical physics models: the dimer model, the loop-erased random walk, the uniform spanning tree, and the discrete Gaussian free field. The packages are written in Julia, for two reasons:

• It's simple. Julia's syntax is readable and standard, so experience with Julia is not a prerequisite for using and modifying the code. Furthermore, Julia can be run online at JuliaBox, so you don't need to install anything.
• It's fast. Speed is one of the Julia developers' top priorities, so generating very large simulations is feasible.
Instructions for getting started are below.

## Examples

### The SLE fan

```  ```
using Graphics2D
using GaussianFreeFields
using Grid
n = 250
h = InterpGrid(fix_boundary_values(DGFF(n)),BCnil,InterpLinear)
κ = 3
χ = 2/sqrt(κ) - sqrt(κ)/2
z0 = (n+1)/2 + im*(n+1)/2
fan = GraphicElement[]
for θ=0.0:0.05:2π
push!(fan,Line(flowline(h, z0, χ, θ); color = θ/(2π)*"green" + (1-θ/(2π))*"blue"))
end
showgraphics([fan;[Line([1 n; n n; n 1; 1 1; 1 n])]])
```
```

### GFF level lines

```  ```
using Graphics2D
using Contour
using GaussianFreeFields
n = 250
h = DGFF(n)
h0 = fix_boundary_values(h)
showgraphics([Line(c;linesize=1.0,color=0.3*"green")
for c in contour(1.0:n,1.0:n,h0,0.0).lines]; dim = 512)
```
```

### A Gaussian free field surface plot

```  ```
using GaussianFreeFields
n = 20
h = DGFF(n)
h0 = fix_boundary_values(h)
X = [x for x=1:n,y=1:n]
Y = [y for x=1:n,y=1:n]
plot_surface(X, Y, h0, rstride = 1, cstride = 1, cmap="autumn")
```
```

### Uniform dimer sampling

```  ```
using Graphics2D
using Dimers
showgraphics(drawgraph(dimersample(20)))
```
```

### Uniform spanning tree sampling

```  ```
using Dimers
G = grid_graph(20)
roots = [[true];[false for i=1:length(G.vertices)-1]]
showgraphics(draw_graph(Wilson(G,roots)))
```
```

### Conformal maps

```  ```
using Graphics2D
using ConformalMaps
slitdomain = [0.0, 0.495, 0.5 + 0.25*im, 0.505, 1.0, 1.0 + 1.0*im, im]
f = ConformalMap(slitdomain,0.5+0.5im;resolution=40)
g = inv(f)
showgraphics([visualize(g;rings=12,rays=20)[2];domain(g)])
```
```

## Getting Started

``` Pkg.clone("git://github.com/sswatson/Graphics2D.jl.git") Pkg.clone("git://github.com/sswatson/Dimers.jl.git") Pkg.clone("git://github.com/sswatson/GaussianFreeFields.jl.git") Pkg.clone("git://github.com/sswatson/ConformalMaps.jl.git") ```
3. That's it! You can learn about the language on the Julia learning page, and you can read the package documentation and see more examples on my GitHub page. To inspect the source code, open the `src` directory on GitHub and look at `PackageName.jl`.