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

potential_energy analysis function limited to built-in potential types #44

Open
jrdegreeff opened this issue Apr 20, 2021 · 0 comments
Open

Comments

@jrdegreeff
Copy link

function potential_energy(coordinates, simulation::NBodySimulation)
e_potential = 0
system = simulation.system
n = length(system.bodies)
if :lennard_jones keys(system.potentials)
p = system.potentials[:lennard_jones]
(ms, indxs) = obtain_data_for_lennard_jones_interaction(system)
e_potential += lennard_jones_potential(p, indxs, coordinates, simulation.boundary_conditions)
end
if :electrostatic keys(system.potentials)
p = system.potentials[:electrostatic]
(qs, ms, indxs, exclude) = obtain_data_for_electrostatic_interaction(simulation.system)
e_potential += electrostatic_potential(p, indxs, exclude, qs, coordinates, simulation.boundary_conditions)
end
e_potential
end

The current implementation for calculating the potential energy of the system is hardcoded to only recognize a couple of built-in potential functions. NBS supports adding custom potentials for the simulation, but they can't be included in analysis of the energies afterwards. Could this be extended to custom potentials through dynamic dispatch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant