def __init__(self, latency=1.0, name="", pars=None, dopbc=True, active=np.array([-1]), interface=None): """Initialises FFSocket. Args: latency: The number of seconds the socket will wait before updating the client list. name: The name of the forcefield. pars: A dictionary used to initialize the forcefield, if required. Of the form {'name1': value1, 'name2': value2, ... }. dopbc: Decides whether or not to apply the periodic boundary conditions before sending the positions to the client code. interface: The object used to create the socket used to interact with the client codes. """ # a socket to the communication library is created or linked super(FFSocket, self).__init__(latency, name, pars, dopbc, active) if interface is None: self.socket = InterfaceSocket() else: self.socket = interface self.socket.requests = self.requests
def fetch(self): """Creates a ForceSocket object. Returns: A ForceSocket object with the correct socket parameters. """ if self.threaded.fetch() == False: raise ValueError("FFSockets cannot poll without threaded mode.") # just use threaded throughout return FFSocket( pars=self.parameters.fetch(), name=self.name.fetch(), latency=self.latency.fetch(), dopbc=self.pbc.fetch(), active=self.activelist.fetch(), threaded=self.threaded.fetch(), interface=InterfaceSocket( address=self.address.fetch(), port=self.port.fetch(), slots=self.slots.fetch(), mode=self.mode.fetch(), timeout=self.timeout.fetch(), match_mode=self.matching.fetch(), exit_on_disconnect=self.exit_on_disconnect.fetch()))
def fetch(self): """Creates a ForceSocket object. Returns: A ForceSocket object with the correct socket parameters. """ return FFSocket(pars = self.parameters.fetch(), name = self.name.fetch(), latency = self.latency.fetch(), dopbc = self.pbc.fetch(), interface=InterfaceSocket(address=self.address.fetch(), port=self.port.fetch(), slots=self.slots.fetch(), mode=self.mode.fetch(), timeout=self.timeout.fetch() ) )
def __init__(self, pars=None, interface=None): """Initializes FFSocket. Args: pars: Optional dictionary, giving the parameters needed by the driver. interface: Optional Interface object, which contains the socket. """ # a socket to the communication library is created or linked super(FFSocket,self).__init__() if interface is None: self.socket = InterfaceSocket() else: self.socket = interface if pars is None: self.pars = {} else: self.pars = pars self.request = None
def test_interface(): """InterfaceSocket: startup.""" InterfaceSocket()