Skip to content

Commit

Permalink
Merge pull request #10 from xmgao/fix-documentation-errors
Browse files Browse the repository at this point in the history
Fix documentation errors
  • Loading branch information
ertuil committed Aug 5, 2024
2 parents 5dadf68 + 68578c6 commit b56a63b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Here is an example of using SimQN.
from qns.network.route.dijkstra import DijkstraRouteAlgorithm
from qns.network.topology.topo import ClassicTopology
import qns.utils.log as log
import logging

init_fidelity = 0.99 # the initial entanglement's fidelity
nodes_number = 150 # the number of nodes
Expand Down Expand Up @@ -102,3 +103,4 @@ Other contributors includes:
* Zirui Xiao, School of Cyber Science and Technology, University of Science and Technology of China, China.
* Yuqi Yang, School of Cyber Science and Technology, University of Science and Technology of China, China.
* Bing Yang, School of Cyber Science and Technology, University of Science and Technology of China, China.
* Xumin Gao, School of Cyber Science and Technology, University of Science and Technology of China, China.
2 changes: 1 addition & 1 deletion docs/source/tutorials.entity.memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Quantum memory is an entity that can store qubits. It can be equipped to a quant
q1 = Qubit()
m.write(q1)
q2 = m.read()
q2 = m.read(q1)
The memory can have a limited size. ``is_full`` function returns whether the memory is full:

Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorials.models.qubit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,18 @@ SimQN also provides some commonly used decoherence models, including dephase mod

.. code-block:: python
from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransmitErrorModel
from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransferErrorModel
from qns.models.qubit.factory import QubitFactory
Qubit = QubitFactory(store_error_model=DepolarStorageErrorModel, transfer_error_model=DephaseTransmitErrorModel)
Qubit = QubitFactory(store_error_model=DepolarStorageErrorModel, transfer_error_model=DephaseTransferErrorModel)
q1 = Qubit(name="q1")
q2 = Qubit(name="q2")
SimQN also have error models for operating or measuring on qubits, by implementing the ``operate_error_model`` and ``measure_error_model``:

.. code-block:: python
from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransmitErrorModel
from qns.models.qubit.decoherence import DepolarStorageErrorModel, DephaseTransferErrorModel
from qns.models.qubit.factory import QubitFactory
Qubit = QubitFactory(operate_decoherence_rate=0.2,
Expand Down
6 changes: 3 additions & 3 deletions docs/source/tutorials.network.route.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ An example of using this algorithm is:

.. code-block:: python
from qns.network.topology import RandomTopology, ClassicTopology
from qns.network.topology import RandomTopology
from qns.network.network import QuantumNetwork
from qns.network.route import DijkstraRouteAlgorithm
Expand All @@ -39,8 +39,8 @@ An example of using this algorithm is:
lines_number=10,
qchannel_args={"delay": 0.05, "bandwidth": 10},
cchannel_args={"delay": 0.05},
memory_args=[{"capacity": memory_capacity}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=init_fidelity)])
memory_args=[{"capacity": 50}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# use the ``DijkstraRouteAlgorithm``, using the bandwidth as the ``metric_func``
route = DijkstraRouteAlgorithm(metric_func=lambda qchannel: qchannel.bandwidth)
Expand Down
11 changes: 6 additions & 5 deletions docs/source/tutorials.network.topology.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Topology generators may have more parameters. The following example shows how to
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)])
memory_args=[{"capacity": 50}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# build the network
net = QuantumNetwork(topo=topo)
Expand Down Expand Up @@ -54,16 +54,17 @@ SimQN is able to generate classic topologies as well. The classic topology is in

.. code-block:: python
from qns.network.topology import RandomTopology, ClassicTopology
from qns.network.topology import RandomTopology
from qns.network.network import QuantumNetwork
from qns.network.topology.topo import ClassicTopology
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)])
memory_args=[{"capacity": 50}],
nodes_apps=[EntanglementDistributionApp(init_fidelity=0.99)])
# build the network, classic topology follows the quantum topology
net = QuantumNetwork(topo=topo, classic_topo=ClassicTopology.Follow)
Expand Down
7 changes: 4 additions & 3 deletions docs/source/tutorials.quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ The simulation is last for 10 seconds and the ``accuracy`` is 10,000,000,000 slo
import numpy as np
light_speed = 299791458
length = 100000 # 100,000 km
length = 100000 # 100,000 m
def drop_rate(length):
# drop 0.2 db/KM
return 1 - np.exp(- length / 50000)
return 1 - np.exp(- length / 50000) #or 1 - np.power(10, - length / 50000)
# generate quantum nodes
n1 = QNode(name="n1")
Expand Down Expand Up @@ -88,6 +88,7 @@ First, we generate the simulator and produce the network produce:
from qns.network.route.dijkstra import DijkstraRouteAlgorithm
from qns.network.topology.topo import ClassicTopology
import qns.utils.log as log
import logging
init_fidelity = 0.99 # the initial entanglement's fidelity
nodes_number = 150 # the number of nodes
Expand Down Expand Up @@ -134,7 +135,7 @@ Now, it is possible to run the simulation and get the results:
s.run()
# count the number of successful entanglement distribution for each session
results = [src.apps[0].success_count for req in net.requests]
results = [req.src.apps[0].success_count for req in net.requests]
# log the results
log.monitor(requests_number, nodes_number, results, s.time_spend, sep=" ")
6 changes: 4 additions & 2 deletions docs/source/tutorials.util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ Users can set the logging level and record logs:

.. code-block:: Python
import logging
log.logger.setLevel(logging.INFO)
a = 1
log.debug("debug message")
log.info("info message", a)
log.warn("warn message", a+1)
log.info("info message %d", a)
log.warn("warn message %d", a + 1)
log.error("error message")
log.critical("critical message")
Expand Down

0 comments on commit b56a63b

Please sign in to comment.