3636from twisted .internet .defer import inlineCallbacks
3737from twisted .spread import pb
3838
39+ from qutip import Qobj
40+
3941
4042#####################################################################################################
4143#
@@ -103,6 +105,18 @@ def remote_process_qubit(self, virtualNum):
103105
104106 print ("BOB: My Random Number is " , x , "\n " )
105107
108+ def assemble_qubit (self , realM , imagM ):
109+ """
110+ Reconstitute the qubit as a qutip object from its real and imaginary components given as a list.
111+ We need this since Twisted PB does not support sending complex valued object natively.
112+ """
113+ M = realM
114+ for s in range (len (M )):
115+ for t in range (len (M )):
116+ M [s ][t ] = realM [s ][t ] + 1j * imagM [s ][t ]
117+
118+ return Qobj (M )
119+
106120
107121#####################################################################################################
108122#
@@ -113,27 +127,25 @@ def main():
113127 # In this example, we are Bob.
114128 myName = "Bob"
115129
116- # This file defines the network of virtual quantum nodes
117- network_file = simulaqron_settings .network_config_file
118130
119- # This file defines the nodes acting as servers in the classical communication network
120- classicalFile = "classicalNet.cfg"
131+ logging .basicConfig (format = '%(asctime)s:%(levelname)s:%(message)s' , level = logging .DEBUG )
132+
133+ # This file defines the network of virtual quantum nodes
134+ virtualNet = SocketsConfig (str (simulaqron_settings .network_config_file ), network_name = "default" , config_type = "vnode" )
121135
122- # Read configuration files for the virtual quantum, as well as the classical network
123- virtualNet = SocketsConfig (network_file )
124- classicalNet = SocketsConfig (classicalFile )
136+ # This file defines the network used for classical communication
137+ classicalNet = SocketsConfig ("classicalNet.json" , network_name = "default" , config_type = "app" )
125138
126- # Check if we should run a local classical server. If so, initialize the code
127- # to handle remote connections on the classical communication network
139+ # Check if we should run a server (if this node is listed in classicalNet)
128140 if myName in classicalNet .hostDict :
129- lNode = localNode (classicalNet .hostDict [myName ], classicalNet )
141+ # Create the local classical server
142+ myNode = localNode (virtualNet .hostDict [myName ], classicalNet )
130143 else :
131- lNode = None
144+ myNode = None
145+
146+ # Connect and run
147+ setup_local (myName , virtualNet , classicalNet , myNode , runClientNode )
132148
133- # Set up the local classical server if applicable, and connect to the virtual
134- # node and other classical servers. Once all connections are set up, this will
135- # execute the function runClientNode
136- setup_local (myName , virtualNet , classicalNet , lNode , runClientNode )
137149
138150
139151##################################################################################################
0 commit comments