Skip to content

Commit

Permalink
discuss entropy
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-24 committed Jun 13, 2024
1 parent 5cdfd3d commit 8a6303d
Show file tree
Hide file tree
Showing 5 changed files with 130 additions and 131 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- [ ] xx in Fig. 12?
- [ ] Use correct hammet parameters
- [ ] Figs. S3 & S4
- [ ] Entropy in cplx
- [x] Entropy in cplx
- [ ] Sign $U_q$
- [ ] Extra explanation solv. (diff of $\varepsilon$ is not enough)
- [ ] All tables in the SI should be updated (!)
Expand Down
89 changes: 44 additions & 45 deletions analyses/plot_cplx_Gx1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,35 @@
import argparse

from matplotlib.ticker import AutoMinorLocator, MultipleLocator
from nitroxides.commons import AU_TO_ANG, AU_TO_KJMOL, G_NME4, G_BF4, RADII_BF4, RADII_NME4, C_NITROXIDE, dG_DH_cplx_Kx1, EPSILON_R
from nitroxides.commons import AU_TO_ANG, AU_TO_KJMOL, H_NME4, H_BF4, S_NME4, S_BF4, RADII_BF4, RADII_NME4, C_NITROXIDE, dG_DH_cplx_Kx1, EPSILON_R

T = 298.15
R = 8.3145e-3 # kJ mol⁻¹

def prepare_data(data: pandas.DataFrame, solvent: str):
subdata = data[data['solvent'] == solvent]

dG_DH_k01 = dG_DH_cplx_Kx1(subdata['z'] + 1, subdata['z'] + 1, 1, subdata['r_A_ox'] / AU_TO_ANG, subdata['r_AX_ox'] / AU_TO_ANG, RADII_BF4[solvent] / AU_TO_ANG, EPSILON_R[solvent])
dG_DH_k11 = dG_DH_cplx_Kx1(subdata['z'], subdata['z'], 1, subdata['r_A_rad'] / AU_TO_ANG, subdata['r_AX_rad'] / AU_TO_ANG, RADII_NME4[solvent] / AU_TO_ANG, EPSILON_R[solvent])
dG_DH_k21 = dG_DH_cplx_Kx1(subdata['z'] - 1, subdata['z'] - 1, 1, subdata['r_A_red'] / AU_TO_ANG, subdata['r_AX_red'] / AU_TO_ANG, RADII_NME4[solvent] / AU_TO_ANG, EPSILON_R[solvent])
dH_DH_k01 = dG_DH_cplx_Kx1(subdata['z'] + 1, subdata['z'] + 1, 1, subdata['r_A_ox'] / AU_TO_ANG, subdata['r_AX_ox'] / AU_TO_ANG, RADII_BF4[solvent] / AU_TO_ANG, EPSILON_R[solvent])
dH_DH_k11 = dG_DH_cplx_Kx1(subdata['z'], subdata['z'], 1, subdata['r_A_rad'] / AU_TO_ANG, subdata['r_AX_rad'] / AU_TO_ANG, RADII_NME4[solvent] / AU_TO_ANG, EPSILON_R[solvent])
dH_DH_k21 = dG_DH_cplx_Kx1(subdata['z'] - 1, subdata['z'] - 1, 1, subdata['r_A_red'] / AU_TO_ANG, subdata['r_AX_red'] / AU_TO_ANG, RADII_NME4[solvent] / AU_TO_ANG, EPSILON_R[solvent])

subdata.insert(1, 'dG_cplx_ox', (subdata['G_cplx_ox']- G_BF4[solvent] + dG_DH_k01) * AU_TO_KJMOL)
subdata.insert(1, 'dG_cplx_rad', (subdata['G_cplx_rad'] - G_NME4[solvent] + dG_DH_k11) * AU_TO_KJMOL)
subdata.insert(1, 'dG_cplx_red', (subdata['G_cplx_red'] - G_NME4[solvent] + dG_DH_k21) * AU_TO_KJMOL)
subdata.insert(1, 'dH_cplx_ox', (subdata['H_cplx_ox'] - H_BF4[solvent] + dH_DH_k01) * AU_TO_KJMOL)
subdata.insert(1, 'dH_cplx_rad', (subdata['H_cplx_rad'] - H_NME4[solvent] + dH_DH_k11) * AU_TO_KJMOL)
subdata.insert(1, 'dH_cplx_red', (subdata['H_cplx_red'] - H_NME4[solvent] + dH_DH_k21) * AU_TO_KJMOL)

subdata.insert(1, 'dS_cplx_ox', (subdata['S_cplx_ox'] - S_BF4[solvent]) * AU_TO_KJMOL)
subdata.insert(1, 'dS_cplx_rad', (subdata['S_cplx_rad'] - S_NME4[solvent]) * AU_TO_KJMOL)
subdata.insert(1, 'dS_cplx_red', (subdata['S_cplx_red'] - S_NME4[solvent]) * AU_TO_KJMOL)

return subdata

def plot_Gx1(ax, data: pandas.DataFrame, family: str, color: str):
def plot_Gx1(ax, data: pandas.DataFrame, state: str, family: str, color: str):
subdata = data[data['family'] == family]

x = [int(x.replace('mol_', '')) for x in subdata['name']]

ax.plot(x, subdata['dG_cplx_ox'], 'o', color=color, label=family.replace('Family.', ''))
ax.plot(x, subdata['dG_cplx_rad'], '^', color=color)
ax.plot(x, subdata['dG_cplx_red'], 's', color=color)

def plot_helpline(ax, data):
x = [int(x.replace('mol_', '')) for x in data['name']]
ax.plot(x, data['dG_cplx_ox'], '--', color='black', linewidth=0.8)
ax.bar(x, subdata['dH_cplx_{}'.format(state)], color=color, label=family.replace('Family.', ''))
ax.bar(x, -T * subdata['dS_cplx_{}'.format(state)], edgecolor=color, color='none')
ax.plot(x, subdata['dH_cplx_{}'.format(state)] -T * subdata['dS_cplx_{}'.format(state)], 'o', color=color)


def make_table(f, data: pandas.DataFrame, solvent: str):
Expand Down Expand Up @@ -70,41 +69,41 @@ def make_table(f, data: pandas.DataFrame, solvent: str):

data = pandas.read_csv(args.input)

figure = plt.figure(figsize=(10, 8))
ax1, ax2 = figure.subplots(2, 1, sharey=True, sharex=True)
figure = plt.figure(figsize=(10, 10))
ax1, ax2, ax3 = figure.subplots(3, 1, sharey=True, sharex=True)

subdata_wa = prepare_data(data, 'water')
plot_helpline(ax1, subdata_wa)

plot_Gx1(ax1, subdata_wa, 'Family.AMO', 'tab:pink')
plot_Gx1(ax1, subdata_wa, 'Family.P6O', 'tab:blue')
plot_Gx1(ax1, subdata_wa, 'Family.P5O', 'black')
plot_Gx1(ax1, subdata_wa, 'Family.IIO', 'tab:green')
plot_Gx1(ax1, subdata_wa, 'Family.APO', 'tab:red')
plot_Gx1(ax1, subdata_wa, 'ox', 'Family.AMO', 'tab:pink')
plot_Gx1(ax1, subdata_wa, 'ox', 'Family.P6O', 'tab:blue')
plot_Gx1(ax1, subdata_wa, 'ox', 'Family.P5O', 'black')
plot_Gx1(ax1, subdata_wa, 'ox', 'Family.IIO', 'tab:green')
plot_Gx1(ax1, subdata_wa, 'ox', 'Family.APO', 'tab:red')

ax1.legend(ncols=5)
ax1.set_xlim(0.5,61.5)
ax1.text(38, -10, "Water", fontsize=18)
ax1.xaxis.set_minor_locator(MultipleLocator(2))
ax1.grid(which='both', axis='x')
ax1.plot([0, 62], [0, 0], '-', color='grey')

subdata_ac = prepare_data(data, 'acetonitrile')
plot_helpline(ax2, subdata_ac)

plot_Gx1(ax2, subdata_ac, 'Family.P6O', 'tab:blue')
plot_Gx1(ax2, subdata_ac, 'Family.P5O', 'black')
plot_Gx1(ax2, subdata_ac, 'Family.IIO', 'tab:green')
plot_Gx1(ax2, subdata_ac, 'Family.APO', 'tab:red')

ax2.set_xlabel('Molecule id')
ax2.set_xlim(0.5,61.5)
ax2.text(38, -10, "Acetonitrile", fontsize=18)
ax2.xaxis.set_minor_locator(MultipleLocator(2))
ax2.grid(which='both', axis='x')
ax2.plot([0, 62], [0, 0], '-', color='grey')

[ax.set_ylabel('$\\Delta G^\\star_{cplx}$ (kJ mol$^{-1}$)') for ax in [ax1, ax2]]
ax1.text(5, 60, "N$^+$A$^-$", fontsize=18)

plot_Gx1(ax2, subdata_wa, 'rad', 'Family.AMO', 'tab:pink')
plot_Gx1(ax2, subdata_wa, 'rad', 'Family.P6O', 'tab:blue')
plot_Gx1(ax2, subdata_wa, 'rad', 'Family.P5O', 'black')
plot_Gx1(ax2, subdata_wa, 'rad', 'Family.IIO', 'tab:green')
plot_Gx1(ax2, subdata_wa, 'rad', 'Family.APO', 'tab:red')
ax2.text(5, 60, "N$^\\bullet$C$^+$", fontsize=18)

plot_Gx1(ax3, subdata_wa, 'red', 'Family.AMO', 'tab:pink')
plot_Gx1(ax3, subdata_wa, 'red', 'Family.P6O', 'tab:blue')
plot_Gx1(ax3, subdata_wa, 'red', 'Family.P5O', 'black')
plot_Gx1(ax3, subdata_wa, 'red', 'Family.IIO', 'tab:green')
plot_Gx1(ax3, subdata_wa, 'red', 'Family.APO', 'tab:red')
ax3.text(5, 60, "N$^-$C$^+$", fontsize=18)

[ax.set_ylabel('Thermochemical contribution (kJ mol$^{-1}$)') for ax in [ax1, ax2, ax3]]
[ax.xaxis.set_minor_locator(MultipleLocator(2)) for ax in [ax1, ax2, ax3]]
[ax.grid(which='both', axis='x') for ax in [ax1, ax2, ax3]]
[ax.plot([0, 62], [0, 0], '-', color='grey') for ax in [ax1, ax2, ax3]]

ax3.set_xlabel('Molecule id')

plt.tight_layout()
figure.savefig(args.output)
Loading

0 comments on commit 8a6303d

Please sign in to comment.