- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 19
 
Open
Description
NBodySimulator.jl/src/nbody_simulation_result.jl
Lines 135 to 151 in 5c9d950
| 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?
Metadata
Metadata
Assignees
Labels
No labels