harishaseebat92 commited on
Commit
b0f5437
·
1 Parent(s): 0863742

Turbo Colorscale, EM : IONQ QPU Integration

Browse files
em/excitation.py CHANGED
@@ -502,7 +502,7 @@ def update_initial_state_preview():
502
  plotter.add_mesh(
503
  mesh,
504
  scalars='scalars',
505
- cmap="Blues",
506
  show_scalar_bar=False,
507
  show_edges=show_grid_edges,
508
  edge_color='grey',
 
502
  plotter.add_mesh(
503
  mesh,
504
  scalars='scalars',
505
+ cmap=EXCITATION_SURFACE_COLORSCALE,
506
  show_scalar_bar=False,
507
  show_edges=show_grid_edges,
508
  edge_color='grey',
em/globals.py CHANGED
@@ -30,16 +30,10 @@ __all__ = [
30
  ]
31
 
32
  # --- Constants ---
33
- GRID_SIZES = ["16", "32", "64", "128", "256", "512"]
34
  DEFAULT_AXIS_TICKS = (0.0, 0.25, 0.5, 0.75, 1.0)
35
 
36
- EXCITATION_SURFACE_COLORSCALE = [
37
- [0.0, "#001219"],
38
- [0.25, "#005F73"],
39
- [0.5, "#94D2BD"],
40
- [0.75, "#EE9B00"],
41
- [1.0, "#CA6702"],
42
- ]
43
 
44
  # --- PyVista and Simulation Data ---
45
  plotter = pv.Plotter()
 
30
  ]
31
 
32
  # --- Constants ---
33
+ GRID_SIZES = [8, 16, 32, 64, 128, 256, 512]
34
  DEFAULT_AXIS_TICKS = (0.0, 0.25, 0.5, 0.75, 1.0)
35
 
36
+ EXCITATION_SURFACE_COLORSCALE = "Turbo"
 
 
 
 
 
 
37
 
38
  # --- PyVista and Simulation Data ---
39
  plotter = pv.Plotter()
em/simulation.py CHANGED
@@ -9,8 +9,16 @@ import numpy as np
9
 
10
  from .state import state, ctrl, _apply_workflow_highlights, is_statevector_estimator_selected, is_ibm_qpu_selected
11
  from .globals import (
12
- plotter, simulation_data, current_mesh, snapshot_times,
13
- stop_simulation, qpu_ts_cache, sim_ts_cache, set_stop_simulation, reset_globals
 
 
 
 
 
 
 
 
14
  )
15
 
16
  # Import backend functions
@@ -126,10 +134,9 @@ def setup_surface_plot_data(sim_data, nx):
126
  g.X_grids['Hy'], g.Y_grids['Hy'] = np.meshgrid(x_m1, y)
127
 
128
  # Compute z_scale for visualization
129
- # finite_vals = [abs(float(v)) for pair in g.surface_clims.values() for v in pair if np.isfinite(v)]
130
- # max_abs = max(finite_vals) if finite_vals else 1e-9
131
- # g.z_scale = (nx / 2) / max(max_abs, 1e-9)
132
- g.z_scale = 1.0
133
 
134
  g.simulation_data = sim_data
135
 
@@ -209,7 +216,7 @@ def redraw_surface_plot():
209
  mesh,
210
  scalars='scalars',
211
  # clim=g.surface_clims[field],
212
- cmap="Blues",
213
  show_scalar_bar=False,
214
  show_edges=True,
215
  edge_color='grey',
@@ -490,7 +497,7 @@ def run_simulation_only():
490
  impulse_pos=impulse_pos,
491
  shots=10000,
492
  pm_optimization_level=2,
493
- simulation="True",
494
  optimization="True",
495
  platform="IBM",
496
  progress_callback=_ibm_progress_callback,
 
9
 
10
  from .state import state, ctrl, _apply_workflow_highlights, is_statevector_estimator_selected, is_ibm_qpu_selected
11
  from .globals import (
12
+ plotter,
13
+ simulation_data,
14
+ current_mesh,
15
+ snapshot_times,
16
+ stop_simulation,
17
+ qpu_ts_cache,
18
+ sim_ts_cache,
19
+ set_stop_simulation,
20
+ reset_globals,
21
+ EXCITATION_SURFACE_COLORSCALE,
22
  )
23
 
24
  # Import backend functions
 
134
  g.X_grids['Hy'], g.Y_grids['Hy'] = np.meshgrid(x_m1, y)
135
 
136
  # Compute z_scale for visualization
137
+ finite_vals = [abs(float(v)) for pair in g.surface_clims.values() for v in pair if np.isfinite(v)]
138
+ max_abs = max(finite_vals) if finite_vals else 1e-9
139
+ g.z_scale = (nx / 2) / max(max_abs, 1e-9)
 
140
 
141
  g.simulation_data = sim_data
142
 
 
216
  mesh,
217
  scalars='scalars',
218
  # clim=g.surface_clims[field],
219
+ cmap=EXCITATION_SURFACE_COLORSCALE,
220
  show_scalar_bar=False,
221
  show_edges=True,
222
  edge_color='grey',
 
497
  impulse_pos=impulse_pos,
498
  shots=10000,
499
  pm_optimization_level=2,
500
+ simulation="False",
501
  optimization="True",
502
  platform="IBM",
503
  progress_callback=_ibm_progress_callback,
em/state.py CHANGED
@@ -6,6 +6,8 @@ These allow using state.update(), @state.change(), and ctrl.xxx at module
6
  load time, then applying them when set_server() is called.
7
  """
8
 
 
 
9
  __all__ = [
10
  "state", "ctrl", "set_server", "init_state",
11
  "enable_point_picking_on_plotter",
@@ -234,6 +236,7 @@ def _init_state_defaults():
234
  "stop_button_disabled": True,
235
  "export_format": "vtk",
236
  "nx_slider_index": None,
 
237
  "show_export_status": False,
238
  "export_status_message": "",
239
  "logo_src": None,
 
6
  load time, then applying them when set_server() is called.
7
  """
8
 
9
+ from .globals import GRID_SIZES
10
+
11
  __all__ = [
12
  "state", "ctrl", "set_server", "init_state",
13
  "enable_point_picking_on_plotter",
 
236
  "stop_button_disabled": True,
237
  "export_format": "vtk",
238
  "nx_slider_index": None,
239
+ "grid_size_labels": [int(val) for val in GRID_SIZES],
240
  "show_export_status": False,
241
  "export_status_message": "",
242
  "logo_src": None,
em/ui.py CHANGED
@@ -8,7 +8,7 @@ from trame.widgets import html as trame_html, vuetify3, plotly as plotly_widgets
8
  from pyvista.trame.ui import plotter_ui
9
 
10
  from .state import state, ctrl, get_server
11
- from .globals import plotter
12
  from .geometry import build_geometry_placeholder as _build_geometry_placeholder
13
  from .excitation import build_excitation_placeholder as _build_excitation_placeholder
14
  from .simulation import run_simulation_only, reset_to_defaults, stop_simulation_handler
@@ -346,14 +346,17 @@ def _build_meshing_card():
346
  v_model=("nx_slider_index", None),
347
  label="No. of points per direction:",
348
  min=0,
349
- max=5,
350
  step=1,
351
  show_ticks="always",
352
  thumb_label="always",
353
  density="compact",
354
  color="primary",
355
  ):
356
- vuetify3.Template(v_slot_thumb_label="{ modelValue }", children=["{{ modelValue === null ? 'Select' : [8, 16, 32, 64, 128, 256, 512][modelValue] }}"])
 
 
 
357
  # Hover content: enlarged Plotly graph
358
  with vuetify3.VSheet(classes="pa-2", elevation=6, rounded=True, style="width: 644px;"):
359
  qubit_fig_widget = plotly_widgets.Figure(
 
8
  from pyvista.trame.ui import plotter_ui
9
 
10
  from .state import state, ctrl, get_server
11
+ from .globals import plotter, GRID_SIZES
12
  from .geometry import build_geometry_placeholder as _build_geometry_placeholder
13
  from .excitation import build_excitation_placeholder as _build_excitation_placeholder
14
  from .simulation import run_simulation_only, reset_to_defaults, stop_simulation_handler
 
346
  v_model=("nx_slider_index", None),
347
  label="No. of points per direction:",
348
  min=0,
349
+ max=len(GRID_SIZES) - 1,
350
  step=1,
351
  show_ticks="always",
352
  thumb_label="always",
353
  density="compact",
354
  color="primary",
355
  ):
356
+ vuetify3.Template(
357
+ v_slot_thumb_label="{ modelValue }",
358
+ children=["{{ modelValue === null ? 'Select' : grid_size_labels[modelValue] }}"],
359
+ )
360
  # Hover content: enlarged Plotly graph
361
  with vuetify3.VSheet(classes="pa-2", elevation=6, rounded=True, style="width: 644px;"):
362
  qubit_fig_widget = plotly_widgets.Figure(
qlbm/qlbm_sample_app.py CHANGED
@@ -12,6 +12,8 @@ import plotly.graph_objects as go
12
 
13
  dim=3
14
 
 
 
15
 
16
  def bin_to_gray(bin_s):
17
  XOR=lambda x,y: (x or y) and not (x and y)
@@ -869,7 +871,7 @@ def _create_slider_figure(output_list, T_list, X):
869
  opacity=0.4,
870
  surface_count=10,
871
  caps=dict(x_show=False, y_show=False, z_show=False),
872
- colorscale='Blues',
873
  colorbar=dict(title="Density"),
874
  visible=visible,
875
  name=f"T={T}"
@@ -1043,7 +1045,7 @@ def show_initial_distribution(
1043
  opacity=0.4,
1044
  surface_count=10,
1045
  caps=dict(x_show=False, y_show=False, z_show=False),
1046
- colorscale='Blues',
1047
  ))
1048
 
1049
  fig.update_layout(
 
12
 
13
  dim=3
14
 
15
+ QLBM_PLOT_COLORSCALE = "Turbo"
16
+
17
 
18
  def bin_to_gray(bin_s):
19
  XOR=lambda x,y: (x or y) and not (x and y)
 
871
  opacity=0.4,
872
  surface_count=10,
873
  caps=dict(x_show=False, y_show=False, z_show=False),
874
+ colorscale=QLBM_PLOT_COLORSCALE,
875
  colorbar=dict(title="Density"),
876
  visible=visible,
877
  name=f"T={T}"
 
1045
  opacity=0.4,
1046
  surface_count=10,
1047
  caps=dict(x_show=False, y_show=False, z_show=False),
1048
+ colorscale=QLBM_PLOT_COLORSCALE,
1049
  ))
