maltepuetz / ScalingCollapse.jl

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

Implement more than 3 parameters #26

Closed danielsimm closed 5 months ago

danielsimm commented 5 months ago

The package currently supports a maximum of 3 parameters, which is insufficient in some cases. Custom scaling functions can already be created, but the optimization does not work yet. Example for a 5 parameter scaling function given below:

function myfunction(d::ScalingCollapse.Data, p1, p2, p3, p4, p5)

    #  initialize arrays for scaled data
    xs = zeros(length(d.xs))
    ys = zeros(length(d.ys))
    es = zeros(length(d.es))

    # scale data according to p1 and p2
    for (i, x, y, e) in zip(eachindex(d.xs), d.xs, d.ys, d.es)
        xs[i] = (x - p1) * L^p2 * (1 + p3*(x - p1))
        ys[i] = y / ( 1 + p4 * d.L^(p5) ) 
        es[i] = e / ( 1 + p4 * d.L^(p5) ) 
    end

    # create new Data object with scaled data
    return ScalingCollapse.Data(d.L, xs, ys, es)
end

my_sf = ScalingFunction(myfunction; p_names=["K_c", "nu", "α", "β", "irr"])