Overview
Configuration classes for controlling quantum simulation parameters, neural network backends, and physics settings.Classes
SimulatorConfig
Main configuration for quantum computer simulator. Location:quantum_computer.py
Constructor:
Grid and Network Architecture
-
grid_size (int): Spatial grid resolution for wavefunctions
- Default:
16 - Must match checkpoint training configuration
- Wavefunction shape:
(2, grid_size, grid_size) - Memory scales as
O(2^n × grid_size²)
- Default:
-
hidden_dim (int): Hidden layer dimension for neural networks
- Default:
32 - Must match checkpoint
- Used in Hamiltonian, Schrodinger, and Dirac networks
- Default:
-
expansion_dim (int): Expansion layer dimension
- Default:
64 - Used in Schrodinger and Dirac networks
- Larger values increase expressiveness but slow inference
- Default:
-
num_spectral_layers (int): Number of spectral convolution layers
- Default:
2 - Must match checkpoint
- More layers = more accurate but slower
- Default:
Dirac Physics
-
dirac_mass (float): Fermion rest mass
- Default:
1.0(atomic units) - Used in Dirac backend evolution
- Default:
-
dirac_c (float): Speed of light
- Default:
1.0(atomic units) - Physical value:
137.035999084(fine structure constant α⁻¹)
- Default:
-
gamma_representation (str): Dirac gamma matrix convention
- Default:
"dirac" - Options:
"dirac","weyl" - Affects spinor component mixing
- Default:
Evolution Parameters
-
dt (float): Time step for evolution operators
- Default:
0.01 - Smaller values = more accurate but slower
- Used in Hamiltonian backend:
ψ(t+dt) ≈ ψ(t) - i·dt·H·ψ(t)
- Default:
-
normalization_eps (float): Numerical stability epsilon
- Default:
1e-8 - Added to norm before division:
ψ / (||ψ|| + eps) - Prevents division by zero
- Default:
-
potential_depth (float): Eigenstate potential magnitude
- Default:
5.0 - Scales amplitude initialization potentials
- Default:
-
potential_width (float): Potential spatial width
- Default:
0.3 - Controls double-well and Coulomb potential shapes
- Default:
Checkpoint Paths
-
hamiltonian_checkpoint (str): Path to Hamiltonian network weights
- Default:
"weights/latest.pth" - Required for all backends (used as fallback)
- Default:
-
schrodinger_checkpoint (str): Path to Schrodinger network weights
- Default:
"weights/schrodinger_crystal_final.pth" - Optional: falls back to Hamiltonian if missing
- Default:
-
dirac_checkpoint (str): Path to Dirac network weights
- Default:
"weights/dirac_phase5_latest.pth" - Optional: uses analytical Dirac if missing
- Default:
Hardware
-
device (str): PyTorch device for computation
- Default:
"cuda"if available, else"cpu" - Options:
"cpu","cuda","cuda:0", etc.
- Default:
-
random_seed (int): Random number generator seed
- Default:
42 - Ensures reproducible eigenstate initialization
- Default:
-
max_qubits (int): Maximum number of qubits supported
- Default:
8 - Memory limit:
2^max_qubits × 2 × grid_size × grid_size × sizeof(float32) - Example: 8 qubits, 16×16 grid ≈ 512 MB
- Default:
FrameworkConfig
Extended configuration for molecular and visualization modules. Location:quantum_simulator.py
Constructor:
Fine Structure Physics
-
c_light (float): Speed of light in atomic units
- Default:
137.035999084 - Equal to
1/αwhere α is fine structure constant
- Default:
-
alpha_fs (float): Fine structure constant
- Default:
0.0072973525693(≈ 1/137) - Determines relativistic corrections
- Default:
-
hbar (float): Reduced Planck constant ℏ
- Default:
1.0(atomic units)
- Default:
-
electron_mass (float): Electron rest mass
- Default:
1.0(atomic units)
- Default:
Monte Carlo Sampling
-
mc_batch_size (int): Samples per batch in rejection sampling
- Default:
100000 - Larger = more efficient but more memory
- Default:
-
mc_max_particles (int): Maximum particles to accept
- Default:
2000000 - Hard limit on output size
- Default:
-
mc_min_particles (int): Minimum particles to attempt
- Default:
5000 - Lower bound on sampling
- Default:
-
r_max_factor (float): Radial cutoff scaling
- Default:
4.0 - Formula:
r_max = r_max_factor × n² + r_max_offset
- Default:
-
r_max_offset (float): Radial cutoff offset (Bohr radii)
- Default:
10.0
- Default:
-
prob_safety_factor (float): Rejection threshold multiplier
- Default:
1.05 - Ensures
P_threshold > P_maxfor stability
- Default:
Grid Search
-
grid_search_r (int): Radial grid points for P_max search
- Default:
300
- Default:
-
grid_search_theta (int): Polar angle grid points
- Default:
150
- Default:
-
grid_search_phi (int): Azimuthal angle grid points
- Default:
150
- Default:
Visualization
-
figure_dpi (int): Dots per inch for output images
- Default:
150 - Final resolution:
dpi × (size_x, size_y)pixels
- Default:
-
figure_size_x, figure_size_y (int): Figure dimensions in inches
- Default:
24 × 20 - Output:
3600 × 3000pixels at 150 DPI
- Default:
-
histogram_bins (int): Projection histogram resolution
- Default:
300
- Default:
-
scatter_size_min, scatter_size_max (float): 3D point size range
- Default:
1.0to8.0 - Size scales with probability density
- Default:
-
background_color (str): Figure background color
- Default:
"#000008"(dark blue)
- Default:
Output
-
output_dir (str): Directory for saved visualizations
- Default:
"download"
- Default:
-
default_num_samples (int): Default Monte Carlo particle count
- Default:
100000
- Default:
Advanced Physics
-
zbw_time_steps (int): Zitterbewegung simulation steps
- Default:
1000
- Default:
-
zbw_dt (float): Zitterbewegung time step
- Default:
0.001
- Default:
-
zbw_packet_width (float): Initial wave packet width
- Default:
0.1
- Default:
-
fine_structure_orders (int): Perturbation expansion orders
- Default:
4
- Default:
Configuration Validation
Checkpoint Compatibility
Network architecture parameters (grid_size, hidden_dim, expansion_dim, num_spectral_layers) must match the values used during checkpoint training. Mismatch causes:
Memory Requirements
Memory usage per state:| Qubits | Grid | Memory | Notes |
|---|---|---|---|
| 2 | 16 | 8 KB | Minimal |
| 4 | 16 | 128 KB | Typical |
| 6 | 16 | 2 MB | Manageable |
| 8 | 16 | 32 MB | Large (default max) |
| 10 | 16 | 512 MB | Very large |
| 8 | 32 | 128 MB | High resolution |
| 10 | 32 | 2 GB | Limit for 16 GB RAM |
Device Selection
Automatic GPU detection:Example Usage
Basic Configuration
High-Resolution Configuration
Molecular Simulation Configuration
Orbital Visualization Configuration
Notes
- All energy values are in atomic units (Hartree)
- All lengths are in Bohr radii (a₀)
- Checkpoints must be PyTorch
.pthfiles - Missing checkpoints trigger warnings but don’t stop initialization
- Random seed affects eigenstate initialization only, not quantum gates