# How to calculate the computational time required for a MD simulation

I have a ligand and receptor to simulate with MD. These are my specs:

1. Receptor has 4674 atoms,
2. Ligand has 273 atoms
3. CHARMM force field
4. MD software GROMACS
5. Computing machine: Amazon g4dn.xlarge (1 GPU 4vCPUs)
6. 10ns of dynamics$$^*$$

What's the time needed to run the MD (i.e. in hr, days)? How to calculate and is there a formula to calculate it? I need to estimate the cost of using the Amazon machine.

$$^*$$ I'm not sure the reasonable value for the timing required for the dynamics. Please advice too.

The simulation speed and efficiency depends on the hardware and software that you use. Things that you should keep in mind are,

1. Every computer is unique in its ability. So only someone with access to the exact same hardware (processor, gpu etc.) can test this out and tell you.
2. As far as I know, there is no established method of calculating the computational time required for a calculation. But you can test this for yourself and get a scaling graph of how the number of atoms and cpu cores change the computational efficiency (This is valid only for a similar use case and so do not expect someone else's work to give a proper prediction).

That said, there actually are some things that you can try. First reduce the amount of dynamics that you simulate from 10ns to say a several hundred pico seconds thereby reducing the computational time required. This way, you can achieve a very small calculation, at the end of which, you would see the computational speed prediction from the MD software (usually in the form of hours/ns or ns/day). Once you know this, you can get an idea of how long the calculation might take for a 10ns dynamics length. However, do keep note that this estimation could have a small error and so it would be best to have some extra time allocated.

When doing this, remember that if the calculation writes files to the hard drive frequently, the time taken to write those files would slow the simulation down. This would be slightly difficult to account for in the initial short run. Also keep in mind that different ensembles have different computational speeds. For example, in my workstation, the NVE ensemble can be calculated around 50% faster than the NPT ensemble. However I do not know whether this is universal or not.

Also do note that as you proceed with your work, you would gain experience regarding the time taken for each calculation. With that experience, you would be able to get a pretty good guess of how long it takes (as long as the computer remains the same).

Since you seem to be just starting MD calculations, keep in mind that more cores is not always faster. Sometimes increasing the number of cores can reduce the computational efficiency by increasing communication time. So it would be best to try changing the number of cores allocated to see the configuration that gives the best performance.

• @scamander In case a more extended discussion is needed for clarification, I moved the comments here to chat
– Tyberius
Nov 1, 2021 at 16:48

Short answer: Do a short test run for performance estimates. Once you're familiar with a specific hardware/software combination, you may be able to estimate based on the size of the system, but the general advice (especially with hardware you're not familiar with) is to do a short benchmarking run.

Gromacs-specific practical advice: Use the -maxh option to gmx mdrun (documentation). This will allow you to run for a fixed amount of wall time, letting you benchmark for a fixed cost (say, 1 hour compute time). You can run for 1 hour, and get a good estimate of ns/day by multiplying the result number of ns by 24, and use that in production run cost estimates. (You probably can get a decent estimate from 10-15 minutes; much less than that may not give accurate results.) Note: performance can vary from run to run, even on the same hardware. This is especially true if you use some of Gromacs's tools to auto-optimize performance.

Another option: since you'll typically want to equilibrate in NVT and/or NPT before starting a production run, you can use the equilibration run as your benchmark.

Side notes: Not specific to the question here, but I see a couple red flags in the description. (1) You don't list waters. Are you intending to run with an implicit water model? If not, then keep in mind the majority of your atoms will be water. This is especially true if you're studying the ligand binding/unbinding process, where you typically need to pad with more water than just a globular protein with the same number of residues (you need a simulation box big enough for the fully unbound ligand-receptor system). (2) 10ns is a pretty short run. For biomolecular systems with molecular mechanics force fields, I would usually do multiple runs (minimum 4, typically 8-10) of at least 100ns each, and that's just to characterize a stable basin. If you're interested in transitions (binding/unbinding) the timescales are typically much longer, and in many cases aren't feasible by direct molecular dynamics -- enhanced sampling methods are required.