Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-random Points initialization for fractal_flame method? #33

Open
leios opened this issue Dec 26, 2022 · 0 comments
Open

Non-random Points initialization for fractal_flame method? #33

leios opened this issue Dec 26, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@leios
Copy link
Owner

leios commented Dec 26, 2022

Right now, all the initial points are generated with rand(), but we could do something like...

function grid_gen(n; dims=2, endpoints = [-1,1], ArrayType = Array,
                  FloatType = Float64)

    grid_extents = endpoints[2] - endpoints[1]

    # number of points along any given axis
    # For 2D, we take the sqrt(n) and then round up
    axis_num = ceil(Int, n^(1/dims))

    # Distance between each point
    dx = grid_extents / (axis_num)

    # This is warning in the case that we do not have a square number
    if n^(1/dims) != axis_num
        println("Cannot evenly divide ", n, " into ", dims, " dimensions!")
    end 

    # Initializing the array, particles along the column, dimensions along rows
    a = zeros(FloatType, n, dims)

    # This works by firxt generating an N dimensional tuple with the number
    # of particles to be places along each dimension ((10,10) for 2D and n=100)
    # Then we generate the list of all CartesianIndices and cast that onto a
    # grid by multiplying by dx and subtracting grid_extents/2
    k = 1
    for i in CartesianIndices(Tuple([axis_num for j = 0:(dims-1)]))
        if k <= size(a)[1]
            a[k,:] .= (Tuple(i).-0.5).*dx.+endpoints[1]
        end
        k += 1
    end 

    return Particles(ArrayType(a),
                     ArrayType(zeros(FloatType, n, dims)),
                     ArrayType(zeros(FloatType, n, dims)))
    
end

Another useful idea: use the points from the previous timestep as initial points for the next timestep (do we already do this?). This will allow us to cut the number of steps down as well. Related #26

@leios leios added the enhancement New feature or request label Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant