@@ -102,7 +102,10 @@ julia> ITensors.op(::OpName"X", ::SiteType"Boson", s::Index) = 1/sqrt(2) * op("a
102102Now we can use it in our callback by adding it to the list, for example:
103103
104104``` jldoctest callback_obj
105- julia> cb = ExpValueCallback("N(1,2,3,4),X(1,2,3,4)", sites, 10dt);
105+ julia> cb = ExpValueCallback("N(1,2,3,4),X(1,2,3,4)", sites, 10dt)
106+ ExpValueCallback
107+ Operators: N(1), N(2), N(3), N(4), X(1), X(2), X(3) and X(4)
108+ No measurements performed
106109
107110```
108111
@@ -114,7 +117,7 @@ the `"N(1,2,3,4),X(1,2,3,4)"` operators.
114117Let's set up a Hamiltonian operator and run a quick simulation with TDVP1 (see
115118the [ TDVP1 tutorial] ( @ref " Standard TDVP1 ") ):
116119
117- ``` jldoctest callback_obj
120+ ``` jldoctest callback_obj; filter = r"id=\d+" => "id=###"
118121julia> v = MPS(sites, n -> n == 1 ? "1" : "0");
119122
120123julia> v = enlargelinks(v, 4);
@@ -137,7 +140,7 @@ julia> tdvp1!(v, H, dt, 10; callback=cb, progress=false);
137140
138141By invoking ` cb ` we can see that there is new information:
139142
140- ``` jldoctest callback_obj
143+ ``` jldoctest callback_obj; filter = [r"9.99\d+" => "10.0", r"0.99\d+" => "1.0"]
141144julia> cb
142145ExpValueCallback
143146Operators: N(1), N(2), N(3), N(4), X(1), X(2), X(3) and X(4)
@@ -152,25 +155,25 @@ The computed expectation values can be accessed by calling the `expvalues`
152155method on the callback: the result is a dictionary where each local operator is
153156assigned the series of its expectation values.
154157
155- ``` jldoctest callback_obj
158+ ``` jldoctest callback_obj; filter = r" \[ \d \. 0 \+ 0 \. 0im, .*" => "[#.0+0.0im, ###"
156159julia> expvalues(cb)
157160OrderedCollections.OrderedDict{LocalOperator, Vector{ComplexF64}} with 8 entries:
158- N(1) => [1.0+0.0im, 0.332612+0.0im, 0.00109072 +0.0im, 0.00850228 +0.0im, 0.003 …
159- X(1) => [0.0+0.0im, -1.13453e-6-4.60006e-23im, -3.93457e-6-2.03123e-22im, -2. …
160- N(2) => [0.0+0.0im, 0.497967+0.0im , 0.132586+0.0im , 0.0262118+0.0im, 0.003191 …
161- X(2) => [0.0+0.0im, -1.61758e-6+6.61744e -23im, -2.2168e-6-2.60208e-18im, -2.1 …
162- N(3) => [0.0+0.0im, 0.149637+0.0im , 0.416359+0.0im , 0.0131695+0.0im, 0.047656 …
163- X(3) => [0.0+0.0im, -1.14256e-6+3.43722e-22im , -2.63261e-5-4.06683e-20im, -2. …
164- N(4) => [0.0+0.0im, 0.0184514+0.0im , 0.316095+0.0im , 0.227534+0.0im, 0.011087 …
165- X(4) => [0.0+0.0im, 4.27215e-5-2.05802e-21im, 0.000124825-1.03762e-20im, 5.01 …
161+ N(1) => [1.0+0.0im, 0.332612+0.0im, 0.00109051 +0.0im, 0.0085059 +0.0im, 0.0034 …
162+ X(1) => [0.0+0.0im, -4.93851e-9-1.55657e-24im, 1.54546e-7-6.4159e-24im, 1.083 …
163+ N(2) => [0.0+0.0im, 0.497967-2.52076e-23im , 0.132589-7.85081e-19im , 0.0262158 …
164+ X(2) => [0.0+0.0im, -1.73335e-9-1.0679e -23im, 6.49531e-7+1.56158e-20im, 2.344 …
165+ N(3) => [0.0+0.0im, 0.149637-2.63998e-23im , 0.416356-2.54984e-23im , 0.0131673 …
166+ X(3) => [0.0+0.0im, -3.70391e-7+4.54031e-23im , -3.44816e-7-9.89546e-22im, 3.5 …
167+ N(4) => [0.0+0.0im, 0.0184914+7.90412e-20im , 0.316137-1.95008e-18im , 0.227405 …
168+ X(4) => [0.0+0.0im, -4.55872e-6+1.36907e-23im, 6.11274e-6-1.46214e-22im, 8.46 …
166169
167170```
168171
169172The time series for individual operators can be accessed via the `expvalues(cb,
170173lop)` syntax, where ` lop` is either a ` LocalOperator` or a string that defines a
171174single ` LocalOperator ` .
172175
173- ``` jldoctest callback_obj
176+ ``` jldoctest callback_obj; filter = r"^(\s+)?[-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)? [-+] [-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)?im"m => "### + ###im"
174177julia> expvalues(cb, LocalOperator(3 => "N"))
17517811-element Vector{ComplexF64}:
176179 0.0 + 0.0im
@@ -205,7 +208,7 @@ Finally, we can access the time series relative to the state norm (which is the
205208actual 2-norm of the state, the trace, or another relevant quantity depending on
206209the chosen time-evolution algorithm).
207210
208- ``` jldoctest callback_obj
211+ ``` jldoctest callback_obj; filter = r"^(\s+)?[-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)? [-+] [-+]?([0-9]*[.])?[0-9]+([eE][-+]?\d+)?im"m => "### + ###im"
209212julia> measurements_norm(cb)
21021311-element Vector{ComplexF64}:
211214 1.0 + 0.0im
0 commit comments