From ff3ccf172130bb775b5d2b2129f84cfb07774fbc Mon Sep 17 00:00:00 2001 From: Stefan Krastanov Date: Sun, 11 Jun 2023 02:18:21 -0400 Subject: [PATCH] switch to ConcurrentSim --- docs/Project.toml | 2 +- .../colorcentermodularcluster.md | 2 +- docs/src/howto/firstgenrepeater/firstgenrepeater.md | 10 +++++----- docs/src/tutorial/message_queues.md | 10 +++++----- docs/src/visualizations.md | 2 +- .../colorcentermodularcluster/1_time_to_connected.jl | 2 +- .../colorcentermodularcluster/3_makie_interactive.jl | 2 +- examples/colorcentermodularcluster/Project.toml | 4 ++-- examples/colorcentermodularcluster/setup.jl | 4 ++-- examples/firstgenrepeater/setup.jl | 2 +- ext/QuantumSavoryMakie/QuantumSavoryMakie.jl | 4 ++-- src/QuantumSavory.jl | 2 +- src/{simjulia.jl => concurrentsim.jl} | 8 ++++---- test/Project.toml | 2 +- test/test_jet.jl | 4 ++-- test/test_plotting.jl | 2 +- 16 files changed, 31 insertions(+), 31 deletions(-) rename src/{simjulia.jl => concurrentsim.jl} (85%) diff --git a/docs/Project.toml b/docs/Project.toml index 76d50135..59ea0d15 100644 --- a/docs/Project.toml +++ b/docs/Project.toml @@ -1,5 +1,6 @@ [deps] CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" DocumenterCitations = "daee34ce-89f3-4625-b898-19384cb65244" @@ -15,7 +16,6 @@ QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c" QuantumSavory = "2de2e421-972c-4cb5-a0c3-999c85908079" ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" -SimJulia = "428bdadb-6287-5aa5-874b-9969638295fd" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" ThreadTools = "dbf13d8f-d36e-4350-8970-f3a99faba1a8" diff --git a/docs/src/howto/colorcentermodularcluster/colorcentermodularcluster.md b/docs/src/howto/colorcentermodularcluster/colorcentermodularcluster.md index 798ff0ab..5803af35 100644 --- a/docs/src/howto/colorcentermodularcluster/colorcentermodularcluster.md +++ b/docs/src/howto/colorcentermodularcluster/colorcentermodularcluster.md @@ -34,7 +34,7 @@ For a convenient data structure to track per-node metadata in a graph (network) Moreover, behind the scenes `QuantumSavory.jl` will use: -- `SimJulia.jl` for discrete event scheduling and simulation; +- `ConcurrentSim.jl` for discrete event scheduling and simulation; - `Makie.jl` together with our custom plotting recipes for visualizations; - `QuantumOptics.jl` for low-level quantum states. diff --git a/docs/src/howto/firstgenrepeater/firstgenrepeater.md b/docs/src/howto/firstgenrepeater/firstgenrepeater.md index 5ec814e3..8cdf5831 100644 --- a/docs/src/howto/firstgenrepeater/firstgenrepeater.md +++ b/docs/src/howto/firstgenrepeater/firstgenrepeater.md @@ -28,7 +28,7 @@ For a convenient data structure to track per-node metadata in a graph (network) Moreover, behind the scenes `QuantumSavory.jl` will use: -- `SimJulia.jl` for discrete event scheduling and simulation; +- `ConcurrentSim.jl` for discrete event scheduling and simulation; - `Makie.jl` together with our custom plotting recipes for visualizations; - `QuantumOptics.jl` for low-level quantum states. @@ -54,7 +54,7 @@ The `RegisterNet` would contain, on each node: - a [`Register`](@ref) of the appropriate size; - an array of tuples keeping track of whom each qubit in the register is entangled to (as the `:enttracker` property); -- an array of locks (from `SimJulia.jl`) keeping track of whether a process is happening on the given qubit (as the `:locks` property). +- an array of locks (from `ConcurrentSim.jl`) keeping track of whether a process is happening on the given qubit (as the `:locks` property). !!! note To see how to visualize these data structures as the simulation is proceeding, consult the [Visualizations](@ref Visualizations) page. @@ -481,7 +481,7 @@ end ## Running the simulations Now that we have defined the Entangler, Swapper, and Purifier processes, we just need to run the simulation. -That is no different from running any other `SimJulia.jl` simulation, after our custom setup: +That is no different from running any other `ConcurrentSim.jl` simulation, after our custom setup: ```julia sizes = [2,3,4,3,2] # Number of qubits in each register @@ -513,7 +513,7 @@ end ``` Then to run the simulation up to time `t` we just write `run(sim, t)`. -If we want to run until the next event, whenever that is, we can do `SimJulia.step(sim)` +If we want to run until the next event, whenever that is, we can do `ConcurrentSim.step(sim)` ## Figures of Merit and Visualizations @@ -558,7 +558,7 @@ Many of the above functions take the `time` keyword argument, which ensures that Of note is that we also used `Makie.jl` for plotting, -`SimJulia.jl` for discrete event scheduling, +`ConcurrentSim.jl` for discrete event scheduling, `QuantumClifford.jl` for efficient simulation of Clifford circuits, and `QuantumOptics.jl` for convenient master equation integration. Many of these tools were used under the hood without being invoked directly. diff --git a/docs/src/tutorial/message_queues.md b/docs/src/tutorial/message_queues.md index 19c68e84..0ac3ef37 100644 --- a/docs/src/tutorial/message_queues.md +++ b/docs/src/tutorial/message_queues.md @@ -8,20 +8,20 @@ end ``` In network simulations, a convenient synchronization primitive is the passing of messages between nodes. -The `ResumableFunctions` and `SimJulia` libraries provide such primitives, convenient to use with `QuatumSavory`. +The `ResumableFunctions` and `ConcurrentSim` libraries provide such primitives, convenient to use with `QuatumSavory`. Here we run through a simple example: there are two nodes that perform certain measurements. If the measurement result is the same, then the simulation ends. If the results differ, then we reset both nodes and try again. No actual physics will be simulated here (we will just generate some random numbers). There are a number of convenient queue structures provided by these libraries. We will focus on `Store` and `DelayChannel` both of which are FILO stacks on which you can `put` messages or `get` messages. -We use `SimJulia`'s `@yield` and `@process` constructs to provide concurrency in our simulation. +We use `ConcurrentSim`'s `@yield` and `@process` constructs to provide concurrency in our simulation. First we create a `Simulation` object (to track the fictitious simulation time and currently active simulated process) and create a few FILO stacks for `put`ting and `get`ting messages. ```@example messagechannel using QuantumSavory using ResumableFunctions -using SimJulia +using ConcurrentSim using CairoMakie sim = Simulation() @@ -118,7 +118,7 @@ Finally, we schedule the two concurrent processes and run the simulation until s @process process_node1(sim) @process process_node2(sim) -SimJulia.run(sim) +ConcurrentSim.run(sim) time_before_success = now(sim) ``` @@ -183,7 +183,7 @@ end @process process_node1(sim) @process process_node2(sim) -SimJulia.run(sim) +ConcurrentSim.run(sim) fig = Figure() ax = Axis(fig[1,1],xlabel="time") diff --git a/docs/src/visualizations.md b/docs/src/visualizations.md index 0c365aec..72c56c3d 100644 --- a/docs/src/visualizations.md +++ b/docs/src/visualizations.md @@ -47,7 +47,7 @@ The [`resourceplot_axis`](@ref) function can be used to draw all locks and resou ```@example vis using Graphs -using SimJulia +using ConcurrentSim sim = Simulation() diff --git a/examples/colorcentermodularcluster/1_time_to_connected.jl b/examples/colorcentermodularcluster/1_time_to_connected.jl index 23e21196..b7550a09 100644 --- a/examples/colorcentermodularcluster/1_time_to_connected.jl +++ b/examples/colorcentermodularcluster/1_time_to_connected.jl @@ -12,7 +12,7 @@ function run_until_connected(root_conf) net, sim, observables, conf = prep_sim(root_conf) # Run until all connections succeed while !all([net[v,:link_register] for v in edges(net)]) - SimJulia.step(sim) + ConcurrentSim.step(sim) end # Calculate fidelity of each cluster vertex fid = map(vertices(net)) do v diff --git a/examples/colorcentermodularcluster/3_makie_interactive.jl b/examples/colorcentermodularcluster/3_makie_interactive.jl index ba7f1a12..79ef41b6 100644 --- a/examples/colorcentermodularcluster/3_makie_interactive.jl +++ b/examples/colorcentermodularcluster/3_makie_interactive.jl @@ -12,7 +12,7 @@ function run_until_connected(root_conf) net, sim, observables, conf = prep_sim(root_conf) # Run until all connections succeed while !all([net[v,:link_register] for v in edges(net)]) - SimJulia.step(sim) + ConcurrentSim.step(sim) end # Calculate fidelity of each cluster vertex fid = map(vertices(net)) do v diff --git a/examples/colorcentermodularcluster/Project.toml b/examples/colorcentermodularcluster/Project.toml index a8b39dd6..4c11da2c 100644 --- a/examples/colorcentermodularcluster/Project.toml +++ b/examples/colorcentermodularcluster/Project.toml @@ -1,4 +1,5 @@ [deps] +ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9" @@ -7,8 +8,7 @@ QuantumOptics = "6e0679c1-51ea-5a7c-ac74-d61b76210b0c" QuantumSavory = "2de2e421-972c-4cb5-a0c3-999c85908079" ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" -SimJulia = "428bdadb-6287-5aa5-874b-9969638295fd" WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008" [compat] -JSServe = "2.2.3" \ No newline at end of file +JSServe = "2.2.7" \ No newline at end of file diff --git a/examples/colorcentermodularcluster/setup.jl b/examples/colorcentermodularcluster/setup.jl index 8347a5b3..34db25f3 100644 --- a/examples/colorcentermodularcluster/setup.jl +++ b/examples/colorcentermodularcluster/setup.jl @@ -3,7 +3,7 @@ using Graphs # For discrete event simulation using ResumableFunctions -using SimJulia +using ConcurrentSim # For sampling from probability distributions using Distributions @@ -87,7 +87,7 @@ function prep_sim(root_conf) # compute various derived constants for the simulation conf = derive_conf(root_conf) - # set up SimJulia discrete events simulation + # set up ConcurrentSim discrete events simulation sim = Simulation() net[:, :espin_queue] = () -> Resource(sim,1) diff --git a/examples/firstgenrepeater/setup.jl b/examples/firstgenrepeater/setup.jl index b6e87c11..d35ea2e2 100644 --- a/examples/firstgenrepeater/setup.jl +++ b/examples/firstgenrepeater/setup.jl @@ -3,7 +3,7 @@ using Graphs # For discrete event simulation using ResumableFunctions -using SimJulia +using ConcurrentSim # Useful for interactive work # Enables automatic re-compilation of modified codes diff --git a/ext/QuantumSavoryMakie/QuantumSavoryMakie.jl b/ext/QuantumSavoryMakie/QuantumSavoryMakie.jl index 2c365cc7..97d6da7a 100644 --- a/ext/QuantumSavoryMakie/QuantumSavoryMakie.jl +++ b/ext/QuantumSavoryMakie/QuantumSavoryMakie.jl @@ -3,7 +3,7 @@ module QuantumSavoryMakie using QuantumSavory using Graphs using NetworkLayout -import SimJulia +import ConcurrentSim import Makie import Makie: Theme, Figure, Axis, @recipe import QuantumSavory: registernetplot, registernetplot_axis, resourceplot_axis, showonplot @@ -129,7 +129,7 @@ end ## -showonplot(r::SimJulia.Resource) = !isfree(r) +showonplot(r::ConcurrentSim.Resource) = !isfree(r) showonplot(b::Bool) = b """Draw the various resources and locks stored in the given meta-graph on a given Makie axis. diff --git a/src/QuantumSavory.jl b/src/QuantumSavory.jl index 61df79f7..831b0bc6 100644 --- a/src/QuantumSavory.jl +++ b/src/QuantumSavory.jl @@ -214,7 +214,7 @@ include("noninstant.jl") include("backends/quantumoptics/quantumoptics.jl") include("backends/clifford/clifford.jl") -include("simjulia.jl") +include("concurrentsim.jl") include("plots.jl") diff --git a/src/simjulia.jl b/src/concurrentsim.jl similarity index 85% rename from src/simjulia.jl rename to src/concurrentsim.jl index c0224c8b..2eeca34c 100644 --- a/src/simjulia.jl +++ b/src/concurrentsim.jl @@ -1,6 +1,6 @@ using ResumableFunctions -import SimJulia # Should be using -using SimJulia: Environment, request, release, now, active_process, timeout, Store, @process, Process, put, get +import ConcurrentSim # Should be using +using ConcurrentSim: Environment, request, release, now, active_process, timeout, Store, @process, Process, put, get using Printf export @simlog, isfree, nongreedymultilock, spinlock, DelayChannel @@ -59,10 +59,10 @@ end put(channel.store, value) end -function SimJulia.put(channel::DelayChannel, value) # TODO rename to the ones from Base +function ConcurrentSim.put(channel::DelayChannel, value) # TODO rename to the ones from Base @process latency(channel.store.env, channel, value) # results in the scheduling of all events generated by latency end -function SimJulia.get(channel::DelayChannel) # TODO rename to the ones from Base +function ConcurrentSim.get(channel::DelayChannel) # TODO rename to the ones from Base get(channel.store) # returns an element stored in the cable store end diff --git a/test/Project.toml b/test/Project.toml index b9f87a93..79427e19 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,6 +1,7 @@ [deps] Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" +ConcurrentSim = "6ed1e86c-fcaf-46a9-97e0-2b26a2cdb499" DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e" Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" @@ -23,7 +24,6 @@ RecursiveArrayTools = "731186ca-8d62-57ce-b412-fbd966d074cd" ResumableFunctions = "c5292f4c-5179-55e1-98c5-05642aab7184" Revise = "295af30f-e4ad-537b-8983-00126c2a3abe" SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f" -SimJulia = "428bdadb-6287-5aa5-874b-9969638295fd" StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b" diff --git a/test/test_jet.jl b/test/test_jet.jl index 761d1d7b..7a035e19 100644 --- a/test/test_jet.jl +++ b/test/test_jet.jl @@ -1,5 +1,5 @@ using QuantumSavory, JET -using DiffEqBase, Graphs, JumpProcesses, Makie, ResumableFunctions, SimJulia, QuantumOptics, QuantumOpticsBase, QuantumClifford, Symbolics, WignerSymbols +using DiffEqBase, Graphs, JumpProcesses, Makie, ResumableFunctions, ConcurrentSim, QuantumOptics, QuantumOpticsBase, QuantumClifford, Symbolics, WignerSymbols using JET: ReportPass, BasicPass, InferenceErrorReport, UncaughtExceptionReport @@ -30,7 +30,7 @@ rep = report_package("QuantumSavory"; AnyFrameModule(QuantumOpticsBase), AnyFrameModule(QuantumClifford), AnyFrameModule(ResumableFunctions), - AnyFrameModule(SimJulia), + AnyFrameModule(ConcurrentSim), AnyFrameModule(WignerSymbols), )) diff --git a/test/test_plotting.jl b/test/test_plotting.jl index e19b1972..79905d72 100644 --- a/test/test_plotting.jl +++ b/test/test_plotting.jl @@ -31,7 +31,7 @@ display(fig) ## using Graphs -using SimJulia +using ConcurrentSim sim = Simulation() for v in vertices(network) network[v,:bool] = rand(Bool)