@@ -253,6 +253,8 @@ def main():
253253 dt = float (sys .argv [3 ])
254254 if len (sys .argv ) > 4 :
255255 t1 = float (sys .argv [4 ])
256+ else :
257+ t1 = dt
256258 if len (sys .argv ) > 5 :
257259 shots = int (sys .argv [5 ])
258260 else :
@@ -289,24 +291,6 @@ def main():
289291
290292 # If we're using conventional simulation in the approximation model, collect samples over the depth series.
291293 experiment_probs = [{}] * (depth + 1 )
292- if t1 > 0 :
293- for trial in range (trials ):
294- experiment = QrackSimulator (n_qubits )
295- experiment .run_qiskit_circuit (qc )
296- for d in range (1 , depth + 1 ):
297- experiment .run_qiskit_circuit (step )
298-
299- counts = dict (Counter (experiment .measure_shots (qubits , shots )))
300-
301- for key , value in counts .items ():
302- experiment_probs [d ][key ] = (
303- experiment_probs [d ].get (key , 0 ) + value / shots
304- )
305-
306- for experiment in experiment_probs :
307- for key in experiment .keys ():
308- experiment [key ] /= trials
309-
310294 experiment = QrackSimulator (n_qubits )
311295 experiment .run_qiskit_circuit (qc )
312296 counts = dict (Counter (experiment .measure_shots (qubits , shots )))
@@ -340,15 +324,15 @@ def main():
340324 # Add up the square residuals:
341325 r_squared = result ["l2_difference" ] ** 2
342326
343- magnetization , sqr_magnetization = 0 , 0
327+ magnetization_0 , sqr_magnetization_0 = 0 , 0
344328 for key , value in experiment_probs [0 ].items ():
345329 m = 0
346330 for _ in range (n_qubits ):
347331 m += - 1 if (key & 1 ) else 1
348332 key >>= 1
349333 m /= n_qubits
350- magnetization += value * m
351- sqr_magnetization += value * m * m
334+ magnetization_0 += value * m
335+ sqr_magnetization_0 += value * m * m
352336
353337 c_magnetization , c_sqr_magnetization = 0 , 0
354338 for p in range (1 << n_qubits ):
@@ -363,7 +347,7 @@ def main():
363347
364348 # Save the sum of squares and sum of square residuals on the magnetization curve values.
365349 ss = c_sqr_magnetization ** 2
366- ssr = (c_sqr_magnetization - sqr_magnetization ) ** 2
350+ ssr = (c_sqr_magnetization - sqr_magnetization_0 ) ** 2
367351
368352 r_squared = 0
369353 ss = 0
@@ -455,26 +439,9 @@ def main():
455439 # Add up the square residuals:
456440 r_squared += result ["l2_difference" ] ** 2
457441
458- if model < 0.99 :
459- # Mix in the conventional simulation component.
460- magnetization , sqr_magnetization = 0 , 0
461- for key , value in experiment_probs [d ].items ():
462- m = 0
463- for _ in range (n_qubits ):
464- m += - 1 if (key & 1 ) else 1
465- key >>= 1
466- m /= n_qubits
467- magnetization += value * m
468- sqr_magnetization += value * m * m
469-
470- magnetization = model * d_magnetization + (1 - model ) * magnetization
471- sqr_magnetization = (
472- model * d_sqr_magnetization + (1 - model ) * sqr_magnetization
473- )
474- else :
475- # Rely entirely on the (n+1)-dimensional model.
476- magnetization = d_magnetization
477- sqr_magnetization = d_sqr_magnetization
442+ # Mix in the initial state component.
443+ magnetization = model * d_magnetization + (1 - model ) * magnetization_0
444+ sqr_magnetization = model * d_sqr_magnetization + (1 - model ) * sqr_magnetization_0
478445
479446 # Calculate the "control-case" magnetization values, from Aer's samples.
480447 c_magnetization , c_sqr_magnetization = 0 , 0
0 commit comments