The question below describes my plan to make a basic molecular dynamics calculation using a Python script rather than a canned, self-contained program.

There seems to be three parts:

  1. a model of the honeycomb net and substrate atoms
  2. an expression for energy based on atomic positions
  3. an energy minimization procedure (the topic of this question)

The two procedures I can imagine implementing are

  1. Monte-carlo method jiggle the positions randomly using some pseudo-temperature parameter, keep the new positions if energy goes down and flip a coin about keeping the new positions if higher based on *how much higher) it is.
  2. Kinematically using a damped differential equation and a standard ODE solver for all atomic positions.

These are general tools that I'm aware of and know how to implement in general and I can start with these no problem. But are these the numerical techniques that proper classical molecular dynamical simulations use, or are there different and/or better ways?


My nascent DIY model, from here (click for larger)

enter image description here

  • 2
    $\begingroup$ Just FYI, "molecular dynamics" refers to the method that simulates the time evolution of a system by numerically integrating its equations of motion. Energy minimization (aka "geometry optimization") is something different. The umbrella term you might be looking for is "molecular mechanics". $\endgroup$
    – TooTea
    Mar 3, 2022 at 22:13
  • $\begingroup$ @TooTea yes I see what you mean, dynamics means what it means. However in practice it looks like at least some "MD people" use MD to reference either sometimes whether they should or shouldn't cf. this answer. Personally I'll pursue the FIRE (inertial relaxation (with damping)) method I think. It will make for better-looking movies :-) e.g. youtu.be/WFCvkkDSfIU?t=218 $\endgroup$
    – uhoh
    Mar 3, 2022 at 22:22

1 Answer 1


AFAIK most MD codes do something like conjugate gradients or BFGS for energy minimization. Your option 1 is Metropolis Monte Carlo, while option 2 sounds like the FIRE algorithm.

However, why implement something yourself, when there is a multitude of solvers already available in e.g. scipy? See https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html, for example. You could just interface to these routines and get a lot of functionality "for free"?

  • 2
    $\begingroup$ I for one, like making things myself. If you understand how to do something, it shouldn't take long. If it does, you were always just kidding yourself that you understood it and had no right to be using a black box on the pretext of simply using a more efficient code because you understood the fundamentals. $\endgroup$
    – B. Kelly
    Mar 3, 2022 at 14:10
  • 1
    $\begingroup$ Oh! somehow I totally misread your very clear suggestion. Yes in this question I already call scipy.optimize.minimize and it certainly makes complete sense not to reinvent the wheel when it comes to numerical algorithms necessarily implemented in complied code. What I want to implement myself is the model setup and energy evaluation function, and to do that well I'll need to understand the optimizer. Yes for option 2 FIRE (inertial relaxation) is just the kind of thing I was thinking of. Your answer is exactly what I needed; thank you! $\endgroup$
    – uhoh
    Mar 3, 2022 at 22:10
  • 2
    $\begingroup$ Writing personal optimizers can be very helpful! For harder problems where off-the-shelf optimizers failed, I had success writing my own that was kind of a managed-wrapper around others: my optimizer would wrap the black-box function being optimized, allowing the off-the-shelf optimizers to do their thing when they were working well enough. When they'd start having problems, I'd trace the iteration-history to make some new guesses (e.g., to get out of a weird pot-hole), then put in some transforms to condition the model. Kinda like being a driver of a mostly-self-driving car. $\endgroup$
    – Nat
    Mar 3, 2022 at 22:33
  • $\begingroup$ fyi I've just asked Basics of configuration initialization strategies used in molecular dynamics? $\endgroup$
    – uhoh
    Mar 3, 2022 at 22:39
  • $\begingroup$ FIRE looks surprisingly easy to implement, I think I will give it a try. Thanks again! $\endgroup$
    – uhoh
    Mar 5, 2022 at 9:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .