-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import numpy | ||
|
||
class IonPair: | ||
def __init__(self, q: float, a1: float, a2: float, s1: float = 1.0, s2: float = 1.0): | ||
self.q = q | ||
self.a1 = a1 | ||
self.a2 = a2 | ||
|
||
self.mu = q * (a1 + a2) * s1 | ||
self.a = (a1**3 + a2**3)**(1/3) * s2 | ||
|
||
@staticmethod | ||
def _e_born_solvation(q: float, a: float, epsr: float, epsi: float = 1.0) -> float: | ||
"""Solvatation energy from Born theory""" | ||
return q ** 2 / (2*a) * (1/epsr - 1/epsi) | ||
|
||
@staticmethod | ||
def _e_coulomb(q1: float, q2: float, r: float, eps: float) -> float: | ||
"""Coulombic interaction between two charges in a given medium""" | ||
return q1 * q2 / (r*eps) | ||
|
||
@staticmethod | ||
def _e_coulomb2(q1: float, q2: float, mu: float, eps: float) -> float: | ||
"""Coulombic interaction / formation of a dipole""" | ||
return q1 * q2 * numpy.abs(q1) / (eps * mu) | ||
|
||
@staticmethod | ||
def _e_dipole_onsager(mu: float, a: float, epsr: float, epsi: float = 1.0) -> float: | ||
"""Solvatation energy of a dipole in a cavity, according to Onsager""" | ||
return -3*(epsr-epsi)/((2*epsr+1)*(2*epsi+1))*mu**2/a**3 | ||
|
||
def e_born_solvation(self, epsr: float, epsi: float = 1.0) -> float: | ||
return IonPair._e_born_solvation(self.q, self.a1, epsr, epsi) + IonPair._e_born_solvation(-self.q, self.a2, epsr, epsi) | ||
|
||
def e_coulomb(self, epsi: float = 1.0) -> float: | ||
return IonPair._e_coulomb(self.q, -self.q, self.a1 + self.a2, epsi) | ||
|
||
def e_coulomb2(self, eps: float) -> float: | ||
return IonPair._e_coulomb2(self.q, -self.q, self.mu, eps) | ||
|
||
def e_dipole_onsager(self, epsr, epsi: float = 1.0) -> float: | ||
return IonPair._e_dipole_onsager(self.mu, self.a, epsr, epsi) | ||
|
||
def e_pair(self, epsr: float, epsi: float = 1.0) -> float: | ||
return self.e_coulomb2(epsi) + self.e_dipole_onsager(epsr, epsi) - self.e_born_solvation(epsr, epsi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import pandas | ||
import matplotlib.pyplot as plt | ||
import numpy | ||
import sys | ||
import argparse | ||
|
||
from nitroxides.commons import AU_TO_ANG, AU_TO_EV, G_NME4, G_BF4, RADII_BF4, RADII_NME4, dG_DH_cplx_Kx1, AU_TO_KJMOL | ||
from nitroxides.pairs import IonPair | ||
|
||
S1=1 | ||
S2 = 1.5 | ||
|
||
def plot_r_Kx1(ax, data: pandas.DataFrame, family: str, solvent: str, epsilon_r: float, color: str, has_cation: bool = False, has_anion: bool = False): | ||
subdata = data[(data['family'] == family) & (data['solvent'] == solvent) & (data['has_anion'] == has_anion) & (data['has_cation'] == has_cation)] | ||
|
||
if has_anion: | ||
dG_DH = dG_DH_cplx_Kx1(subdata['z'] + 1, subdata['z'], -1, subdata['r_A'] / AU_TO_ANG, subdata['r_AX'] / AU_TO_ANG, RADII_BF4[solvent] / AU_TO_ANG, epsilon_r) # K_01 | ||
dG = (subdata['G_cplx'] - G_BF4[solvent] + dG_DH) * AU_TO_EV | ||
dGp = IonPair( | ||
q=1, | ||
a1=subdata['r_A'] / AU_TO_ANG, | ||
a2=RADII_BF4[solvent] / AU_TO_ANG, | ||
s1=subdata['d_OX'] / (subdata['r_A'] + RADII_BF4[solvent]), | ||
s2=subdata['r_AX']/(subdata['r_A'] **3 + RADII_BF4[solvent]**3)**(1/3) | ||
).e_pair(epsilon_r) | ||
else: | ||
dG_DH = dG_DH_cplx_Kx1(subdata['z'] - 1, subdata['z'], 1, subdata['r_A'] / AU_TO_ANG, subdata['r_AX'] / AU_TO_ANG, RADII_NME4[solvent] / AU_TO_ANG, epsilon_r) # K_21 | ||
dG = (subdata['G_cplx'] - G_NME4[solvent] + dG_DH) * AU_TO_EV | ||
dGp = IonPair( | ||
q=-1, | ||
a1=subdata['r_A'] / AU_TO_ANG, | ||
a2=RADII_NME4[solvent] / AU_TO_ANG, | ||
s1=subdata['d_OX'] / (subdata['r_A'] + RADII_NME4[solvent]), | ||
s2=subdata['r_AX']/(subdata['r_A'] **3 + RADII_NME4[solvent]**3)**(1/3) | ||
).e_pair(epsilon_r) | ||
|
||
ax.plot(dGp, dG, 'o', color=color, label=family.replace('Family.', '')) | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('-i', '--input', default='../data/Data_cplx_Kx1.csv') | ||
parser.add_argument('-o', '--output', default='Data_cplx_r_Kx1.pdf') | ||
|
||
args = parser.parse_args() | ||
|
||
data = pandas.read_csv(args.input) | ||
|
||
figure = plt.figure(figsize=(8, 6)) | ||
ax1, ax2 = figure.subplots(2, 1, sharey=True) | ||
|
||
plot_r_Kx1(ax1, data, 'Family.AMO', 'acetonitrile', 35.,'tab:pink', has_anion=True) | ||
plot_r_Kx1(ax1, data, 'Family.P6O', 'acetonitrile', 35.,'tab:blue', has_anion=True) | ||
plot_r_Kx1(ax1, data, 'Family.P5O', 'acetonitrile', 35., 'black', has_anion=True) | ||
plot_r_Kx1(ax1, data, 'Family.IIO', 'acetonitrile', 35., 'tab:green', has_anion=True) | ||
plot_r_Kx1(ax1, data, 'Family.APO', 'acetonitrile', 35., 'tab:red', has_anion=True) | ||
|
||
ax1.legend(ncols=5) | ||
# ax1.text(38, 1, "Water", fontsize=18) | ||
|
||
plot_r_Kx1(ax2, data, 'Family.AMO', 'acetonitrile', 35.,'tab:pink', has_cation=True) | ||
plot_r_Kx1(ax2, data, 'Family.P6O', 'acetonitrile', 35.,'tab:blue', has_cation=True) | ||
plot_r_Kx1(ax2, data, 'Family.P5O', 'acetonitrile', 35., 'black', has_cation=True) | ||
plot_r_Kx1(ax2, data, 'Family.IIO', 'acetonitrile', 35., 'tab:green', has_cation=True) | ||
plot_r_Kx1(ax2, data, 'Family.APO', 'acetonitrile', 35., 'tab:red', has_cation=True) | ||
|
||
#ax2.text(38, -2, "Acetonitrile", fontsize=18) | ||
|
||
[ax.set_ylabel('$\\Delta G^\\star_{pair}$ (eV)') for ax in [ax1, ax2]] | ||
|
||
# ax2.set_xlabel('$d$ (Å)') | ||
|
||
plt.tight_layout() | ||
figure.savefig(args.output) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.