I would like to know if the following script can be simplified? Thank you!
def charge(atom, r_12):
#Defining the charge
if atom == "C":
E = energy(-4, r_12)
if atom == "N":
E = energy(-3, r_12)
if atom == "Cs" or atom == "H" :
E = energy(1, r_12)
if atom == "Ge" or atom == "Pb" or atom == "Si" :
E = energy(2, r_12)
if atom == "Br" or atom == "I" :
E = energy(-1, r_12)
if atom == "X":
E = energy(-2, r_12)
return E
The energy(q_ion, r_12) is just another function I defined for calculating the interaction energy and m is the math package in python.
def energy(q_ion, r_12):
#Calculating the energy
Q = -1
l = 6
E = (Q * q_ion * m.erf(r_12 / l)) / r_12
return E