qadence.draw
example plots
Mostly for quick, manual checking of correct plotting output.
from qadence import X , Y , kron
from qadence.draw import display
b = kron ( X ( 0 ), Y ( 1 ))
%3
08f7a8d48917451aa59caf5122487ad8
0
b29bd113f0d94ca38c215f536f164357
X
08f7a8d48917451aa59caf5122487ad8--b29bd113f0d94ca38c215f536f164357
a66f1f26e8b74bbba7c88e959fc2dbe5
1
7eba456eaa8143acbc8c463b086f6c0a
b29bd113f0d94ca38c215f536f164357--7eba456eaa8143acbc8c463b086f6c0a
4b2b97fc847f4bbe8f158ecaf5a17349
b7c9108e736c4a1d93adf75d2e12d1ec
Y
a66f1f26e8b74bbba7c88e959fc2dbe5--b7c9108e736c4a1d93adf75d2e12d1ec
b7c9108e736c4a1d93adf75d2e12d1ec--4b2b97fc847f4bbe8f158ecaf5a17349
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 0 ))
%3
b0fc5cda42c14cb792b987d75f0bf199
0
1c4d33a08ed54d32960091b25ec4315e
X
b0fc5cda42c14cb792b987d75f0bf199--1c4d33a08ed54d32960091b25ec4315e
8be149d8ec90426fbd754769db22e710
Y
1c4d33a08ed54d32960091b25ec4315e--8be149d8ec90426fbd754769db22e710
3f7cb00bb4f64ed59159bc5bae41dd3f
8be149d8ec90426fbd754769db22e710--3f7cb00bb4f64ed59159bc5bae41dd3f
from qadence import X , Y , chain
from qadence.draw import display
b = chain ( X ( 0 ), Y ( 1 ))
%3
e9d18979d0ee41a9bf671ca38d1de36d
0
5f8c5f7a69e548c4b00f1b01a1e7624b
X
e9d18979d0ee41a9bf671ca38d1de36d--5f8c5f7a69e548c4b00f1b01a1e7624b
26d3e7ab4779465487c11b8dbd11b4b8
1
91cacf8b2bbe42dd8dd0c975cf381590
5f8c5f7a69e548c4b00f1b01a1e7624b--91cacf8b2bbe42dd8dd0c975cf381590
f76db219879b4972924c1aa8097ae0c8
91cacf8b2bbe42dd8dd0c975cf381590--f76db219879b4972924c1aa8097ae0c8
9bcd1c085d27429aaed052b5907cee12
085d090aa1574168bcd99979f223b9d7
26d3e7ab4779465487c11b8dbd11b4b8--085d090aa1574168bcd99979f223b9d7
3ffadc87f6fe47deb56ac540390f538d
Y
085d090aa1574168bcd99979f223b9d7--3ffadc87f6fe47deb56ac540390f538d
3ffadc87f6fe47deb56ac540390f538d--9bcd1c085d27429aaed052b5907cee12
from qadence import X , Y , add
from qadence.draw import display
b = add ( X ( 0 ), Y ( 1 ), X ( 2 ))
%3
cluster_98e06b126dd540b79a9fc9ac3af6d6bf
e04dc554881444b59911f8b6b17bd5ad
0
c40e669fa0b544bb942081e630666191
e04dc554881444b59911f8b6b17bd5ad--c40e669fa0b544bb942081e630666191
d9052d89939149898f355bb4b0781968
1
48dd7d47a27e43efb4f718df1fec32eb
c40e669fa0b544bb942081e630666191--48dd7d47a27e43efb4f718df1fec32eb
0d90a3c86c014c13ac94d594dfde6be7
608a1c88fdee4168ad3a4a1f66dfc600
AddBlock
d9052d89939149898f355bb4b0781968--608a1c88fdee4168ad3a4a1f66dfc600
8d81a633cd3e4cb4b5132ee8ad012759
2
608a1c88fdee4168ad3a4a1f66dfc600--0d90a3c86c014c13ac94d594dfde6be7
d8499d78bd6e48768a2d8a187dfcaa5c
aa8420da4ecc478c8a6ccd399fe0de5a
8d81a633cd3e4cb4b5132ee8ad012759--aa8420da4ecc478c8a6ccd399fe0de5a
aa8420da4ecc478c8a6ccd399fe0de5a--d8499d78bd6e48768a2d8a187dfcaa5c
from qadence import CNOT , RX , HamEvo , X , Y , Z , chain , kron
rx = kron ( RX ( 3 , 0.5 ), RX ( 2 , "x" ))
rx . tag = "rx"
gen = chain ( Z ( i ) for i in range ( 4 ))
# `chain` puts things in sequence
block = chain (
kron ( X ( 0 ), Y ( 1 ), rx ),
CNOT ( 2 , 3 ),
HamEvo ( gen , 10 )
)
%3
cluster_7b90a4cab4d14120848adfe25f592ba7
cluster_7e371b51c19a42f789bb6a28e02c3c21
rx
ceda626114114b1ebffca90ad2c7e044
0
eae3bd9c333448a0a8ba00a2fd8c69be
X
ceda626114114b1ebffca90ad2c7e044--eae3bd9c333448a0a8ba00a2fd8c69be
07aef37d129c4a679ad73c12a6d05056
1
9beecae672d5402495b38a42a6340259
eae3bd9c333448a0a8ba00a2fd8c69be--9beecae672d5402495b38a42a6340259
d91a43c776174022bd3ee19c6aa2cf5d
9beecae672d5402495b38a42a6340259--d91a43c776174022bd3ee19c6aa2cf5d
14ebde9c92e5488197b4abd3068bc2d0
d91a43c776174022bd3ee19c6aa2cf5d--14ebde9c92e5488197b4abd3068bc2d0
7cf5063f9d794d4c8f25708d9f9acfa5
8c96ca5c8d984b26a62cbfea8a2c67df
Y
07aef37d129c4a679ad73c12a6d05056--8c96ca5c8d984b26a62cbfea8a2c67df
c613d774a64c42179ad100b7fb0f2265
2
19d7f66f990d4242baa9b5c23bc46ec4
8c96ca5c8d984b26a62cbfea8a2c67df--19d7f66f990d4242baa9b5c23bc46ec4
0bf1ded0d90c4c33855c93ad395a7877
HamEvo
19d7f66f990d4242baa9b5c23bc46ec4--0bf1ded0d90c4c33855c93ad395a7877
0bf1ded0d90c4c33855c93ad395a7877--7cf5063f9d794d4c8f25708d9f9acfa5
92d09149151b44759e12f57bd6c7ea25
8fd4fce5820e49c5a6bfb63c1f12bd1a
RX(x)
c613d774a64c42179ad100b7fb0f2265--8fd4fce5820e49c5a6bfb63c1f12bd1a
77e2918f3f584dd38b62b74365ab7839
3
77e3b8aef82b499c8b946b686d5bd056
8fd4fce5820e49c5a6bfb63c1f12bd1a--77e3b8aef82b499c8b946b686d5bd056
0a32fb99da224bc3969c482c3f571b5d
t = 10
77e3b8aef82b499c8b946b686d5bd056--0a32fb99da224bc3969c482c3f571b5d
0a32fb99da224bc3969c482c3f571b5d--92d09149151b44759e12f57bd6c7ea25
ad6060f284064f3e997d4a878be6beff
73e1ea2dd84342e9bc6fb72b3ae93e92
RX(0.5)
77e2918f3f584dd38b62b74365ab7839--73e1ea2dd84342e9bc6fb72b3ae93e92
54a21a8745404eac8cac149b8795d8b9
X
73e1ea2dd84342e9bc6fb72b3ae93e92--54a21a8745404eac8cac149b8795d8b9
54a21a8745404eac8cac149b8795d8b9--77e3b8aef82b499c8b946b686d5bd056
d7c4ec1bbb2b44e78688fe4b18cb4cff
54a21a8745404eac8cac149b8795d8b9--d7c4ec1bbb2b44e78688fe4b18cb4cff
d7c4ec1bbb2b44e78688fe4b18cb4cff--ad6060f284064f3e997d4a878be6beff
from qadence import feature_map , hea , chain
block = chain ( feature_map ( 4 , reupload_scaling = "Tower" ), hea ( 4 , 2 ))
%3
cluster_de80dfa209274db1a8225918ca793729
HEA
cluster_3e1ade5726e44cb0aaa88cd0a6c55bcb
Tower Fourier FM
b0af123b0bf94acbbb35b00bd709d9a2
0
a371a7ecd0f4407481dd0bfe65b338c6
RX(1.0*phi)
b0af123b0bf94acbbb35b00bd709d9a2--a371a7ecd0f4407481dd0bfe65b338c6
f8bea35d36204fafb42008aa7238d92c
1
bd6ba27e40264a8dbcc1445db7954393
RX(theta₀)
a371a7ecd0f4407481dd0bfe65b338c6--bd6ba27e40264a8dbcc1445db7954393
0995b94eff6f4f64b142a41a9edd3a8d
RY(theta₄)
bd6ba27e40264a8dbcc1445db7954393--0995b94eff6f4f64b142a41a9edd3a8d
a97e3860d3b64295b3bb79078f468c75
RX(theta₈)
0995b94eff6f4f64b142a41a9edd3a8d--a97e3860d3b64295b3bb79078f468c75
d6dae32af9754624a1ca7efaa20a9106
a97e3860d3b64295b3bb79078f468c75--d6dae32af9754624a1ca7efaa20a9106
af8c7094fd204721ab9b0c0a9c201abe
d6dae32af9754624a1ca7efaa20a9106--af8c7094fd204721ab9b0c0a9c201abe
9b0cf67b26894864a60639a7db6885bb
RX(theta₁₂)
af8c7094fd204721ab9b0c0a9c201abe--9b0cf67b26894864a60639a7db6885bb
7439c414ac7a4d74bf60f5ceb12e163c
RY(theta₁₆)
9b0cf67b26894864a60639a7db6885bb--7439c414ac7a4d74bf60f5ceb12e163c
5473de84e8074b91a0bb64d95ef5c0ee
RX(theta₂₀)
7439c414ac7a4d74bf60f5ceb12e163c--5473de84e8074b91a0bb64d95ef5c0ee
2df8460f785648de8ee8b00450128fe8
5473de84e8074b91a0bb64d95ef5c0ee--2df8460f785648de8ee8b00450128fe8
2884bd5b96f249cf82227271310841fd
2df8460f785648de8ee8b00450128fe8--2884bd5b96f249cf82227271310841fd
8e4128ad993448ada08f98b6159fa540
2884bd5b96f249cf82227271310841fd--8e4128ad993448ada08f98b6159fa540
612616864e3f4fe485f9c2353ba2fcb9
c9a1b289d9f04a4f988e8786284515bc
RX(2.0*phi)
f8bea35d36204fafb42008aa7238d92c--c9a1b289d9f04a4f988e8786284515bc
4bb990f0b9a24f99b87258e8a0bc38c7
2
184fad702b2d414c801fe058d6624c15
RX(theta₁)
c9a1b289d9f04a4f988e8786284515bc--184fad702b2d414c801fe058d6624c15
0748a6b0733e42f0ada2c3762c2b84bd
RY(theta₅)
184fad702b2d414c801fe058d6624c15--0748a6b0733e42f0ada2c3762c2b84bd
b822b48b536b419abb8ce79cf06bb78e
RX(theta₉)
0748a6b0733e42f0ada2c3762c2b84bd--b822b48b536b419abb8ce79cf06bb78e
fff20490943741549aa55bcfb714577c
X
b822b48b536b419abb8ce79cf06bb78e--fff20490943741549aa55bcfb714577c
fff20490943741549aa55bcfb714577c--d6dae32af9754624a1ca7efaa20a9106
50ff3dcc391041c093739e3aea89508a
fff20490943741549aa55bcfb714577c--50ff3dcc391041c093739e3aea89508a
fc3d5f7c53ba4481ada795e1caff6581
RX(theta₁₃)
50ff3dcc391041c093739e3aea89508a--fc3d5f7c53ba4481ada795e1caff6581
012b18367d064bd08a2aea1e06b7da10
RY(theta₁₇)
fc3d5f7c53ba4481ada795e1caff6581--012b18367d064bd08a2aea1e06b7da10
b41459827d854c1cac8734aec940e97f
RX(theta₂₁)
012b18367d064bd08a2aea1e06b7da10--b41459827d854c1cac8734aec940e97f
15972775afde4807b198d5e5aa1b5680
X
b41459827d854c1cac8734aec940e97f--15972775afde4807b198d5e5aa1b5680
15972775afde4807b198d5e5aa1b5680--2df8460f785648de8ee8b00450128fe8
0bbb010b10854bf6ac02a43c2c8bf58d
15972775afde4807b198d5e5aa1b5680--0bbb010b10854bf6ac02a43c2c8bf58d
0bbb010b10854bf6ac02a43c2c8bf58d--612616864e3f4fe485f9c2353ba2fcb9
42363e9fb675487a8b09c419a2c4ca46
2868a59ea47c47da93932dd41e158865
RX(3.0*phi)
4bb990f0b9a24f99b87258e8a0bc38c7--2868a59ea47c47da93932dd41e158865
6fb158c12ccb4538aa8c1aaec4f5e1dd
3
3377b346f70a484597beed4835bb6a30
RX(theta₂)
2868a59ea47c47da93932dd41e158865--3377b346f70a484597beed4835bb6a30
f90e4940ab604186990f0fccdf761e52
RY(theta₆)
3377b346f70a484597beed4835bb6a30--f90e4940ab604186990f0fccdf761e52
6c4affbc01d34356a3c42ccb0b14e0a0
RX(theta₁₀)
f90e4940ab604186990f0fccdf761e52--6c4affbc01d34356a3c42ccb0b14e0a0
2f9a30c2653245d9b35235228f82d872
6c4affbc01d34356a3c42ccb0b14e0a0--2f9a30c2653245d9b35235228f82d872
a4137f84afeb4dfd8933811c3d5f56f5
X
2f9a30c2653245d9b35235228f82d872--a4137f84afeb4dfd8933811c3d5f56f5
a4137f84afeb4dfd8933811c3d5f56f5--50ff3dcc391041c093739e3aea89508a
05369b58c15f4effba5577e8f3511003
RX(theta₁₄)
a4137f84afeb4dfd8933811c3d5f56f5--05369b58c15f4effba5577e8f3511003
842a17def1b047ec8ea83d317baf954e
RY(theta₁₈)
05369b58c15f4effba5577e8f3511003--842a17def1b047ec8ea83d317baf954e
9f6c4a0f90b045cbb7035339a52a360f
RX(theta₂₂)
842a17def1b047ec8ea83d317baf954e--9f6c4a0f90b045cbb7035339a52a360f
245ce4327d714e879dabb4409212d01e
9f6c4a0f90b045cbb7035339a52a360f--245ce4327d714e879dabb4409212d01e
f6bf147a9a22478d87b4ff3d2a7f0d4d
X
245ce4327d714e879dabb4409212d01e--f6bf147a9a22478d87b4ff3d2a7f0d4d
f6bf147a9a22478d87b4ff3d2a7f0d4d--0bbb010b10854bf6ac02a43c2c8bf58d
f6bf147a9a22478d87b4ff3d2a7f0d4d--42363e9fb675487a8b09c419a2c4ca46
cb979a9c10b3465d8edd5c30a4ba823d
d5394dccbbed428dad1dfb649d4bc9b5
RX(4.0*phi)
6fb158c12ccb4538aa8c1aaec4f5e1dd--d5394dccbbed428dad1dfb649d4bc9b5
3c715c536577458ea48c0b8af5d14320
RX(theta₃)
d5394dccbbed428dad1dfb649d4bc9b5--3c715c536577458ea48c0b8af5d14320
53058379cd054936a58a06e1613ea13b
RY(theta₇)
3c715c536577458ea48c0b8af5d14320--53058379cd054936a58a06e1613ea13b
2350ab1cfb0f4aae80a81b1cfaff358e
RX(theta₁₁)
53058379cd054936a58a06e1613ea13b--2350ab1cfb0f4aae80a81b1cfaff358e
4a89a3bfa53f4deab15bf8acbc74f5a4
X
2350ab1cfb0f4aae80a81b1cfaff358e--4a89a3bfa53f4deab15bf8acbc74f5a4
4a89a3bfa53f4deab15bf8acbc74f5a4--2f9a30c2653245d9b35235228f82d872
cf4eeac2553440f4bf04ff8b2f5bd553
4a89a3bfa53f4deab15bf8acbc74f5a4--cf4eeac2553440f4bf04ff8b2f5bd553
7c0927469ec6471fa0523ad643d79cc2
RX(theta₁₅)
cf4eeac2553440f4bf04ff8b2f5bd553--7c0927469ec6471fa0523ad643d79cc2
963d96fa3714438599ff438ada02d7a9
RY(theta₁₉)
7c0927469ec6471fa0523ad643d79cc2--963d96fa3714438599ff438ada02d7a9
dce2eb798ca24dd99f80162e083a48b8
RX(theta₂₃)
963d96fa3714438599ff438ada02d7a9--dce2eb798ca24dd99f80162e083a48b8
98076b0bea3d4f49b116db39934c6672
X
dce2eb798ca24dd99f80162e083a48b8--98076b0bea3d4f49b116db39934c6672
98076b0bea3d4f49b116db39934c6672--245ce4327d714e879dabb4409212d01e
251638e8d60546489ec34509a53c52cf
98076b0bea3d4f49b116db39934c6672--251638e8d60546489ec34509a53c52cf
251638e8d60546489ec34509a53c52cf--cb979a9c10b3465d8edd5c30a4ba823d
from qadence import QuantumModel , QuantumCircuit , total_magnetization , hea
model = QuantumModel ( QuantumCircuit ( 3 , hea ( 3 , 2 )), total_magnetization ( 3 ))
%3
cluster_df214ee00cae427e98177f00520a5f12
Obs.
cluster_3c253d2af27e44d59ac066de590014e5
cluster_043269445e624b45b260e0f18137f313
HEA
c6fea4bc810f405496cf508216ead4f9
0
40de705c15f44c09ba4dafb9dc4c1ea8
RX(theta₀)
c6fea4bc810f405496cf508216ead4f9--40de705c15f44c09ba4dafb9dc4c1ea8
28b25e8bdb774867ae28b1787f592978
1
e86447ebc9ee432fb15bf8a25e605333
RY(theta₃)
40de705c15f44c09ba4dafb9dc4c1ea8--e86447ebc9ee432fb15bf8a25e605333
90732327dc7b451a904bbbbb404c9326
RX(theta₆)
e86447ebc9ee432fb15bf8a25e605333--90732327dc7b451a904bbbbb404c9326
d63d93592b8a48749209a72a9f82b11a
90732327dc7b451a904bbbbb404c9326--d63d93592b8a48749209a72a9f82b11a
83dc09d99c184ab18448336265273d46
d63d93592b8a48749209a72a9f82b11a--83dc09d99c184ab18448336265273d46
86f8b54655a4434aa4874b340c684b26
RX(theta₉)
83dc09d99c184ab18448336265273d46--86f8b54655a4434aa4874b340c684b26
e66bd8dbc9264814a2c1d8a47232b2b2
RY(theta₁₂)
86f8b54655a4434aa4874b340c684b26--e66bd8dbc9264814a2c1d8a47232b2b2
4fa85b54d80b45339c0f0a28b16b5ef9
RX(theta₁₅)
e66bd8dbc9264814a2c1d8a47232b2b2--4fa85b54d80b45339c0f0a28b16b5ef9
469b352b3073419f887dc4dd9d53eb6d
4fa85b54d80b45339c0f0a28b16b5ef9--469b352b3073419f887dc4dd9d53eb6d
66a56929478b49f196917b1f4c6d1c98
469b352b3073419f887dc4dd9d53eb6d--66a56929478b49f196917b1f4c6d1c98
94f2ecd543e740a3874337c5afe9de97
66a56929478b49f196917b1f4c6d1c98--94f2ecd543e740a3874337c5afe9de97
2193f83c1b3946cdb117c1bc594bb40e
94f2ecd543e740a3874337c5afe9de97--2193f83c1b3946cdb117c1bc594bb40e
ec447a66910a442284429619fcdef433
38e1231c11c541359e05543660140eef
RX(theta₁)
28b25e8bdb774867ae28b1787f592978--38e1231c11c541359e05543660140eef
2682f790de9f413ab6f75a6f7c3ec320
2
0dfe201d8011465c9a395415cb21a7d1
RY(theta₄)
38e1231c11c541359e05543660140eef--0dfe201d8011465c9a395415cb21a7d1
d30649026be04e6ca289348dcc82b576
RX(theta₇)
0dfe201d8011465c9a395415cb21a7d1--d30649026be04e6ca289348dcc82b576
ab25a9116b47404c95227d3f3105353b
X
d30649026be04e6ca289348dcc82b576--ab25a9116b47404c95227d3f3105353b
ab25a9116b47404c95227d3f3105353b--d63d93592b8a48749209a72a9f82b11a
ba858f3026c4429da3550594d04b8c4b
ab25a9116b47404c95227d3f3105353b--ba858f3026c4429da3550594d04b8c4b
4467cb6cab134c8495849cd5023233bb
RX(theta₁₀)
ba858f3026c4429da3550594d04b8c4b--4467cb6cab134c8495849cd5023233bb
cbaed39492d04bc5b793c64ac6a2ac81
RY(theta₁₃)
4467cb6cab134c8495849cd5023233bb--cbaed39492d04bc5b793c64ac6a2ac81
dada4bbd5cdb4dc2902ca27ae0cb4960
RX(theta₁₆)
cbaed39492d04bc5b793c64ac6a2ac81--dada4bbd5cdb4dc2902ca27ae0cb4960
03799b901092412bafd5f9ef9f456e6b
X
dada4bbd5cdb4dc2902ca27ae0cb4960--03799b901092412bafd5f9ef9f456e6b
03799b901092412bafd5f9ef9f456e6b--469b352b3073419f887dc4dd9d53eb6d
921088fba46948ffb2470a728a00dfaf
03799b901092412bafd5f9ef9f456e6b--921088fba46948ffb2470a728a00dfaf
ed200661c87d4e409ea425a92bedb90a
AddBlock
921088fba46948ffb2470a728a00dfaf--ed200661c87d4e409ea425a92bedb90a
ed200661c87d4e409ea425a92bedb90a--ec447a66910a442284429619fcdef433
219eccb9b0d141b8a56a04a4b7a8b97f
022ea6cf5a804e6b8a97b6cc65642113
RX(theta₂)
2682f790de9f413ab6f75a6f7c3ec320--022ea6cf5a804e6b8a97b6cc65642113
12cea888aeea48d6a423845e59d7ca64
RY(theta₅)
022ea6cf5a804e6b8a97b6cc65642113--12cea888aeea48d6a423845e59d7ca64
239f4610bf074db8b33283ec281d241d
RX(theta₈)
12cea888aeea48d6a423845e59d7ca64--239f4610bf074db8b33283ec281d241d
d1e10dfe93c646ff84c516a2b4fb6f49
239f4610bf074db8b33283ec281d241d--d1e10dfe93c646ff84c516a2b4fb6f49
303514584ab8492a8ad823458e103b52
X
d1e10dfe93c646ff84c516a2b4fb6f49--303514584ab8492a8ad823458e103b52
303514584ab8492a8ad823458e103b52--ba858f3026c4429da3550594d04b8c4b
799e1e793cb84b5dbe3264787e806e2d
RX(theta₁₁)
303514584ab8492a8ad823458e103b52--799e1e793cb84b5dbe3264787e806e2d
7dc49395d5d649228fba6825af776527
RY(theta₁₄)
799e1e793cb84b5dbe3264787e806e2d--7dc49395d5d649228fba6825af776527
bc54b98ea5ed47c59f1f88f5f7d5bf02
RX(theta₁₇)
7dc49395d5d649228fba6825af776527--bc54b98ea5ed47c59f1f88f5f7d5bf02
58c7e34a2a404b568e5d17b66f9ae782
bc54b98ea5ed47c59f1f88f5f7d5bf02--58c7e34a2a404b568e5d17b66f9ae782
d95f9ed4c9334d51a49b54992b4c506b
X
58c7e34a2a404b568e5d17b66f9ae782--d95f9ed4c9334d51a49b54992b4c506b
d95f9ed4c9334d51a49b54992b4c506b--921088fba46948ffb2470a728a00dfaf
f76d6875f30241ae89a330ee2adb013f
d95f9ed4c9334d51a49b54992b4c506b--f76d6875f30241ae89a330ee2adb013f
f76d6875f30241ae89a330ee2adb013f--219eccb9b0d141b8a56a04a4b7a8b97f
from qadence import *
b = chain ( SWAP ( 0 , 1 ), SWAP ( 0 , 3 ))
%3
9e0616a10bf844c28c3a4d4b907e1597
0
4b5d62599dba4bbca90892a274efe387
9e0616a10bf844c28c3a4d4b907e1597--4b5d62599dba4bbca90892a274efe387
76eb331f04f14ae59508ea979696bafc
1
8b11be321350418399c47e92ef2bb227
e78d4409969f4a90acfc5dd8b5ef8742
4b5d62599dba4bbca90892a274efe387--e78d4409969f4a90acfc5dd8b5ef8742
a589059de5a44540a4f8c93e29036ff1
8b11be321350418399c47e92ef2bb227--a589059de5a44540a4f8c93e29036ff1
2fb10f8f6611449d8128a546600f0f51
277a3c36a6984226b4e082b3052cbbe4
a589059de5a44540a4f8c93e29036ff1--277a3c36a6984226b4e082b3052cbbe4
f63781b63101402396d0d17c366e91ab
2fb10f8f6611449d8128a546600f0f51--f63781b63101402396d0d17c366e91ab
8db1d09ebe5340048a71dae243d8ba08
fc93a14eddde4f3c898826ef9f3dc781
76eb331f04f14ae59508ea979696bafc--fc93a14eddde4f3c898826ef9f3dc781
0cafd7dae04b40b9a8b9dee7b593e5c9
2
fc93a14eddde4f3c898826ef9f3dc781--8b11be321350418399c47e92ef2bb227
278f7d61b6274521ad8a2379e029823b
e78d4409969f4a90acfc5dd8b5ef8742--278f7d61b6274521ad8a2379e029823b
c24dc5eba34d4385abf5ac8a5499b528
278f7d61b6274521ad8a2379e029823b--c24dc5eba34d4385abf5ac8a5499b528
c24dc5eba34d4385abf5ac8a5499b528--8db1d09ebe5340048a71dae243d8ba08
65b049241a204e398a2a77032b753d28
8a74e9a8e2af42988e8f7abca087c7f1
0cafd7dae04b40b9a8b9dee7b593e5c9--8a74e9a8e2af42988e8f7abca087c7f1
52d33b2bf035441a99261fd8d9d2fd97
3
316e3f5dc84043a08669d14858940271
8a74e9a8e2af42988e8f7abca087c7f1--316e3f5dc84043a08669d14858940271
3026b4a21d284abb9970e158b206a7e8
316e3f5dc84043a08669d14858940271--3026b4a21d284abb9970e158b206a7e8
3698d1048f594c42979fb8ba501958a5
3026b4a21d284abb9970e158b206a7e8--3698d1048f594c42979fb8ba501958a5
3698d1048f594c42979fb8ba501958a5--65b049241a204e398a2a77032b753d28
9e0eb6059cc94e2ca0349c58089abb5e
f1567da6761041789df7f30a466aea58
52d33b2bf035441a99261fd8d9d2fd97--f1567da6761041789df7f30a466aea58
92d06e52a4de4d2093cd0640c2e7d5ed
f1567da6761041789df7f30a466aea58--92d06e52a4de4d2093cd0640c2e7d5ed
323b3fd59d184b27a7c28c39776ef7ae
92d06e52a4de4d2093cd0640c2e7d5ed--323b3fd59d184b27a7c28c39776ef7ae
323b3fd59d184b27a7c28c39776ef7ae--2fb10f8f6611449d8128a546600f0f51
277a3c36a6984226b4e082b3052cbbe4--9e0eb6059cc94e2ca0349c58089abb5e
from qadence import *
b = chain ( CPHASE ( 0 , 1 , 0.5 ), CPHASE ( 0 , 2 , 0.5 ), CPHASE ( 0 , 3 , 0.5 ))
%3
e24de86c3a0944d7af697596b70bb664
0
b75431b6049f45fa9788c8823abcb4db
e24de86c3a0944d7af697596b70bb664--b75431b6049f45fa9788c8823abcb4db
53c5f28b7e2b473e82851badfcd0cfec
1
fa2eabeb56724f6f818e0597f23a87cc
b75431b6049f45fa9788c8823abcb4db--fa2eabeb56724f6f818e0597f23a87cc
001926dd76bf4271aeaedeb5c3d1133c
fa2eabeb56724f6f818e0597f23a87cc--001926dd76bf4271aeaedeb5c3d1133c
291ef5c1dd0f448bad8bce7e2bd69cb7
001926dd76bf4271aeaedeb5c3d1133c--291ef5c1dd0f448bad8bce7e2bd69cb7
27acc55cec8d4a83a8f11d63e0e2cdb6
dc0621c8d8ca4e629499285ea4ad7d8a
PHASE(0.5)
53c5f28b7e2b473e82851badfcd0cfec--dc0621c8d8ca4e629499285ea4ad7d8a
c905f8d1c62a480bb0581efc0c6c8f2f
2
dc0621c8d8ca4e629499285ea4ad7d8a--b75431b6049f45fa9788c8823abcb4db
bd695772b847405ab6607e8883ee77b7
dc0621c8d8ca4e629499285ea4ad7d8a--bd695772b847405ab6607e8883ee77b7
336eaba0b6b340b699f193a58be2ffc3
bd695772b847405ab6607e8883ee77b7--336eaba0b6b340b699f193a58be2ffc3
336eaba0b6b340b699f193a58be2ffc3--27acc55cec8d4a83a8f11d63e0e2cdb6
f186bf82c1944627a27c5005d5c01efc
5cceb655e7a4485bad5f80676cbc962b
c905f8d1c62a480bb0581efc0c6c8f2f--5cceb655e7a4485bad5f80676cbc962b
684ceb21074848a9b752aab88f038cf9
3
f61213e467fa4b038d94079b7bbbcbba
PHASE(0.5)
5cceb655e7a4485bad5f80676cbc962b--f61213e467fa4b038d94079b7bbbcbba
f61213e467fa4b038d94079b7bbbcbba--fa2eabeb56724f6f818e0597f23a87cc
a14855f34aad42369a7a69ab3fcf1ed9
f61213e467fa4b038d94079b7bbbcbba--a14855f34aad42369a7a69ab3fcf1ed9
a14855f34aad42369a7a69ab3fcf1ed9--f186bf82c1944627a27c5005d5c01efc
7ca5d8a838e14ed8a4981bb0fd1b83c7
2b59d1f71bcb4fa588fbbc9bcde0ecef
684ceb21074848a9b752aab88f038cf9--2b59d1f71bcb4fa588fbbc9bcde0ecef
47b7f0584ab548c7bce352711b1d0739
2b59d1f71bcb4fa588fbbc9bcde0ecef--47b7f0584ab548c7bce352711b1d0739
25fd06be3dfc47f2b2be8329f4015ec8
PHASE(0.5)
47b7f0584ab548c7bce352711b1d0739--25fd06be3dfc47f2b2be8329f4015ec8
25fd06be3dfc47f2b2be8329f4015ec8--001926dd76bf4271aeaedeb5c3d1133c
25fd06be3dfc47f2b2be8329f4015ec8--7ca5d8a838e14ed8a4981bb0fd1b83c7
Developer documentation
This section contains examples in pure graphviz that can be used to understand roughly what is done
in the actual drawing backend.
import graphviz
font_name = "Sans-Serif"
font_size = "8"
graph_attr = {
"rankdir" : "LR" , # LR = left to right, TB = top to bottom
"nodesep" : "0.1" , # In inches, tells distance between nodes without edges
"compound" : "true" , # Needed to draw properly edges in hamevo when content is hidden
"splines" : "false" , # Needed to draw control gates vertical lines one over the other
} # These are the default values for graphs
node_attr = {
"shape" : "box" , # 'box' for normal nodes, 'point' for control gates or 'plaintext' for starting nodes (the qubit label).
"style" : "rounded" , # Unfortunately we can't specify the radius of the rounded, at least for this version
"fontname" : font_name ,
"fontsize" : font_size ,
"width" : "0.1" , # In inches, it doesn't get tinier than the label font.
"height" : "0.1" # In inches, it doesn't get tinier than the label font.
} # These are the defaults values that can be overridden at node declaration.
default_cluster_attr = {
"fontname" : font_name ,
"fontsize" : font_size ,
"labelloc" : "b" , # location of cluster label. b as bottom, t as top
"style" : "rounded"
} # These are the defaults values that can be overridden at sub graph declaration
hamevo_cluster_attr = {
"label" : "HamEvo(t=10)"
}
hamevo_cluster_attr . update ( default_cluster_attr )
h = graphviz . Graph ( graph_attr = graph_attr , node_attr = node_attr )
h . node ( "Hello World!" )
h
# Define graph
h = graphviz . Graph ( node_attr = node_attr , graph_attr = graph_attr )
# Add start and end nodes
for i in range ( 4 ):
h . node ( f 's { i } ' , shape = "plaintext" , label = f ' { i } ' , group = f " { i } " )
h . node ( f 'e { i } ' , style = 'invis' , group = f " { i } " )
# Add nodes
h . node ( 'X' , group = "0" )
h . node ( 'Y' , group = "1" )
# Add hamevo and its nodes
hamevo = graphviz . Graph ( name = 'cluster_hamevo' , graph_attr = hamevo_cluster_attr )
for i in range ( 4 ):
hamevo . node ( f 'z { i } ' , shape = "box" , style = "invis" , label = f ' { i } ' , group = f " { i } " )
h . subgraph ( hamevo )
# Add rx gates cluster and its nodes
cluster_attr = { "label" : "RX gates" }
cluster_attr . update ( default_cluster_attr )
cluster = graphviz . Graph ( name = "cluster_0" , graph_attr = cluster_attr )
cluster . node ( 'RX(x)' , group = "2" )
cluster . node ( 'RX(0.5)' , group = "3" )
h . subgraph ( cluster )
h . node ( 'cnot0' , label = '' , shape = 'point' , width = '0.1' , group = '0' )
h . node ( 'cnot1' , label = 'X' , group = '1' )
h . node ( 'cnot2' , label = '' , shape = 'point' , width = '0.1' , group = '2' )
h . node ( 'cnot3' , label = '' , shape = 'point' , width = '0.1' , group = '3' )
# Add edges
h . edge ( 's0' , 'X' )
h . edge ( 'X' , 'cnot0' )
h . edge ( 'cnot0' , 'z0' , lhead = 'cluster_hamevo' )
h . edge ( 'z0' , 'e0' , ltail = 'cluster_hamevo' )
h . edge ( 's1' , 'Y' )
h . edge ( 'Y' , 'cnot1' )
h . edge ( 'cnot1' , 'z1' , lhead = 'cluster_hamevo' )
h . edge ( 'z1' , 'e1' , ltail = 'cluster_hamevo' )
h . edge ( 's2' , 'RX(x)' )
h . edge ( 'RX(x)' , 'cnot2' )
h . edge ( 'cnot2' , 'z2' , lhead = 'cluster_hamevo' )
h . edge ( 'z2' , 'e2' , ltail = 'cluster_hamevo' )
h . edge ( 's3' , 'RX(0.5)' )
h . edge ( 'RX(0.5)' , 'cnot3' )
h . edge ( 'cnot3' , 'z3' , lhead = 'cluster_hamevo' )
h . edge ( 'z3' , 'e3' , ltail = 'cluster_hamevo' )
h . edge ( 'cnot1' , 'cnot0' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h . edge ( 'cnot1' , 'cnot2' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h . edge ( 'cnot1' , 'cnot3' , constraint = 'false' ) # constraint: false is needed to draw vertical edges
h
Example of cluster of clusters
# Define graph
h = graphviz . Graph ( node_attr = node_attr , graph_attr = graph_attr )
# Define start and end nodes
for i in range ( 4 ):
h . node ( f 's { i } ' , shape = "plaintext" , label = f ' { i } ' , group = f " { i } " )
h . node ( f 'e { i } ' , style = 'invis' , group = f " { i } " )
# Define outer cluster
cluster_attr = { "label" : "Outer cluster" }
cluster_attr . update ( default_cluster_attr )
outer_cluster = graphviz . Graph ( name = "cluster_outer" , graph_attr = cluster_attr )
# Define inner cluster 1 and its nodes
cluster_attr = { "label" : "Inner cluster 1" }
cluster_attr . update ( default_cluster_attr )
inner1_cluster = graphviz . Graph ( name = "cluster_inner1" , graph_attr = cluster_attr )
inner1_cluster . node ( "a0" , group = "0" )
inner1_cluster . node ( "a1" , group = "1" )
outer_cluster . subgraph ( inner1_cluster )
# Define inner cluster 2 and its nodes
cluster_attr = { "label" : "Inner cluster 2" }
cluster_attr . update ( default_cluster_attr )
inner2_cluster = graphviz . Graph ( name = "cluster_inner2" , graph_attr = cluster_attr )
inner2_cluster . node ( "a2" , group = "2" )
inner2_cluster . node ( "a3" , group = "3" )
outer_cluster . subgraph ( inner2_cluster )
# This has to be done here, after inner clusters definitions
h . subgraph ( outer_cluster )
# Define more nodes
for i in range ( 4 ):
h . node ( f "b { i } " , group = f " { i } " )
for i in range ( 4 ):
h . edge ( f 's { i } ' , f 'a { i } ' )
h . edge ( f 'a { i } ' , f 'b { i } ' )
h . edge ( f 'b { i } ' , f 'e { i } ' )
h