1050
 
1051
  fig.update_layout(
qlbm/visualize_counts.py CHANGED
@@ -234,7 +234,7 @@ def plot_density_isosurface_slider(outputs, T_list=None):
234
  opacity=0.4,
235
  surface_count=10,
236
  caps=dict(x_show=False, y_show=False, z_show=False),
237
- colorscale='Blues',
238
  colorbar=dict(title="Density"),
239
  visible=visible,
240
  name=f"T={T_list[i]}"
 
234
  opacity=0.4,
235
  surface_count=10,
236
  caps=dict(x_show=False, y_show=False, z_show=False),
237
+ colorscale='Turbo',
238
  colorbar=dict(title="Density"),
239
  visible=visible,
240
  name=f"T={T_list[i]}"
qlbm_embedded.py CHANGED
@@ -100,6 +100,8 @@ _PROBLEM_GEOMETRY_MAP = {
100
  "Laminar flow & heat transfer for a heated body in water.": "Rectangular domain with a heated box (3D)",
101
  }
102
 
 
 
103
 
104
  def set_server(server):
105
  """Set the server for embedded mode."""
@@ -488,7 +490,7 @@ def get_initial_distribution_figure(distribution_type, N, show_edges=False):
488
  isomin=isomin,
489
  isomax=isomax,
490
  surface_count=surface_count,
491
- colorscale='Blues',
492
  opacity=0.35,
493
  caps=dict(x_show=False, y_show=False, z_show=False)
494
  )]
@@ -717,7 +719,8 @@ def _create_box_figure(lx, ly, lz, title):
717
  j=[3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
718
  k=[0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
719
  opacity=0.2,
720
- color="rgba(255,218,185,0.25)",
 
721
  flatshading=True,
722
  name=title,
723
  showscale=False
 
100
  "Laminar flow & heat transfer for a heated body in water.": "Rectangular domain with a heated box (3D)",
101
  }
102
 
103
+ _QLBM_PREVIEW_COLORSCALE = "Turbo"
104
+
105
 
106
  def set_server(server):
107
  """Set the server for embedded mode."""
 
490
  isomin=isomin,
491
  isomax=isomax,
492
  surface_count=surface_count,
493
+ colorscale=_QLBM_PREVIEW_COLORSCALE,
494
  opacity=0.35,
495
  caps=dict(x_show=False, y_show=False, z_show=False)
496
  )]
 
719
  j=[3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
720
  k=[0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
721
  opacity=0.2,
722
+ intensity=list(range(len(x))),
723
+ colorscale=_QLBM_PREVIEW_COLORSCALE,
724
  flatshading=True,
725
  name=title,
726
  showscale=False