Topology generator
Build quantum network topology
SimQN provides a interface (qns.network.topology.topo.Topology
) for topology generators. All topology has the following initiate variables:
nodes_number
: the number of nodes in the networknodes_apps
: a list of applications that will be added to all nodesqchannel_args
: the common attribution directory of quantum channels. Its key is the initiate variable’s name ofQuantumChannel
, for example:{"delay": 0.3, "bandwidth": 10}
.qchannel_args
: the common attribution directory of classic channels. Its key is the initiate variable’s name ofClassicChannel
, for example:{"delay": 0.3, "bandwidth": 10}
.memory_args
: a list of the common attributions directory of the quantum memories. Its key is the initiate variable’s name ofQuantumMemory
, for example:[{"capacity": 10}, {"capacity": 10, "store_error_model_args": {"t_coh": 1}}]
Topology generators may have more parameters. The following example shows how to use the random topology generator, and it has an optional parameter lines_number
:
from qns.network.topology import RandomTopology
from qns.network.network import QuantumNetwork
topo = RandomTopology(
nodes_number=5,
lines_number=10,
qchannel_args={"delay": 0.05},
cchannel_args={"delay": 0.05},
memory_args=[{"capacity": memory_capacity}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
# build the network
net = QuantumNetwork(topo=topo)
SimQn provides several topology generators:
BasicTopology
generates several quantum nodes but no quantum channels. All nodes are not connected with each other.LineTopology
connects all nodes to from a line topology.GridTopology
forms a square grid topology.nodes_number
should be a perfect square number.TreeTopology
generates a tree topology. It has an additional parameterchildren_number
. Each parent node will connect tochildren_number
child nodes.RandomTopology
generates a connected random topology based on the spanning tree. It has an additional parameterlines_number
indicating the number of quantum channels.WaxmanTopology
is another random topology generator based on the Waxman’s algorithm. It has three additional parameters,size
,alpha
, andbete
. The topology is in a \(size*size\) area. Bothalpha
andbete
are parameters of the Waxman’s algorithm.
Users can build their own topology by inheriting the Topology
class and implement the build
method.
Build classic topology
SimQN is able to generate classic topologies as well. The classic topology is indicated by the variable classic_topo
. It is an Enum
with the following options:
ClassicTopology.All
, all nodes are connected directly by a classic channelsClassicTopology.Empty
, no classic topology will be builtClassicTopology.Follow
, the classic topology will be the same to the quantum topology
from qns.network.topology import RandomTopology, ClassicTopology
from qns.network.network import QuantumNetwork
topo = RandomTopology(
nodes_number=5,
lines_number=10,
qchannel_args={"delay": 0.05},
cchannel_args={"delay": 0.05},
memory_args=[{"capacity": memory_capacity}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
# build the network, classic topology follows the quantum topology
net = QuantumNetwork(topo=topo, classic_topo=ClassicTopology.Follow)
Manage the network
The QuantumNetwork
provides the following APIs to get or add nodes, channels, memories and applications:
install
, initiate all nodes, channels, memories and applications in one stepadd_node
, add a new nodeget_node
, get a quantum nodes by its nameadd_qchannel
, add a new quantum channelget_qchannel
, get a quantum channel by its nameadd_cchannel
, add a new classic channelget_cchannel
, get a classic channel by its nameadd_memories
, add new quantum memories to all nodes
# get node by its name
n1 = net.get_node("n1")
# add a new node
n2 = QNode(name="n2")
net.add_node(n2)
# get a quantum channel by its name
l1 = net.get_qchannel("l1")
# add a quantum channel
l2 = QuantumChannel("l2")
net.add_node(l2)
node_list = net.nodes # get all nodes
qchannel_list = net.qchannels # get all quantum channels
cchannel_list = net.cchannels # get all classic channels
# produce a simulator
s = Simulator(0, 60)
# initiate the whole network
net.install(s)
s.run()