SimulationPotential Module

class SimulationPotential.SimulationPotential.SimulationPotential(configuration_file, logfile=None, log_level=20, hostname='localhost', port=5001, authkey='password')[source]

The purpose of this object is to provide an independent service that computes the forces and potential energy for the system. The object listens for a TCP connection containing a molecular configuration. The forces and potential energy are then sent using TCP via the Listener object provided by the multiprocessing package. If a kill code is received then the server shuts down.

CONFIGURATION

dict

A dictionary containing the parsed values from the file in configuration_file.

ADDRESS

str, int

A tuple containing a string representing the hostname/IP and an integer for the service port.

AUTHKEY

str

A string containing the authorisation key for the listener method.

__init__(configuration_file, logfile=None, log_level=20, hostname='localhost', port=5001, authkey='password')[source]

The constructor for the SimulationPotential class.

Note

This class is intended to be used in conjunction with running SimulationServer and SimulationClient objects. See the run_potential_server method for more details.

Parameters:
  • configuration_file (str) – Directory and filename of the configuration file.
  • logfile (str, optional) – Directory and filename of the log file. Is created if doesn’t exist, overwritten if it does.
  • log_level (int, optional) – Specify level of logging required as described in the logging package documentation.
  • hostname (str, optional) – Hostname/IP which the SimulationPotential will run on. Default value is ‘localhost’ to run simulations locally.
  • port (int, optional) – Port number which the SimulationPotential will run on. Default value is 5000, just because.
  • authkey (str, optional) – Authentication key used to secure process communications. Default to None for local computations to increase speed.
run_potential_server(small_number=1e-12)[source]

Start the instance of SimulationPotential ready to receive requests for metric values.

Note

This class assumes that after starting there will be at least one running instance of SimulationClient pointing to ADDRESS, otherwise this process will remain indefinitely blocked.

Parameters:small_number (str) – A small number used to represent the zero metric value. This is used instead of zero to prevent divide by zero errors when evaluating the gradient of the metric.