Homework Assignment
HW 29 — Golden Section Search on the Buckingham Potential
Background
The Buckingham potential is an empirical model for the interaction energy between two neutral atoms or molecules. Unlike the simpler Lennard-Jones potential, it uses an exponential repulsion term. For a pair of atoms separated by distance \(r\), the potential is:
\[
V(r) = \left(\frac{\sigma}{r}\right)^6 - \exp\!\left(-\frac{r}{\sigma}\right)
\]
where \(\sigma\) is a length scale parameter. The equilibrium separation \(r^*\) — the distance at which the atoms are in their lowest-energy configuration — is the minimum of \(V(r)\).
In this assignment you will write general-purpose UDFs for bracketing and GSS, then apply them to locate \(r^*\) for \(\sigma = 10^{-9}\) m (1 nm). The UDFs must accept any function handle as input — do not hard-code \(V(r)\) inside the UDF.
More information about the Buckingham potential: wikipedia.org/wiki/Buckingham_potential
Tasks
Part 1 — Bracketing UDF
-
Write a MATLAB UDF called
bracket_minthat finds a bracket \([a, b, c]\) for the minimum of a 1D function. The inputs should be a function handle, an initial guess \(x_0\), and an initial step size \(\Delta_0\). The outputs should be the three bracket points \(a < b < c\) satisfying \(f(b) < f(a)\) and \(f(b) < f(c)\). - Apply your UDF to the Buckingham potential \(V(r)\) with \(\sigma = 10^{-9}\) m, an initial guess of \(x_0 = 1.5 \times 10^{-9}\) m, and an initial step size of \(\Delta_0 = 10^{-10}\) m. Report the bracket you find.
Part 2 — GSS UDF
-
Write a MATLAB UDF called
gssthat minimizes a 1D function using the Golden Section Search algorithm. The inputs should be a function handle, bracket endpoints \([a, b]\), and a tolerance \(\epsilon\). The output should be the estimated minimum location \(x^*\). -
Apply your
gssUDF to the bracket from Part 1 with a tolerance of \(\epsilon = 10^{-13}\) m. Report the minimum location \(r^*\) and the potential value \(V(r^*)\).
Part 3 — Plot
- Plot \(V(r)\) over a physically meaningful range of \(r\) values. On the same plot, mark the bracket endpoints found in Part 1 (use square markers) and the GSS minimum from Part 2 (use a star marker). Label axes with units and include a legend.
Hints
- Define the Buckingham potential as an anonymous function:
V = @(r) (sigma./r).^6 - exp(-r/sigma);wheresigma = 1e-9. - Be careful with the range of \(r\): as \(r \to 0\), \(V(r) \to +\infty\) due to the repulsive term. Start your plot range at a value where \(V\) is finite.
- The golden ratio parameter is \(\rho = (3 - \sqrt{5})/2 \approx 0.382\). In MATLAB:
rho = (3 - sqrt(5))/2; - Your UDFs should work for any function, not just \(V(r)\). You may verify them on a simpler function before applying to the Buckingham potential.