|
| 1 | +import ProgressMeter |
| 2 | + |
1 | 3 | abstract QuPropagatorMethod
|
2 | 4 |
|
3 | 5 | @doc """
|
@@ -177,7 +179,59 @@ QuEvolutionOp{QE<:QuEquation}(eq::QE, dt::Float64) = QuEvolutionOp(operator(eq),
|
177 | 179 |
|
178 | 180 | QuEvolutionOp{QE<:QuEquation}(eq::QE, tf::Float64, ti::Float64) = QuEvolutionOp(eq, tf-ti)
|
179 | 181 |
|
| 182 | +macro showprogress(qprop) |
| 183 | + return quote |
| 184 | + n = length(@eval $qprop.tlist) |
| 185 | + evolved_states = Array(QuBase.AbstractQuArray, n-1) |
| 186 | + p = ProgressMeter.Progress(n, 1, "Computation of evolved states in progress ... ", 50) |
| 187 | + i = 1 |
| 188 | + for (t, psi) in $(esc(qprop)) |
| 189 | + evolved_states[i] = psi |
| 190 | + i = i + 1 |
| 191 | + ProgressMeter.next!(p) |
| 192 | + end |
| 193 | + evolved_states |
| 194 | + end |
| 195 | +end |
| 196 | + |
| 197 | +macro showprogress_trace(qprop) |
| 198 | + return quote |
| 199 | + n = length(@eval $qprop.tlist) |
| 200 | + trace_evolved_states = Array(Complex128, n-1) |
| 201 | + p = ProgressMeter.Progress(n, 1, "Computation of the trace of evolved states in progress ... ", 50) |
| 202 | + i = 1 |
| 203 | + for (t, psi) in $(esc(qprop)) |
| 204 | + trace_evolved_states[i] = trace(psi) |
| 205 | + i = i + 1 |
| 206 | + ProgressMeter.next!(p) |
| 207 | + end |
| 208 | + trace_evolved_states |
| 209 | + end |
| 210 | +end |
| 211 | + |
| 212 | +macro showprogress_expectation(qprop, expectation_operators) |
| 213 | + return quote |
| 214 | + n = length(@eval $qprop.tlist) |
| 215 | + m = length(@eval $expectation_operators) |
| 216 | + expectation_values = zeros(Complex128, n, m) |
| 217 | + p = ProgressMeter.Progress(n, 1, "Computation of expectation values with respect to evolved states in progress ... ", 50) |
| 218 | + i = 1 |
| 219 | + for (t, psi) in $(esc(qprop)) |
| 220 | + for j in 1:m |
| 221 | + expectation_values[i, j] = expectationvalue(psi, @eval $expectation_operators[m]) |
| 222 | + end |
| 223 | + i = i + 1 |
| 224 | + ProgressMeter.next!(p) |
| 225 | + end |
| 226 | + expectation_values |
| 227 | + end |
| 228 | +end |
| 229 | + |
| 230 | + |
180 | 231 | export QuStateEvolution,
|
181 | 232 | QuPropagator,
|
182 | 233 | QuEvolutionOp,
|
183 |
| - QuPropagatorState |
| 234 | + QuPropagatorState, |
| 235 | + @showprogress, |
| 236 | + @showprogress_trace, |
| 237 | + @showprogress_expectation |
0 commit comments