|
30 | 30 | "source": [ |
31 | 31 | "%matplotlib inline\n", |
32 | 32 | "\n", |
33 | | - "import matplotlib\n", |
34 | 33 | "import numpy as np\n", |
35 | 34 | "import matplotlib.pyplot as plt\n", |
36 | 35 | "import pandas as pd\n", |
|
50 | 49 | " if not os.path.isfile(csvfile):\n", |
51 | 50 | " urllib.request.urlretrieve(\n", |
52 | 51 | " \"https://raw.githubusercontent.com/KULL-Centre/CALVADOS/refs/heads/main/examples/single_MDP/input/residues_CALVADOS3.csv\",\n", |
53 | | - " csvfile)\n", |
54 | | - " df = pd.read_csv(csvfile,\n", |
55 | | - " usecols=[\"three\", \"MW\", \"sigmas\", \"sigmas\", \"q\", \"lambdas\"])\n", |
56 | | - " df.columns = ['name', 'mass', 'hydrophobicity', 'sigma', 'charge']\n", |
| 52 | + " csvfile,\n", |
| 53 | + " )\n", |
| 54 | + " df = pd.read_csv(\n", |
| 55 | + " csvfile, usecols=[\"three\", \"MW\", \"sigmas\", \"sigmas\", \"q\", \"lambdas\"]\n", |
| 56 | + " )\n", |
| 57 | + " df.columns = [\"name\", \"mass\", \"hydrophobicity\", \"sigma\", \"charge\"]\n", |
57 | 58 | " df[\"hydrophobicity\"] = df[\"hydrophobicity\"].map(\"!Lambda {:.5}\".format)\n", |
58 | | - " df[\"ε\"] = 0.8368 # kJ/mol\n", |
| 59 | + " df[\"ε\"] = 0.8368 # kJ/mol\n", |
59 | 60 | " df[\"sigma\"] *= 10 # nm -> angstrom\n", |
60 | | - " df.to_json('calvados3.json', orient=\"records\", force_ascii=False)\n", |
| 61 | + " df.to_json(\"calvados3.json\", orient=\"records\", force_ascii=False)\n", |
61 | 62 | " return df" |
62 | 63 | ] |
63 | 64 | }, |
|
87 | 88 | "metadata": {}, |
88 | 89 | "outputs": [], |
89 | 90 | "source": [ |
90 | | - "σ = 6.0 # angstrom\n", |
91 | | - "ε = 0.8368 # kJ/mol\n", |
| 91 | + "σ = 6.0 # angstrom\n", |
| 92 | + "ε = 0.8368 # kJ/mol\n", |
92 | 93 | "λ = 0.5\n", |
93 | | - "rc = 3 * σ # angstrom\n", |
| 94 | + "rc = 3 * σ # angstrom\n", |
| 95 | + "\n", |
94 | 96 | "\n", |
95 | 97 | "def lj(r):\n", |
96 | | - " return 4 * ε * ( (σ/r)**12 - (σ/r)**6 )\n", |
| 98 | + " return 4 * ε * ((σ / r) ** 12 - (σ / r) ** 6)\n", |
| 99 | + "\n", |
97 | 100 | "\n", |
98 | 101 | "def ah(r):\n", |
99 | 102 | " if r > rc:\n", |
100 | 103 | " return 0.0\n", |
101 | | - " if r <= σ * 2**(1/6):\n", |
102 | | - " return lj(r) - λ * lj(rc) + ε * (1-λ)\n", |
| 104 | + " if r <= σ * 2 ** (1 / 6):\n", |
| 105 | + " return lj(r) - λ * lj(rc) + ε * (1 - λ)\n", |
103 | 106 | " return λ * (lj(r) - lj(rc))\n", |
104 | 107 | "\n", |
105 | | - "r = np.linspace(0.9*σ, rc, 50)\n", |
| 108 | + "\n", |
| 109 | + "r = np.linspace(0.9 * σ, rc, 50)\n", |
106 | 110 | "f = np.vectorize(ah)\n", |
107 | 111 | "\n", |
108 | | - "plt.plot(r/σ, lj(r)/ε, label='Lennard-Jones')\n", |
109 | | - "plt.plot(r/σ, f(r)/ε, label='Ashbaugh-Hatch')\n", |
| 112 | + "plt.plot(r / σ, lj(r) / ε, label=\"Lennard-Jones\")\n", |
| 113 | + "plt.plot(r / σ, f(r) / ε, label=\"Ashbaugh-Hatch\")\n", |
110 | 114 | "\n", |
111 | 115 | "plt.xlabel(\"r/σ\")\n", |
112 | 116 | "plt.ylabel(\"u(r)/ε\")\n", |
|
0 commit comments