
{"id":192,"date":"2024-07-31T16:00:01","date_gmt":"2024-07-31T08:00:01","guid":{"rendered":"https:\/\/www.shirui.me\/blog\/?p=192"},"modified":"2024-07-31T16:12:33","modified_gmt":"2024-07-31T08:12:33","slug":"draw-paths-on-energy-landscape","status":"publish","type":"post","link":"https:\/\/www.shirui.me\/blog\/2024\/07\/31\/draw-paths-on-energy-landscape\/","title":{"rendered":"Draw paths on energy landscape"},"content":{"rendered":"\n<p>A path on energy landscape is like:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"657\" src=\"https:\/\/www.shirui.me\/blog\/wp-content\/uploads\/2024\/07\/el-ezgif.com-speed.gif\" alt=\"pathway on energy landscape\" class=\"wp-image-194\"\/><\/figure>\n\n\n\n<p>and this post is a guide to generate such animations.<\/p>\n\n\n\n<p>Step 1: Generate the Energy Landscape<\/p>\n\n\n\n<p>An energy landscape is essentially an energy function $U(\\mathbf{x})$. This function can be created in various ways. For example, you might generate a series of Gaussian functions with random parameters $\\mu_i$, $\\sigma_i$, and weight factors $\\omega_i$. From these, you can construct a probability function $P(\\mathbf{x}) = \\sum_{i=1}^N \\omega_i G(\\mathbf{x}; \\mu_i, \\sigma_i)$. The energy function  $U(\\mathbf{x})$ is then derived using Boltzmann inversion: $U = -k_B T \\log P$ .<\/p>\n\n\n\n<p>In the example above, I generated a series of Mexican hat functions with varying parameters ($a$), ($b$), and locations.<\/p>\n\n\n\n<p>Step 2: Generate the Path<\/p>\n\n\n\n<p>A path is determined by the dynamics of the system, such as $\\dot{\\mathbf{x}} = -\\nabla U(\\mathbf{x})$ or $\\ddot{\\mathbf{x}} &#8211; \\dot{\\mathbf{x}} = -\\nabla U(\\mathbf{x})$. By integrating from a starting point, you can generate a path. In our example, the walker follows a cyclic path, which requires an understanding of the Lagrangian.<\/p>\n\n\n\n<p>A walker on an energy surface from point $A$ to $B$ takes the &#8220;canonical path&#8221; where the Lagrangian is minimized. The probability of the walker being at $A$ at time $t_0$ and reaching $B$ at time $t_1$ is given by:<\/p>\n\n\n\n<p>$$<br>P(\\mathbf{x}_A, t_0 \\mid \\mathbf{x}_B, t_1) = \\frac{1}{Z} \\int_{\\mathbf{x}(t_0) = \\mathbf{x}_A}^{\\mathbf{x}(t_1) = \\mathbf{x}_B} \\mathcal{D}\\mathbf{x} \\exp\\left(-\\int_{t_0}^{t_1} L(\\mathbf{x}, \\dot{\\mathbf{x}}, t) \\, dt\\right)<br>$$<\/p>\n\n\n\n<p>Maximizing this probability implies minimizing the Lagrangian $L$ (saddle point approximation). Given $L = T &#8211; U$ with $T \\propto \\dot{\\mathbf{x}}^2$, we can discretize the integral of $L$ as:<\/p>\n\n\n\n<p>$$<br>L = \\sum_{i=0}^N \\lambda_1 (\\mathbf{x}_{i+1} &#8211; \\mathbf{x}_i)^2 &#8211; U(\\mathbf{x}_i)<br>$$<\/p>\n\n\n\n<p>where $\\mathbf{x}_0 = \\mathbf{x}_A$ and $\\mathbf{x}_N = \\mathbf{x}_B$. Here, $\\lambda_1$ is a hyperparameter controlling the path&#8217;s tightness. Our goal is to find a series of $\\mathbf{x}_i$ that minimizes $L$. This can be achieved using <code>scipy.optimize.minimize<\/code><\/p>\n\n\n\n<p>Step 3. Generate the animiation<\/p>\n\n\n\n<p>The output can be drawn by <code>mayavi<\/code>, in the example I draw the frames of the animation by <code>povray<\/code>, where <code>.pov<\/code> files were generated by <code>mayavi<\/code>. The trajectory is a thick line that slightly shifted higher than the energy landscape surface to ensure a clear view. You can also draw a big point (sphere) at the forefront of a trajectory, to emphasize the walker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A path on energy landscape is like: and this post is a guide to generate such animations. Step 1: Generate the Energy Landscape An energy landscape is essentially an energy function $U(\\mathbf{x})$. This function can be created in various ways. For example, you might generate a series of Gaussian functions with random parameters $\\mu_i$, $\\sigma_i$, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[28,16,18],"class_list":["post-192","post","type-post","status-publish","format-standard","hentry","category-notes","tag-energy-landscape","tag-molecular-dynamics","tag-povray"],"_links":{"self":[{"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/posts\/192","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/comments?post=192"}],"version-history":[{"count":12,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":206,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/posts\/192\/revisions\/206"}],"wp:attachment":[{"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/media?parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/categories?post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shirui.me\/blog\/wp-json\/wp\/v2\/tags?post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}