Interactive molecular dynamics

When running BioSimSpace interactively, e.g. in a Jupyter notebook, processes are run in the background allowing you to continue with your work, uninterrupted. At any time, it is possible to query the running process for information.

(Here we assume that you have initalised a BioSimspace process, see here for details.)

To see whether the process is running:


To see how many minutes the process has been running for:


To see if any errors have been raised:


To print the last 50 lines of standard output:


To print the last 10 lines of standard error:


It’s also possible to get standard output and error as a list of strings:

stdout = process.getStdout()
stderr = process.getStderr()

If you want to kill the process, run:


Depending on the simulation protocol, it is also possible to query the process for a wide range of thermodynamic information, such as the current energy or pressure. For example, to print a nicely formatted message showing the current simulation time in nanoseconds, the temperature in Kelvin, and the total energy in kcal per mol, run:

 print("%.2f ns, %.2f K, %.2f kcal/mol" % (process.getTime(), process.getTemperature(), process.getTotalEnergy()))

It is also possible to get the current molecular system. This will be generated from the latest restart file.

system = process.getSystem()

Since we are working interactively, any of the process method calls will return the latest data from the running process. In some cases it might be necessary to wait for the process to finish before getting the information. This can be achieved by passing the block keyword argument to any of the methods, e.g:

# Wait for the process to finish and return the final molecular system.
system = process.getSystem(block=True)

(Note that block is False by default when working interactively. In batch mode the default is True.)

As well as querying the most recent data record it is also possible to get time series information. BioSimSpace automatically tracks the log files and standard output of running process and builds a database of all output records. To get the time series of pressure records, run:


(Note that the methods that are available to you are dependent on the process and protocol. To see what’s available, run help(process) on your Process object.)