Hi,
I tried implementing a custom coupling function analogue to the documentation but did not get it to work.
The issue seems to be, that the apply_coupling method is not found, I get a "ERROR: LoadError: MethodError: no method matching apply_coupling!".
Can you help me with that? Did I miss something there?
Thanks!
I tried to provide a minimal (not working) example from code blocks in the documentation:
using Molly
struct MyCoupler
# Any properties, e.g. a target temperature or coupling constant
end
function apply_coupling!(sys, coupling::MyCoupler, sim, neighbors, step_n;
n_threads=Threads.nthreads())
# Do something to the simulation, e.g. scale the velocities
# Return whether the coupling has invalidated the currently stored forces,
# for example by changing the coordinates
recompute_forces = false
return recompute_forces
end
custom_coupler = MyCoupler()
n_atoms = 100
atom_mass = 10.0u"u"
atoms = [Atom(mass=atom_mass, Ļ=0.3u"nm", Ļµ=0.2u"kJ * mol^-1") for i in 1:n_atoms]
boundary = CubicBoundary(2.0u"nm") # Periodic boundary conditions with a 2 nm cube
coords = place_atoms(n_atoms, boundary; min_dist=0.3u"nm") # Random placement without clashing
temp = 100.0u"K"
velocities = [random_velocity(atom_mass, temp) for i in 1:n_atoms]
pairwise_inters = (LennardJones(),) # Don't forget the trailing comma!
sys = System(
atoms=atoms,
coords=coords,
boundary=boundary,
velocities=velocities,
pairwise_inters=pairwise_inters,
)
simulator = VelocityVerlet(dt=0.001u"ps", coupling=custom_coupler)
simulate!(sys, simulator, 1_000)
Hi, I tried implementing a custom coupling function analogue to the documentation but did not get it to work. The issue seems to be, that the apply_coupling method is not found, I get a "ERROR: LoadError: MethodError: no method matching apply_coupling!". Can you help me with that? Did I miss something there? Thanks!
Full error message:
I tried to provide a minimal (not working) example from code blocks in the documentation: