|
| 1 | +using HDF5 |
| 2 | +using CairoMakie |
| 3 | +using CairoMakie.GeometryBasics |
| 4 | +using DelaunayTriangulation |
| 5 | +using MonitoredQuantumCircuits |
| 6 | +using LinearAlgebra |
| 7 | +theme = Theme( |
| 8 | + figure_padding=7, |
| 9 | + size=(246, 3/4*246), |
| 10 | + fontsize=8, |
| 11 | + Scatter=( |
| 12 | + markersize=2.0, |
| 13 | + strokewidth=0.0, |
| 14 | + marker=:circle, |
| 15 | + strokecolor=(:black, 0.5), |
| 16 | + ), |
| 17 | + Lines=( |
| 18 | + linewidth=1.0, |
| 19 | + ), |
| 20 | + VLines=( |
| 21 | + linewidth=1.0, |
| 22 | + ), |
| 23 | + Errorbars=( |
| 24 | + linewidth=0.35, |
| 25 | + whiskerwidth=2.0, |
| 26 | + color=:black, |
| 27 | + ), |
| 28 | + Axis=( |
| 29 | + titlefont=:regular, |
| 30 | + titlesize=10, |
| 31 | + xlabelsize=10, |
| 32 | + ylabelsize=10, |
| 33 | + xgridvisible=false, |
| 34 | + ygridvisible=false, |
| 35 | + xticksize=2.5, |
| 36 | + yticksize=2.5, |
| 37 | + xminorticksize=1.5, |
| 38 | + yminorticksize=1.5, |
| 39 | + spinewidth=0.75, |
| 40 | + xtickwidth=0.75, |
| 41 | + ytickwidth=0.75, |
| 42 | + xminortickwidth=0.75, |
| 43 | + yminortickwidth=0.75, |
| 44 | + xticksmirrored = true, |
| 45 | + yticksmirrored = true, |
| 46 | + xtickalign=1, |
| 47 | + ytickalign=1, |
| 48 | + xminortickalign=1, |
| 49 | + yminortickalign=1, |
| 50 | + xminorticksvisible=true, |
| 51 | + yminorticksvisible=true, |
| 52 | + |
| 53 | + ), |
| 54 | + Legend=( |
| 55 | + labelfont=:regular, |
| 56 | + padding=(2, 2, 2, 2), # The additional space between the legend content and the border. |
| 57 | + patchlabelgap=3, # The gap between the patch and the label of each legend entry. |
| 58 | + patchsize=(4, 4), # The size of the rectangles containing the legend markers. |
| 59 | + rowgap=0, # The gap between the entry rows. |
| 60 | + colgap=0, # The gap between the entry columns. |
| 61 | + titlefont=:regular, |
| 62 | + titlegap=1, |
| 63 | + margin=(2, 2, 2, 2), |
| 64 | + framevisible=false, |
| 65 | + ), |
| 66 | +) |
| 67 | +# merge the theme with the theme_latexfonts() and update the theme |
| 68 | +theme = merge(theme, theme_latexfonts()) |
| 69 | +update_theme!(theme) |
| 70 | + |
| 71 | +function average_data(f) |
| 72 | + tmi = read(f["tmi"]) |
| 73 | + n_samples = read(f["averaging"]) |
| 74 | + |
| 75 | + averaged_tmi = sum(tmi, dims=1) ./ n_samples |
| 76 | + f["tmi_averaged"] = averaged_tmi |
| 77 | + return nothing |
| 78 | +end |
| 79 | + |
| 80 | +function projection(point; origin=[1 / 3, 1 / 3, 1 / 3], e1=normalize(cross(normalize([0.0, 0.0, 1.0] .- [1 / 3, 1 / 3, 1 / 3]), normalize([1 / 3, 1 / 3, 1 / 3]))), e2=normalize([0.0, 0.0, 1.0] .- [1 / 3, 1 / 3, 1 / 3])) |
| 81 | + |
| 82 | + return sum(e1 .* (point .- origin)), sum(e2 .* (point .- origin)) |
| 83 | +end |
| 84 | +function plot_phasediagram(file) |
| 85 | + f = file |
| 86 | + L = read(f["L"]) |
| 87 | + depth = read(f["depth"]) |
| 88 | + |
| 89 | + averaging = read(f["averaging"]) |
| 90 | + type = read(f["type"]) |
| 91 | + tmis = vec(read(f["tmi_averaged"])) |
| 92 | + points = read(f["probabilities"]) |
| 93 | + n = length(points) |
| 94 | + points2d = [projection(p) for p in eachcol(points)] |
| 95 | + |
| 96 | + fig = Figure() |
| 97 | + ax = Axis(fig[1, 1], aspect=DataAspect()) |
| 98 | + hidedecorations!(ax) |
| 99 | + hidespines!(ax) |
| 100 | + |
| 101 | + colormap = Reverse(:vik) |
| 102 | + colormap = to_colormap(cgrad([ |
| 103 | + CairoMakie.RGB(165 / 255, 0 / 255, 38 / 255), |
| 104 | + CairoMakie.RGB(249 / 255, 152 / 255, 89 / 255), |
| 105 | + CairoMakie.RGB(254 / 255, 208 / 255, 130 / 255), |
| 106 | + CairoMakie.RGB(234 / 255, 236 / 255, 204 / 255), |
| 107 | + # CairoMakie.RGB(0, 0, 0), |
| 108 | + CairoMakie.RGB(131 / 255, 184 / 255, 215 / 255), |
| 109 | + CairoMakie.RGB(83 / 255, 134 / 255, 189 / 255), |
| 110 | + CairoMakie.RGB(54 / 255, 75 / 255, 154 / 255)])) |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + # voronoiplot!(ax, [p[1] for p in points2d], [p[2] for p in points2d], averagedTmis, colormap=:vik10, markersize=5, strokewidth=0.0, show_generators=false, smooth=false, unbounded_edge_extension_factor=1.0, colorrange=(-1, 1), highclip=:white, lowclip=:white, nan_color=:black) |
| 115 | + # |
| 116 | + # tricontourf!(ax, [p[1] for p in points2d], [p[2] for p in points2d], averagedTmis, colormap=:vik10, levels=5) |
| 117 | + tri = triangulate(points2d) |
| 118 | + faces = Matrix{Int}(undef, length(each_solid_triangle(tri)), 3) |
| 119 | + for (i, t) in enumerate(each_solid_triangle(tri)) |
| 120 | + faces[i, :] .= t |
| 121 | + end |
| 122 | + mesh!(ax, points2d, faces, color=tmis, colormap=colormap, rasterize=10) |
| 123 | + |
| 124 | + |
| 125 | + p = Polygon( |
| 126 | + Point2f[(-0.8, -0.5), (0.8, -0.5), (0.8, 0.9), (-0.8, 0.9)], |
| 127 | + [Point2f[ |
| 128 | + projection([1, 0, 0]), |
| 129 | + projection([0, 1, 0]), |
| 130 | + projection([0, 0, 1]) |
| 131 | + ]] |
| 132 | + ) |
| 133 | + |
| 134 | + |
| 135 | + # scatter!(ax, [p[1] for p in points2d], [p[2] for p in points2d], color=:black, strokewidth=0, markersize=5) |
| 136 | + scatter!(ax, [p[1] for p in points2d], [p[2] for p in points2d], color=tmis, strokewidth=0.25, strokecolor=:black, colormap=colormap, markersize=2) |
| 137 | + poly!(p, color=:white) |
| 138 | + lines!(ax, [ |
| 139 | + projection([1, 0, 0]), |
| 140 | + projection([0, 1, 0]), |
| 141 | + projection([0, 0, 1]), |
| 142 | + projection([1, 0, 0])], color=:black, joinstyle=:bevel, linewidth=0.75) |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + text!(ax, Point2f[projection([1.1, 0, 0]), projection([0, 1.1, 0]), projection([0, 0, 1.1])], text=[L"$p_X$", L"$p_Y$", L"$p_Z$"], color=:black, align=(:center, :center),fontsize=8) |
| 148 | + # limits!(ax, (-0.8, 0.8), (-0.5, 0.9)) |
| 149 | + Colorbar(fig[1, 2], limits=(minimum(tmis), maximum(tmis)), colormap=colormap, |
| 150 | + flipaxis=true, label=L"$$Tripartite Information", minorticksvisible=true, minortickalign=1.0,tickalign=1.0,spinewidth=0.75,minortickwidth=0.75,tickwidth=0.75,height=154, tellheight=false) |
| 151 | + limits!(ax, (-0.82, 0.82), (-0.515, 0.915)) |
| 152 | + filename = "honeycomb_circuit_L$(L)_D$(depth)_pres$(n)_avg$(averaging)_$(type)" |
| 153 | + save("figures/$filename.svg", fig) |
| 154 | + save("figures/$filename.png", fig) |
| 155 | + save("figures/$filename.pdf", fig) |
| 156 | +end |
0 commit comments