harishaseebat92 commited on
Commit
4bd4398
·
1 Parent(s): 841a0ef

QLBM IBM Qiskit Simulator: This wrapper maps the simulation loop's 0-100% progress to the overall task

Browse files
Files changed (2) hide show
  1. qlbm/qlbm_sample_app.py +9 -1
  2. qlbm_embedded.py +8 -0
qlbm/qlbm_sample_app.py CHANGED
@@ -718,6 +718,7 @@ def run_sampling_sim(
718
  init_state_prep_circ,
719
  T_list,
720
  vel_resolution=32,
 
721
  ):
722
  """
723
  Run QLBM simulation on local Aer statevector simulator.
@@ -734,6 +735,8 @@ def run_sampling_sim(
734
  List of timesteps to simulate
735
  vel_resolution : int
736
  Resolution for velocity field discretization
 
 
737
 
738
  Returns
739
  -------
@@ -767,7 +770,12 @@ def run_sampling_sim(
767
  backend = AerSimulator(method = 'statevector')
768
  output=[]
769
 
770
- for qc in qc_list:
 
 
 
 
 
771
  qc_transpiled=qc
772
  qc_transpiled.save_statevector(conditional=True)
773
 
 
718
  init_state_prep_circ,
719
  T_list,
720
  vel_resolution=32,
721
+ progress_callback=None,
722
  ):
723
  """
724
  Run QLBM simulation on local Aer statevector simulator.
 
735
  List of timesteps to simulate
736
  vel_resolution : int
737
  Resolution for velocity field discretization
738
+ progress_callback : callable, optional
739
+ Function to report progress (0-100)
740
 
741
  Returns
742
  -------
 
770
  backend = AerSimulator(method = 'statevector')
771
  output=[]
772
 
773
+ total_steps = len(qc_list)
774
+ for i, qc in enumerate(qc_list):
775
+ if progress_callback:
776
+ percent = int((i / total_steps) * 100)
777
+ progress_callback(percent)
778
+
779
  qc_transpiled=qc
780
  qc_transpiled.save_statevector(conditional=True)
781
 
qlbm_embedded.py CHANGED
@@ -1153,6 +1153,13 @@ def _run_qiskit_simulation(progress_callback=None):
1153
  # Determine velocity resolution (cap for performance)
1154
  vel_resolution = min(params['grid_size'], 32)
1155
 
 
 
 
 
 
 
 
1156
  # Run simulation using qlbm_sample_app function
1157
  output, fig = run_sampling_sim(
1158
  n=params["n"],
@@ -1162,6 +1169,7 @@ def _run_qiskit_simulation(progress_callback=None):
1162
  init_state_prep_circ=init_state_prep_circ,
1163
  T_list=params["T_list"],
1164
  vel_resolution=vel_resolution,
 
1165
  )
1166
 
1167
  if progress_callback:
 
1153
  # Determine velocity resolution (cap for performance)
1154
  vel_resolution = min(params['grid_size'], 32)
1155
 
1156
+ # Define a progress wrapper to map 0-100% simulation progress to 15-95% overall progress
1157
+ def sim_progress_wrapper(p):
1158
+ if progress_callback:
1159
+ # Map 0-100 -> 15-95
1160
+ weighted_p = 15 + (p / 100.0) * (95 - 15)
1161
+ progress_callback(weighted_p)
1162
+
1163
  # Run simulation using qlbm_sample_app function
1164
  output, fig = run_sampling_sim(
1165
  n=params["n"],
 
1169
  init_state_prep_circ=init_state_prep_circ,
1170
  T_list=params["T_list"],
1171
  vel_resolution=vel_resolution,
1172
+ progress_callback=sim_progress_wrapper,
1173
  )
1174
 
1175
  if progress_callback: