sparc.socketio module

A i-PI compatible socket protocol implemented in SPARC

class sparc.socketio.SPARCProtocol(socket, txt=None)[source]

Bases: IPIProtocol

Extending the i-PI protocol to support extra routines

calculate_new_protocol(atoms, params)[source]
recv_object(include_header=True)[source]

Return a decoded file

include_header: should we receive the header or not

recvinit()[source]

Fallback recvinit method

send_object(obj)[source]

Send an object dumped into pickle

send_param(name, value)[source]

Send a specific param setting to SPARC This is just a test function to see how things may work

TODO: 1) test with just 2 string values to see if SPARC can receive

send_string(msg, msglen=None)[source]
sendinit()[source]

Mimick the old sendinit method but to provide atoms and params to the calculator instance. The actual behavior regarding how the calculator would be (re)-initialized, dependends on the implementation of recvinit

class sparc.socketio.SPARCSocketClient(host='localhost', port=None, unixsocket=None, timeout=None, log=None, parent_calc=None)[source]

Bases: SocketClient

calculate(atoms, use_stress)[source]

Use the calculator instance

irun(atoms, use_stress=True)[source]

Reimplement single step calculation

We’re free to implement the INIT method in socket protocol as most calculators do not involve using these. We can let the C-SPARC to spit out error about needinit error.

run(atoms=None, use_stress=False)[source]

Socket mode in SPARC should allow arbitrary start

class sparc.socketio.SPARCSocketServer(port=None, unixsocket=None, timeout=None, log=None, parent=None)[source]

Bases: SocketServer

We only implement the unix socket version due to simplicity

parent: the SPARC parent calculator

calculate_new_protocol(atoms, params={})[source]
calculate_origin_protocol(atoms)[source]

Send geometry to client and return calculated things as dict.

This will block until client has established connection, then wait for the client to finish the calculation.

property proc
send_atoms_and_params(atoms, params)[source]

Update the atoms and parameters for the SPARC calculator The params should be assignable to SPARC.set

The calc for atoms is stripped for simplicity

property socket_filename
sparc.socketio.generate_random_socket_name(prefix='sparc_', length=6)[source]

Generate a random socket name with the given prefix and a specified length of random hex characters.