|
139 | 139 | ], |
140 | 140 | "source": [ |
141 | 141 | "def rad_dist(Y):\n", |
142 | | - " return np.sqrt(np.sum(Y ** 2))\n", |
| 142 | + " return np.sqrt(np.sum(Y**2))\n", |
143 | 143 | "\n", |
144 | 144 | "\n", |
145 | 145 | "fig, ax = plt.subplots(1, 1, figsize=[7, 3])\n", |
|
207 | 207 | "def calc_U_gradient(x, y, q, a=0, b=1, k=0, d=1):\n", |
208 | 208 | " muy, mux = q\n", |
209 | 209 | "\n", |
210 | | - " G1 = np.sum(y - muy) + (a - muy) / b ** 2 # dU/dmuy\n", |
211 | | - " G2 = np.sum(x - mux) + (k - mux) / b ** 2 # dU/dmux\n", |
| 210 | + " G1 = np.sum(y - muy) + (a - muy) / b**2 # dU/dmuy\n", |
| 211 | + " G2 = np.sum(x - mux) + (k - mux) / b**2 # dU/dmux\n", |
212 | 212 | "\n", |
213 | 213 | " return np.array([-G1, -G2])" |
214 | 214 | ] |
|
257 | 257 | " p *= -1\n", |
258 | 258 | " # Evaluate potential and kinetic energies sat start and end of trajectory\n", |
259 | 259 | " current_U = U(x, y, current_q)\n", |
260 | | - " current_K = np.sum(current_p ** 2) / 2\n", |
| 260 | + " current_K = np.sum(current_p**2) / 2\n", |
261 | 261 | " proposed_U = U(x, y, q)\n", |
262 | | - " proposed_K = np.sum(p ** 2) / 2\n", |
| 262 | + " proposed_K = np.sum(p**2) / 2\n", |
263 | 263 | " # Accept or reject the state at end of trajectory, returning either\n", |
264 | 264 | " # the position at the end of the trajectory or the initial position\n", |
265 | 265 | " accept = False\n", |
|
0 commit comments