From e08aaf2bf9f3afd44183c2dc13d5afa3f558e3d3 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 13:52:14 -0500 Subject: [PATCH 01/19] Update the example path: use @__DIR__ --- src/mps_runner.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mps_runner.jl b/src/mps_runner.jl index b27c4b2..628950c 100644 --- a/src/mps_runner.jl +++ b/src/mps_runner.jl @@ -13,13 +13,14 @@ using JSON include("mps_utils.jl") include("plotter.jl") + function parse_commandline() s = ArgParseSettings() @add_arg_table! s begin "--program-path" help = "the path to the AHS program JSON file" arg_type = String - default = joinpath("examples", "ahs_program.json") + default = joinpath(@__DIR__, "../examples", "ahs_program.json") "--interaction-radius" help = "the interaction radius in meters" arg_type = Float64 From a80e9e31f4472be3d4715d43bfdc7df4ea0628d9 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:00:50 -0500 Subject: [PATCH 02/19] Add [compat] section to Project.toml --- Project.toml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9af8192..b093bbf 100644 --- a/Project.toml +++ b/Project.toml @@ -22,4 +22,32 @@ Braket = "19504a0f-b47d-4348-9127-acc6cc69ef67" CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" \ No newline at end of file +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +Base64 = "1.6" +AxisArrays = "=0.4.7" +CSV = "=0.10.12" +CodeTracking = "=1.3.5" +Compat = "=4.10.1" +DataStructures = "=0.18.15" +Dates = "1.6" +Downloads = "1" +Graphs = "=1.9.0" +InteractiveUtils = "1.6" +JSON3 = "=1.14.0" +LinearAlgebra = "1.6" +Logging = "1.6" +Markdown = "=0.7.5" +NamedTupleTools = "=0.14.3" +OrderedCollections = "=1.6.3" +Pkg = "1.6" +Random = "1.6" +Statistics = "1.6" +SparseArrays = "1.6" +StructTypes = "=1.10.0" +Tar = "1.9.3" +Test = "1.6" +UUIDs = "1.6" +julia = "1.6" +CairoMakie = "0.12.0" \ No newline at end of file From 95242775faa05184a51beea648960270bdd31806 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:17:21 -0500 Subject: [PATCH 03/19] Update [compat] section --- Project.toml | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Project.toml b/Project.toml index b093bbf..e48c24b 100644 --- a/Project.toml +++ b/Project.toml @@ -23,31 +23,27 @@ CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -Base64 = "1.6" -AxisArrays = "=0.4.7" +ArgParse = "1.0" CSV = "=0.10.12" -CodeTracking = "=1.3.5" +DataFrames = "1.6" +Plots = "1.30" +CairoMakie = "0.12.0" Compat = "=4.10.1" +Braket = "0.8" +ITensors = "0.3" +Missings = "1.1" DataStructures = "=0.18.15" Dates = "1.6" -Downloads = "1" -Graphs = "=1.9.0" InteractiveUtils = "1.6" -JSON3 = "=1.14.0" -LinearAlgebra = "1.6" +JSON = "0.20" +JSON3 = "1.14" Logging = "1.6" Markdown = "=0.7.5" -NamedTupleTools = "=0.14.3" -OrderedCollections = "=1.6.3" -Pkg = "1.6" Random = "1.6" Statistics = "1.6" -SparseArrays = "1.6" -StructTypes = "=1.10.0" -Tar = "1.9.3" Test = "1.6" UUIDs = "1.6" julia = "1.6" -CairoMakie = "0.12.0" \ No newline at end of file From 60ee5a437742b26d81e0374b7f6e54711ec31cd0 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:20:22 -0500 Subject: [PATCH 04/19] Update [compat] section, remove Compat pkg --- Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Project.toml b/Project.toml index e48c24b..70f3fc3 100644 --- a/Project.toml +++ b/Project.toml @@ -31,7 +31,6 @@ CSV = "=0.10.12" DataFrames = "1.6" Plots = "1.30" CairoMakie = "0.12.0" -Compat = "=4.10.1" Braket = "0.8" ITensors = "0.3" Missings = "1.1" From 0d1232a3755c678da04e25a0e217dfdfa9f6c658 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:22:50 -0500 Subject: [PATCH 05/19] Update [compat] section --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 70f3fc3..047bada 100644 --- a/Project.toml +++ b/Project.toml @@ -30,7 +30,7 @@ ArgParse = "1.0" CSV = "=0.10.12" DataFrames = "1.6" Plots = "1.30" -CairoMakie = "0.12.0" +CairoMakie = "0.5" Braket = "0.8" ITensors = "0.3" Missings = "1.1" From 10071d45c0bf8a1a2f5f98f16d882826dcf06285 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:26:01 -0500 Subject: [PATCH 06/19] Update [compat] section --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 047bada..fe2883a 100644 --- a/Project.toml +++ b/Project.toml @@ -40,7 +40,7 @@ InteractiveUtils = "1.6" JSON = "0.20" JSON3 = "1.14" Logging = "1.6" -Markdown = "=0.7.5" +Markdown = "1.10" Random = "1.6" Statistics = "1.6" Test = "1.6" From 04af3e5f43e77e0e82f0f7ca11c011e6008b564a Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:30:08 -0500 Subject: [PATCH 07/19] Update [compat] section --- Project.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index fe2883a..ebfe38d 100644 --- a/Project.toml +++ b/Project.toml @@ -37,8 +37,8 @@ Missings = "1.1" DataStructures = "=0.18.15" Dates = "1.6" InteractiveUtils = "1.6" -JSON = "0.20" -JSON3 = "1.14" +JSON = "=0.21.0" +JSON3 = "=1.14.0" Logging = "1.6" Markdown = "1.10" Random = "1.6" From 7e25a9bb4959f38eb699d5689380e46df873ab94 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 14:33:49 -0500 Subject: [PATCH 08/19] Update [compat], ArgParse --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ebfe38d..8a292bd 100644 --- a/Project.toml +++ b/Project.toml @@ -26,7 +26,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" [compat] -ArgParse = "1.0" +ArgParse = "=1.1.5" CSV = "=0.10.12" DataFrames = "1.6" Plots = "1.30" From b0898846edd161d059d0a8786e34891f50975a7c Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 15:42:44 -0500 Subject: [PATCH 09/19] Remove JSON from deps, relpace by JSON3 --- Project.toml | 6 +++--- src/ahs_program.jl | 4 ++-- src/mps_runner.jl | 4 ++-- src/mps_utils.jl | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Project.toml b/Project.toml index 8a292bd..217a158 100644 --- a/Project.toml +++ b/Project.toml @@ -11,7 +11,6 @@ DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" ITensors = "9136182c-28ba-11e9-034c-db9fb085ebd5" -JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28" @@ -24,10 +23,11 @@ Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" +Parsers = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0" [compat] ArgParse = "=1.1.5" -CSV = "=0.10.12" +CSV = "0.10" DataFrames = "1.6" Plots = "1.30" CairoMakie = "0.5" @@ -37,7 +37,6 @@ Missings = "1.1" DataStructures = "=0.18.15" Dates = "1.6" InteractiveUtils = "1.6" -JSON = "=0.21.0" JSON3 = "=1.14.0" Logging = "1.6" Markdown = "1.10" @@ -46,3 +45,4 @@ Statistics = "1.6" Test = "1.6" UUIDs = "1.6" julia = "1.6" +Parsers = "1, 2" \ No newline at end of file diff --git a/src/ahs_program.jl b/src/ahs_program.jl index 6ddf268..916bf60 100644 --- a/src/ahs_program.jl +++ b/src/ahs_program.jl @@ -66,13 +66,13 @@ end json_str = JSON3.write(ir(ahs_program)) -json_obj = JSON.parse(json_str) +json_obj = JSON3.read(json_str) # Define the file path file_path = "examples/ahs_program.json" # Write the JSON object to a file open(file_path, "w") do file - JSON.print(file, json_obj, 4) # The '4' here is for pretty printing with an indent of 4 spaces + JSON3.write(file, json_obj) # The '4' here is for pretty printing with an indent of 4 spaces end diff --git a/src/mps_runner.jl b/src/mps_runner.jl index 628950c..00c687a 100644 --- a/src/mps_runner.jl +++ b/src/mps_runner.jl @@ -8,7 +8,7 @@ using Dates using Missings using Random using Logging -using JSON +using JSON3 include("mps_utils.jl") include("plotter.jl") @@ -81,7 +81,7 @@ experiment_path = args["experiment-path"] program_path = args["program-path"] @info "JSON file to read: $program_path" -ahs_json = JSON.parsefile(program_path) +ahs_json = JSON3.read(read(program_path, String), Dict{String, Any}) results = run(ahs_json, args) diff --git a/src/mps_utils.jl b/src/mps_utils.jl index f7f288b..dec588c 100644 --- a/src/mps_utils.jl +++ b/src/mps_utils.jl @@ -7,7 +7,7 @@ using Dates using Base.Filesystem using Missings using Random -using JSON +using JSON3 """ @@ -189,7 +189,7 @@ function parse_ahs_program(ahs_json, args::Dict{String, Any}) end # Serialize the data to a JSON-formatted string, write the JSON string to the file - write(joinpath(experiment_path, "ahs_program.json"), JSON.json(ahs_json)) + write(joinpath(experiment_path, "ahs_program.json"), JSON3.read(ahs_json)) # Write filling data to CSV file CSV.write(joinpath(experiment_path, "filling.csv"), DataFrame(filling', :auto)) From e22b4d08920c07fd8ff18305c4831e7ffe5c5c4b Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 15:46:17 -0500 Subject: [PATCH 10/19] Update Markdown version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 217a158..9a72c70 100644 --- a/Project.toml +++ b/Project.toml @@ -39,7 +39,7 @@ Dates = "1.6" InteractiveUtils = "1.6" JSON3 = "=1.14.0" Logging = "1.6" -Markdown = "1.10" +Markdown = "1.9" Random = "1.6" Statistics = "1.6" Test = "1.6" From 2bc0da72a6ff8cf109499a4e7db4580c3b3b582e Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 15:58:51 -0500 Subject: [PATCH 11/19] Remove using JSON --- src/ahs_program.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ahs_program.jl b/src/ahs_program.jl index 916bf60..d73fb1e 100644 --- a/src/ahs_program.jl +++ b/src/ahs_program.jl @@ -7,7 +7,7 @@ using Dates using Base.Filesystem using Missings using Random -using JSON, JSON3 +using JSON3 using Markdown using InteractiveUtils From 71fb78c1522c16669d8dcdfbef5e7360b37369db Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 16:07:27 -0500 Subject: [PATCH 12/19] Update path in ahs_program.jl --- src/ahs_program.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ahs_program.jl b/src/ahs_program.jl index d73fb1e..8da449f 100644 --- a/src/ahs_program.jl +++ b/src/ahs_program.jl @@ -69,7 +69,7 @@ json_str = JSON3.write(ir(ahs_program)) json_obj = JSON3.read(json_str) # Define the file path -file_path = "examples/ahs_program.json" +file_path = joinpath(@__DIR__, "../examples", "ahs_program.json") # Write the JSON object to a file open(file_path, "w") do file From c4bb130c1ad5936d9159616dae0e6517d5db8aec Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 16:16:31 -0500 Subject: [PATCH 13/19] Remove JSON from runtests.jl --- test/runtests.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/runtests.jl b/test/runtests.jl index 28feb69..4363761 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,13 +1,13 @@ using BraketAHS: run, save_results using Test -using JSON, JSON3 +using JSON3 @testset "BraketAHS.jl" begin # Write your tests here. json_str = """{"setup":{"ahs_register":{"sites":[["0.0","0.0"],["5.499999999999999856993733449161965e-6","0.0"],["0.0","5.499999999999999856993733449161965e-6"],["5.499999999999999856993733449161965e-6","5.499999999999999856993733449161965e-6"]],"filling":[1,1,1,1]}},"braketSchemaHeader":{"name":"braket.ir.ahs.program","version":"1"},"hamiltonian":{"shiftingFields":[{"magnitude":{"pattern":["0.0","0.0","0.0","0.0"],"time_series":{"values":["0.0","0.0"],"times":["0.0","3.999999999999999818992447303545035e-6"]}}}],"drivingFields":[{"phase":{"pattern":"uniform","time_series":{"values":["0.0","0.0"],"times":["0.0","3.999999999999999818992447303545035e-6"]}},"detuning":{"pattern":"uniform","time_series":{"values":["-3.15e7","-3.15e7","3.15e7","3.15e7"],"times":["0.0","9.999999999999999547481118258862587e-8","3.899999999999999929396754527743951e-6","3.999999999999999818992447303545035e-6"]}},"amplitude":{"pattern":"uniform","time_series":{"values":["0.0","6.3e6","6.3e6","0.0"],"times":["0.0","9.999999999999999547481118258862587e-8","3.899999999999999929396754527743951e-6","3.999999999999999818992447303545035e-6"]}}}]}} """ - ahs_json = JSON.parse(json_str) + ahs_json = JSON3.read(json_str) args = Dict( "experiment-path" => "test/", From edf3822590c7b82aebb72ca2e356c6990c024f94 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 16:41:15 -0500 Subject: [PATCH 14/19] Fix JSON3 saving --- src/mps_utils.jl | 12 ++++++++---- test/runtests.jl | 2 -- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/mps_utils.jl b/src/mps_utils.jl index dec588c..8828a56 100644 --- a/src/mps_utils.jl +++ b/src/mps_utils.jl @@ -13,9 +13,9 @@ using JSON3 """ Generate atom positions from the ahs program. """ -function get_atom_coordinates(ahs_program::Dict{String, Any}) - atom_coords = ahs_program["setup"]["ahs_register"]["sites"] - filling = ahs_program["setup"]["ahs_register"]["filling"] +function get_atom_coordinates(ahs_json) + atom_coords = ahs_json["setup"]["ahs_register"]["sites"] + filling = ahs_json["setup"]["ahs_register"]["filling"] atom_coords = [parse.(Float64, c) for c in atom_coords] return atom_coords, filling end @@ -189,7 +189,11 @@ function parse_ahs_program(ahs_json, args::Dict{String, Any}) end # Serialize the data to a JSON-formatted string, write the JSON string to the file - write(joinpath(experiment_path, "ahs_program.json"), JSON3.read(ahs_json)) + json_str = JSON3.write(ahs_json) + open(joinpath(experiment_path, "ahs_program.json"), "w") do file + write(file, json_str) + end + # Write filling data to CSV file CSV.write(joinpath(experiment_path, "filling.csv"), DataFrame(filling', :auto)) diff --git a/test/runtests.jl b/test/runtests.jl index 4363761..6988ac3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -25,8 +25,6 @@ using JSON3 "generate-plots" => false ) - @show ahs_json - result = run(ahs_json, args) mps_density = result["density"][:, end] From 8413c359e0e670da16ee63d8f84aeb0f896f1f67 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 16:50:50 -0500 Subject: [PATCH 15/19] Update ITensors version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 9a72c70..75c5e45 100644 --- a/Project.toml +++ b/Project.toml @@ -32,7 +32,7 @@ DataFrames = "1.6" Plots = "1.30" CairoMakie = "0.5" Braket = "0.8" -ITensors = "0.3" +ITensors = "=0.3.57" Missings = "1.1" DataStructures = "=0.18.15" Dates = "1.6" From 5874de971bdad0207643204f413912beeba7eb5d Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Mon, 4 Mar 2024 17:39:43 -0500 Subject: [PATCH 16/19] Update dependencies --- Project.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index 75c5e45..ac082c9 100644 --- a/Project.toml +++ b/Project.toml @@ -30,9 +30,9 @@ ArgParse = "=1.1.5" CSV = "0.10" DataFrames = "1.6" Plots = "1.30" -CairoMakie = "0.5" -Braket = "0.8" -ITensors = "=0.3.57" +CairoMakie = "=0.11.8" +Braket = "0.8.0" +ITensors = "0.3.57" Missings = "1.1" DataStructures = "=0.18.15" Dates = "1.6" From 520c85e663fc21d452b89b056d2f9bf7f93b6ae5 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Tue, 5 Mar 2024 11:27:15 -0500 Subject: [PATCH 17/19] Update the example path --- src/mps_runner.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mps_runner.jl b/src/mps_runner.jl index 00c687a..dcc8c96 100644 --- a/src/mps_runner.jl +++ b/src/mps_runner.jl @@ -20,7 +20,7 @@ function parse_commandline() "--program-path" help = "the path to the AHS program JSON file" arg_type = String - default = joinpath(@__DIR__, "../examples", "ahs_program.json") + default = joinpath(dirname(@__DIR__), "examples", "ahs_program.json") "--interaction-radius" help = "the interaction radius in meters" arg_type = Float64 @@ -28,7 +28,7 @@ function parse_commandline() "--experiment-path" help = "the directory in which to store all experiment data" arg_type = String - default = joinpath("examples", "experiment_braket") + default = joinpath(dirname(@__DIR__), "examples", "experiment_braket") "--cutoff" help = "cutoff for SVD values in MPS evolution" arg_type = Float64 From 444d2d4f5a18b2b8a8ba6f25632f9378573eccca Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Tue, 5 Mar 2024 13:12:40 -0500 Subject: [PATCH 18/19] Fix example path in ahs_program.jl --- src/ahs_program.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ahs_program.jl b/src/ahs_program.jl index 8da449f..0fe6dd2 100644 --- a/src/ahs_program.jl +++ b/src/ahs_program.jl @@ -69,7 +69,7 @@ json_str = JSON3.write(ir(ahs_program)) json_obj = JSON3.read(json_str) # Define the file path -file_path = joinpath(@__DIR__, "../examples", "ahs_program.json") +file_path = joinpath(dirname(@__DIR__), "examples", "ahs_program.json") # Write the JSON object to a file open(file_path, "w") do file From fc2429f79ce8fc64eb79bfe63e505520dc3672a2 Mon Sep 17 00:00:00 2001 From: Yaroslav Kharkov Date: Tue, 5 Mar 2024 14:23:36 -0500 Subject: [PATCH 19/19] Update default ahs_program.json path --- src/ahs_program.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ahs_program.jl b/src/ahs_program.jl index 0fe6dd2..ad7c3bb 100644 --- a/src/ahs_program.jl +++ b/src/ahs_program.jl @@ -69,7 +69,7 @@ json_str = JSON3.write(ir(ahs_program)) json_obj = JSON3.read(json_str) # Define the file path -file_path = joinpath(dirname(@__DIR__), "examples", "ahs_program.json") +file_path = joinpath(dirname(@__DIR__), "examples", "ahs_program_default.json") # Write the JSON object to a file open(file_path, "w") do file