JuliaMolSim / Molly.jl

Molecular simulation in Julia
Other
372 stars 51 forks source link

Access coordinates of different time steps and use it for differential learning. #47

Closed moradza closed 1 year ago

moradza commented 2 years ago

I am interested in differential learning for problems like mean_min_distance. First, great job in developing the package! How can I use multiple steps from a single simulation to calculate mean_min_distance? when I use logger data, the gradient is nothing, which makes sense. Any help or tutorial is highly appreciated.

jgreener64 commented 2 years ago

Great question, I am currently thinking about how to do this myself. I think I have a way, which is rather hacky since Zygote doesn't support mutation. I'll try and upload an example in the next few days.

The reason the gradients are nothing at the minute is that all loggers are marked as non-differentiable with

@non_differentiable run_loggers!(args...)

which was done since all the loggers currently mutate, and as mentioned that would error with Zygote.

Let me know how you get on with differentiable simulations. There are a lot of rough edges right now, but it's under heavy development and I'd be interested to see how people are using it. I'd advise being on the master branch to get the latest updates.

moradza commented 2 years ago

I see! Please let me know when you upload the example. I am going to use it in coarse-graining applications in a similar fashion as this repository . They also got around velocity Verlet, but I prefer to do the project in Julia instead of python at the moment. Ping me if there is a specific development, I am new to Julia but eager to work on it.

jgreener64 commented 2 years ago

I added some docs on how to do this, see the end of this section: https://juliamolsim.github.io/Molly.jl/dev/differentiable/#General-interactions.

Basically you need to run the simulation in chunks and accumulate the loss values into a variable.

moradza commented 2 years ago

I will take a look thanks!