def _get_energy(simulation, positions):
    """Given an OpenMM simulation and position, return its energy"""
    simulation.context.setPositions(positions)
    state = simulation.context.getState(getEnergy=True, getPositions=True)
    energy = state.getPotentialEnergy()

    return energy