|
74 | 74 | "source": [ |
75 | 75 | "### Exercise\n", |
76 | 76 | "\n", |
| 77 | + "In this exercise you will explore how the Newton-Raphson method performs on a harmonic potential, where we know the analytical solution is $r = r_0 = 0.74$ Å.\n", |
| 78 | + "\n", |
| 79 | + "**Part 1: Define the second derivative**\n", |
| 80 | + "\n", |
77 | 81 | "1. Write a function to calculate the second derivative of a harmonic potential:\n", |
78 | 82 | "\n", |
79 | | - "$$U^{\\prime\\prime} = k$$\n", |
| 83 | + "$$U^{\\prime\\prime}(r) = k$$\n", |
| 84 | + "\n", |
| 85 | + "Note that for a harmonic potential, the second derivative is simply the force constant $k$ and does not depend on $r$.\n", |
| 86 | + "\n", |
| 87 | + "**Part 2: Demonstrate one-step convergence**\n", |
| 88 | + "\n", |
| 89 | + "2. Write code to perform Newton-Raphson optimisation on your harmonic potential starting from $r = 1.0$ Å. Your code should:\n", |
| 90 | + " - Calculate $U'(r)$ and $U''(r)$ at the starting position\n", |
| 91 | + " - Apply the Newton-Raphson equation once: $r_1 = r_0 - \\frac{U'(r_0)}{U''(r_0)}$\n", |
| 92 | + " - Print both the starting position and the position after one step\n", |
| 93 | + " - Compare the result to the analytical solution ($r_0 = 0.74$ Å)\n", |
80 | 94 | "\n", |
81 | | - "2. Show that the Newton-Raphson method finds the optimal bond length for your harmonic potential in one step, irrespective of your starting point.\n", |
| 95 | + "3. Repeat this calculation for at least three different starting positions:\n", |
| 96 | + " - $r = 0.5$ Å (starting below the minimum)\n", |
| 97 | + " - $r = 1.0$ Å (starting above the minimum) \n", |
| 98 | + " - $r = 1.5$ Å (starting well above the minimum)\n", |
82 | 99 | "\n", |
83 | | - "*Hint: Consider why the Newton-Raphson method works perfectly for quadratic functions.*" |
| 100 | + "**Questions to consider:**\n", |
| 101 | + "- Does each starting point converge to exactly $r = 0.74$ Å in one step?\n", |
| 102 | + "- Why does the Newton-Raphson method work perfectly for a harmonic potential? (Hint: Consider what happens when you substitute the derivatives of a quadratic function into the Newton-Raphson equation. The method assumes the function is locally quadratic—what happens when the function is *exactly* quadratic everywhere?)\n", |
| 103 | + "- Will this one-step convergence property hold for other potential energy functions like the Lennard-Jones potential? Why or why not?" |
84 | 104 | ] |
85 | 105 | }, |
86 | 106 | { |
|
0 commit comments