JuliaMolSim / Molly.jl

Molecular simulation in Julia
Other
400 stars 54 forks source link

StaticArrays usage #185

Closed martinmestre closed 6 days ago

martinmestre commented 2 months ago

Hi, thanks for the package. I would like to know in which script or line of code you use StaticArrays, and how do you work with the number of particles which is not know at compile time. Does your ODE solver require a phase-space SVector with dimension proportional to the number of particles ? Thank you very much.

jgreener64 commented 2 months ago

We use Vector{SVector{3, Float64}} or similar to represent coordinates. So the dimension of the SVector is the dimension of the space in which the simulation happens.

martinmestre commented 2 months ago

Thanks a lot! I understand that Vector{SVector{3, Float64}} is a static array, right? When calling the ODE solver, do you need to flatten it into a single array? That is the problem I am having when trying to use solvers in DifferentialEquations.jl. In some part I need to do u[1:n] and that breaks the static format.

jgreener64 commented 2 months ago

Vector{SVector{3, Float64}} is a vector of static arrays, but itself is not static. I'm not so familiar with DifferentialEquations as we don't use it, but you can use reinterpret to get a Vector{Float64} with 3x the length.

martinmestre commented 2 months ago

Thanks a lot!