Skip to content

ScalingCollapse.jlAutomatic finite-size scaling

Find the critical point and exponents that collapse data from many system sizes onto one master curve, in pure Julia.

ScalingCollapse.jlScalingCollapse.jl

What is ScalingCollapse.jl? ​

Near a continuous phase transition, an observable measured in systems of linear size follows a scaling form such as

Plotted against   and multiplied by , the curves of all system sizes then fall onto one master curve , but only for the right values of , and . ScalingCollapse.jl finds these values for you: it measures how well the rescaled curves collapse, minimizes this measure over the parameters, and estimates their errors.

julia
using ScalingCollapse
using Random

# synthetic data with T_c = 2.0, ν = 1.0 and β = 0.125
F(z) = 1 / (1 + exp(2z))
Ts = collect(range(1.8, 2.2; length=41))
Ls = [16, 32, 64, 128]
ys = [L^(-0.125) .* F.((Ts .- 2.0) .* L) .+ 0.002 .* randn(Xoshiro(L), 41) for L in Ls]

sp = ScalingProblem(Ts, ys, Ls;
    sf=ScalingFunction(:xy; p_names=["T_c", "nu", "beta"]),
    p_space=[1.9:0.02:2.1, 0.5:0.1:1.5, 0.0:0.05:0.5],
)
ScalingProblem
    Scaling function:
        x -> (x - T_c) * L^(1/nu)
        y -> y * L^(beta/nu)
    Optimal parameters:
        T_c = 2.0000170402418176 ± 0.00041621320597460946
        nu = 1.0483092977275075 ± 0.0388852776812044
        beta = 0.12956803324166713 ± 0.007245270920234711
    Optimization interval dx:
        -Inf < x < Inf
    Searched parameter space:
        T_c ∈ 1.9:0.02:2.1
        nu ∈ 0.5:0.1:1.5
        beta ∈ 0.0:0.05:0.5
julia
using CairoMakie

colors = cgrad(:Blues)[range(0.35, 1.0; length=length(Ls))]
fig = Figure(size=(760, 320))
ax1 = Axis(fig[1, 1]; xlabel=L"T", ylabel=L"Y", title="data")
ax2 = Axis(fig[1, 2]; xlabel=L"(T - T_c)\,L^{1/\nu}", ylabel=L"Y\,L^{\beta/\nu}", title="collapse")
xs_scaled, ys_scaled, _, _ = scaled_data(sp)
for i in eachindex(Ls)
    scatterlines!(ax1, Ts, ys[i]; color=colors[i], markersize=6, label="L = $(Ls[i])")
    scatter!(ax2, xs_scaled[i], ys_scaled[i]; color=colors[i], markersize=7)
end
xlims!(ax2, -6, 6)
Legend(fig[1, 3], ax1)
fig

Installation ​

ScalingCollapse.jl is a registered Julia package (Julia 1.9 or later):

julia
using Pkg
Pkg.add("ScalingCollapse")

Where to go next ​

Development status

ScalingCollapse.jl is still young. Expect breaking changes between minor versions, and please open an issue if you run into a problem.

Citing ​

If you use ScalingCollapse.jl in your research, please cite it via its Zenodo record, doi:10.5281/zenodo.10712427.