-
Notifications
You must be signed in to change notification settings - Fork 55
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
AtomsCalculators.jl compatibility #158
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #158 +/- ##
==========================================
+ Coverage 72.39% 72.53% +0.13%
==========================================
Files 35 35
Lines 5231 5246 +15
==========================================
+ Hits 3787 3805 +18
+ Misses 1444 1441 -3 ☔ View full report in Codecov by Sentry. |
Looks mostly good, but I have couple of comments. Force type promoteYou should also extend function AtomsCalculators.promote_force_type(::Any, mc::MollyCalculator)
return SVector(1., 1., 1.) * mc.force_units |> typeof
end So, check that Number of threads
The second part on this, this is something I was going to ask you in a separate issue than this PR, but here we go... The use of name What actually happens is that Julia thread count is fixed on startup, you cannot change it later. What happens in practice, is that you spawn certain number of tasks and those task get distributed on the active thread pool, which by default is all threads. So, to be accurate, it would be better to have name For optimal use So, if you combine these, you could implement forces like this AtomsCalculators.@generate_interface function AtomsCalculators.forces(
abstract_sys,
calc::MollyCalculator;
neighbors=nothing,
n_tasks=Threads.nthreads(),
kwargs...,
)
sys_nointers = System(abstract_sys, calc.energy_units, calc.force_units)
sys = System(
sys_nointers;
pairwise_inters=calc.pairwise_inters,
specific_inter_lists=calc.specific_inter_lists,
general_inters=calc.general_inters,
neighbor_finder=calc.neighbor_finder,
k=calc.k,
)
nbs = isnothing(neighbors) ? find_neighbors(sys) : neighbors
return forces(sys, nbs; n_threads=t_tasks)
end
AtomsCalculators support in Molly calculationsCan Molly use AtomsCalculators to calculate general forces? |
Thanks for that. I have defined Your point about the threads seems sensible, I will put it on the todo list though as it will need a (breaking) change to the whole package to implement consistently throughout.
Possibly, did you have a particular interface in mind? I guess calculators could be given in the general interaction tuples. |
Yes, this is what I had in my mind. It would make easy to add custom calculators for Molly. For a longer term option, integrating AtomsCalculators more inside Molly is probably the way to go. Like use making force calls unified etc. But, for now adding support for general interactions is enough. |
I'll put using calculators for general interactions on the todo list, I can't estimate when I'll have time though. Feel free to have a go if you have time. |
Is there any update on this? |
I'll try to start it this week. |
I switched general interactions to use the AtomsCalculators.jl interface: 66f1723. In the end it was a fairly small change. |
Maybe @tjjarvinen could check this over quickly to see if it looks okay.