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