SimulationClient Package¶
SimulationClient.SimulationClient Module¶
-
class
SimulationClient.SimulationClient.SimulationClient(simulation_client_id, server_host, server_port, authkey, metric_server_addresses, configuration_file, logfile=None, log_level=20, callback_delay=1.0)[source]¶ The purpose of this object is to compute local geodesics using a modified BFGS method. The object receives a pair of end points to compute the local geodesic between. The simulation client then returns a new position for the node. The simulation client needs the value of the potential and it’s gradient function, in order to achieve this it makes calls to it’s assigned SimulationPotential servers.
-
CONFIGURATION¶ dict
A dictionary containing the parsed values from the file in configuration_file.
-
CURVE_ADDRESS¶ str, int
A tuple containing a string representing the hostname/IP and an integer for the running SimulationServer.
-
AUTHKEY¶ str
A string containing the authorisation key for the listener method.
-
DELAY¶ float
The length of time the SimulationClient should wait if there is no new available jobs, before attempting to contact the SimulationServer again.
-
METRIC_SERVERS¶ A list containing tuples of addresses for SimulationPotential instances.
-
ID¶ str
A string that uniquely identifies the client amongst all other clients in the computation.
-
MASS_MATRIX¶ numpy.array
A NumPy matrix containing the mass matrix of the molecular system. Produced automatically from the Atomistic Simulation Environment.
-
__init__(simulation_client_id, server_host, server_port, authkey, metric_server_addresses, configuration_file, logfile=None, log_level=20, callback_delay=1.0)[source]¶ The constructor for the SimulationClient class.
Note
This class is intended to be used in conjunction with running SimulationServer and SimulationPotential objects. It will cause a runtime exception if this condition isn’t satisfied.
Parameters: - simulation_client_id (str) – A string that uniquely identifies the client amongst all other clients in the computation.
- server_host (str) – The TCP/IP hostname of the running SimulationServer instance.
- server_port (int) – The port number that the SimulationServer instance is communicating on.
- authkey (str, optional) – Authentication key used to secure process communications. Default to None for local computations to increase speed.
- metric_server_addresses – A list containing tuples of the type (str, int) containing the hostnames and ports for the running SimulationPotential instances.
- 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.
- callback_delay (float) –
- The length of time the SimulationClient should wait if there is no new available jobs, before attempting
- to contact the SimulationServer again.
-
SimulationClient.CustomBFGS Module¶
-
SimulationClient.CustomBFGS.find_geodesic_midpoint(start_point, end_point, number_of_inner_points, basis_rotation_matrix, tangent_direction, codimension, metric_server_addresses, mass_matrix, authkey, gtol=1e-05)[source]¶ This function computes the local geodesic curve joining start_point to end_point using a modified BFGS method. The modification arises from taking the implementation of BFGS and re-writing it to minimise the number of times the metric function is called.
Parameters: - start_point (numpy.array) – The first end point of the curve.
- end_point (numpy.array) – The last end point of the curve.
- number_of_inner_points (int) – The number of nodes along the curve, less the end points.
- basis_rotation_matrix (numpy.array) – The matrix computed as a result of the orthogonal_tangent_basis function.
- tangent_direction (numpy.array) – The tangent direction as computed by the SimulationClient.
- codimension (int) – The dimension of the problem minus 1. Computed from the atomistic simulation environment.
- metric_server_addresses – A list of tuples of the form (str, int) containing the hostnames and port numbers of the SimulationPotential instances.
- mass_matrix (numpy.array) – A diagonal NumPy array containing the masses of the molecular system as computed in the SimulationClient object.
- authkey (str) – The password used in order to communicate with the SimulationPotential instances.
- gtol (optional float) – The tolerance threshold for the BGFS method.
Returns: The midpoint along the local geodesic curve.
Return type: numpy.array
SimulationClient.Geometric Module¶
-
SimulationClient.Geometric.GradLength(curve, metric, number_of_inner_nodes, mass_matrix, basis_rotation_matrix)[source]¶ This function computes the gradient of the length of a curve object in the isotropic Riemannian length functional with metric coefficient metric.
Parameters: - curve (Curve) – The curve for which the length is to be computed.
- metric – A list of float values representing the values of the metric along the curve. We have that metric[i] = a(curve[i]) where a is the metric coefficient.
- number_of_inner_nodes (int) – The number of nodes in the curve object, less the end points.
- mass_vector (numpy.array) – A NumPy array containing the masses of the molecular system as computed in the SimulationClient object.
Returns: The gradient of the length functional on the curve with metric values in metric.
Return type: numpy.array
-
SimulationClient.Geometric.Length(curve, metric, number_of_inner_nodes, mass_matrix)[source]¶ This function computes the length of a curve object in the isotropic Riemannian length functional with metric coefficient metric.
Parameters: - curve (Curve) – The curve for which the length is to be computed.
- metric – A list of float values representing the values of the metric along the curve. We have that metric[i] = a(curve[i]) where a is the metric coefficient.
- number_of_inner_nodes (int) – The number of nodes in the curve object, less the end points.
- mass_vector (numpy.array) – A NumPy array containing the masses of the molecular system as computed in the SimulationClient object.
Returns: The length of the curve with metric values in metric.
Return type: float
-
SimulationClient.Geometric.norm(x, matrix)[source]¶ Computes the value of sqrt(<x, matrix*x>).
Parameters: - x (numpy.array) – A vector, stored as a NumPy array, to compute the norm for.
- matrix (numpy.array) – A matrix, stored as a NumPy array, used in the computation of <x, matrix*x>.
Returns: The value of sqrt(<x, matrix*x>).
Return type: float
-
SimulationClient.Geometric.norm_gradient(x, matrix)[source]¶ Computes the gradient of sqrt(<x, matrix*x>).
Parameters: - x (numpy.array) – A vector, stored as a NumPy array, to compute the norm for.
- matrix (numpy.array) – A matrix, stored as a NumPy array, used in the computation of <x, matrix*x>.
Returns: The gradient of sqrt(<x, matrix*x>).
Return type: numpy.array
SimulationClient.LinearAlgebra Module¶
-
SimulationClient.LinearAlgebra.mass_norm(vector, mass_matrix)[source]¶ This function computes the inner product of vector with mass_matrix times vector.
Parameters: - vector (numpy.array) – The curve for which the length is to be computed.
- mass_matrix (numpy.array) – A diagonal NumPy array containing the masses of the molecular system as computed in the SimulationClient object.
Returns: The value of <vector, mass_matrix * vector>
Return type: float
-
SimulationClient.LinearAlgebra.orthonormal_tangent_basis(tangent, dimension)[source]¶ This function computes the inner product of vector with mass_matrix times vector.
Parameters: - tangent (numpy.array) – The tangent direction along the local geodesic.
- dimension (int) – The dimension of the problem. Computed from the atomistic simulation environment.
Returns: An orthonomal matrix with the first column parallel to tangent.
Return type: numpy.array
-
SimulationClient.LinearAlgebra.shifts_to_curve(start_point, end_point, shift_points, number_of_inner_points, basis_rotation_matrix, tangent_direction, codimension)[source]¶ This function produces a curve in N-dimensional space when it is initially described as a graph over the first co-ordinate direction.
Parameters: - start_point (numpy.array) – The first end point of the curve.
- end_point (numpy.array) – The last end point of the curve.
- shift_points (numpy.array) – Given a point x_N along the curve, the value shift_points[i] is x_N - <x_N, tangent_direction>tangent_direction. That is the orthogonal component of x_N when projected against the tangent_direction.
- number_of_inner_points (int) – The number of nodes along the curve, less the end points.
- basis_rotation_matrix (numpy.array) – The matrix computed as a result of the orthogonal_tangent_basis function.
- tangent_direction (numpy.array) – The tangent direction as computed by the SimulationClient.
- codimension (int) – The dimension of the problem minus 1. Computed from the atomistic simulation environment.
Returns: A list of NumPy arrays describing the position of the curve.
Return type: list
SimulationClient.MetricValues Module¶
-
SimulationClient.MetricValues.get_metric(curve, number_of_inner_points, metric_server_addresses, authkey)[source]¶ This function distributes the task of computing the metric values along the curve using the SimulationPotential instances.
Parameters: - curve (numpy.array) – A list of NumPy arrays representing a local geodesic.
- number_of_inner_points (int) – The number of points along the curve, less two.
- metric_server_addresses – A list of tuples of the form (str, int) containing the hostnames and port numbers of the SimulationPotential instances.
- authkey (str) – The password used in order to communicate with the SimulationPotential instances.
Returns: A list of float values called metric where metric[i] = a(curve[i]).
Return type: list
-
SimulationClient.MetricValues.shutdown_metric(metric_server_addresses, authkey)[source]¶ This function tells all of the SimulationPotential instances running on the addresses in metric_server_addresses to shutdown. This is called when a SimulationClient instance shuts down.
Parameters: - metric_server_addresses – A list of tuples of the form (str, int) containing the hostnames and port numbers of the SimulationPotential instances.
- authkey (str) – The password used in order to communicate with the SimulationPotential instances.
Returns: The length of the curve with metric values in metric.
Return type: float