#* **************************************************************************
#*
#* CDTK, Chemical Dynamics Toolkit
#* A modular system for chemical dynamics applications and more
#*
#* Copyright (C) 2011, 2012, 2013, 2014, 2015, 2016
#* Oriol Vendrell, DESY, <oriol.vendrell@desy.de>
#*
#* Copyright (C) 2017, 2018, 2019
#* Ralph Welsch, DESY, <ralph.welsch@desy.de>
#*
#* Copyright (C) 2020, 2021, 2022, 2023
#* Ludger Inhester, DESY, ludger.inhester@cfel.de
#*
#* This file is part of CDTK.
#*
#* CDTK is free software: you can redistribute it and/or modify
#* it under the terms of the GNU General Public License as published by
#* the Free Software Foundation, either version 3 of the License, or
#* (at your option) any later version.
#*
#* This program is distributed in the hope that it will be useful,
#* but WITHOUT ANY WARRANTY; without even the implied warranty of
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#* GNU General Public License for more details.
#*
#* You should have received a copy of the GNU General Public License
#* along with this program. If not, see <http://www.gnu.org/licenses/>.
#*
#* **************************************************************************
import math
import numpy as np
"""
Coulomb potential between point particles
"""
[docs]
class Coulomb(object):
def __init__(self,**opts):
self.natoms = opts.get('natoms',0)
self.masses = opts.get('masses',None)
self.charges = opts.get('charges',None)
def _potential(self,x):
xx = np.asarray(x)
xx.shape = (self.natoms,3)
v = 0.0
for i in range(0,self.natoms-1):
for j in range(i+1,self.natoms):
rij = xx[i] - xx[j]
Rij = math.sqrt(np.dot(rij,rij))
qq = self.charges[i] * self.charges[j]
vij = qq/Rij
v = v + vij
xx.shape = (3*self.natoms,)
return v
[docs]
def getPotentialFunction(self):
def f(x):
return self._potential(x)
return f