maltepuetz / ScalingCollapse.jl

A julia package for automatic finite size scaling.
MIT License
5 stars 1 forks source link

ScalingCollapse

Stable Dev Build Status Coverage Aqua DOI

This is a package for automatic finite size scaling. Finite size scaling is a method to determine the critical parameters of a phase transition by exploiting, so called, finite size effects. This package implements an automatic optimization algorithm to find the best parameters for a finite size scaling collapse.

It is still in early development, so expect bugs and breaking changes. Feel free to create issues in case you stumble upon any problems!

Installation

For installation run the following command:

julia> using Pkg; Pkg.add("https://github.com/maltepuetz/ScalingCollapse.jl.git")

Getting started

To find the best parameters for a finite size scaling analysis, we need to create a ScalingProblem. Lets say we have data for the binder cumulant of the 2D Ising model binder for different temperatures Ts and different system sizes Ls. We want to find the critical temperature and the critical exponent of the correlation length. Let's create a ScalingProblem as follows:

using ScalingCollapse
sp = ScalingProblem(Ts, binder, Ls;
    sf = ScalingFunction(:x),
    dx = [-1.0, 1.0],
)

The kwarg sf is used to set the scaling function. In this case we use the scaling function preset :x which only rescales the x-axis as x -> (x - p1)/p1 * L^(1/p2). We can also give the parameters custom names by passing the kwarg p_names::Vector{String} to the ScalingFunction constructor. We use the kwarg dx to limit the optimization to a fixed interval because powerlaw dependece is usually only accurate close to the critical point. The default value is dx = [-Inf, Inf]. Other kwargs are:

There are also other preset ScalingFunctions:

Note that you can also create your own scaling function! We can make our scaling function looking a little bit cooler by giving our parameters custom names with the kwarg p_names::Vector{String}.

Now that we know the basics, let us solve another scaling problem. This time we know that the critical temperature is somewhere between T_c = 2.0 and T_c = 2.4 and the critical exponent is somewhere between nu = 0.5 and nu = 1.5. We set the parameter space accordingly:

using ScalingCollapse
sp = ScalingProblem(Ts, binder, Ls;
    sf = ScalingFunction(:x; p_names = ["T_c", "nu"]),
    dx = [-1.0, 1.0],
    p_space = [2.0:0.1:2.4, 0.5:0.1:1.5],
    error = true,
)

We limited the parameter space so the algorithm runs faster, calculated some error bars and made everything look cooler by giving the parameters custom names!

Fixing parameters

Let's say that we know from our statistical mechanics course that the critical exponent of the correlation length is nu = 1. We can fix this parameter by passing it as a kwarg to the ScalingFunction constructor.

using ScalingCollapse
sp = ScalingProblem(Ts, binder, Ls;
    sf = ScalingFunction(:x; p_names = ["T_c", "nu"], nu=1),
    dx = [-1.0, 1.0],
    p_space = [2.0:0.1:2.4],
    error = true,
)

Now the algorithm will only optimize the critical temperature T_c and the critical exponent of the correlation length will be fixed to nu = 1.

Creating custom scaling functions

To be written...

Have fun and let me know if you have any problems!