quantrs2_circuit/scirs2_pulse_control_enhanced/
config.rs

1//! Configuration types for enhanced pulse control
2
3use super::pulses::PulseLibrary;
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7/// Enhanced pulse control configuration
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct EnhancedPulseConfig {
10    /// Base pulse control configuration
11    pub base_config: PulseControlConfig,
12    /// Enable ML-based pulse optimization
13    pub enable_ml_optimization: bool,
14    /// Enable real-time calibration
15    pub enable_realtime_calibration: bool,
16    /// Enable advanced waveform synthesis
17    pub enable_advanced_synthesis: bool,
18    /// Enable comprehensive error mitigation
19    pub enable_error_mitigation: bool,
20    /// Enable adaptive control
21    pub enable_adaptive_control: bool,
22    /// Enable visual pulse representation
23    pub enable_visual_output: bool,
24    /// Optimization objectives
25    pub optimization_objectives: Vec<PulseOptimizationObjective>,
26    /// Performance constraints
27    pub performance_constraints: PulseConstraints,
28    /// Signal processing options
29    pub signal_processing: SignalProcessingConfig,
30    /// Export formats
31    pub export_formats: Vec<PulseExportFormat>,
32}
33
34impl Default for EnhancedPulseConfig {
35    fn default() -> Self {
36        Self {
37            base_config: PulseControlConfig::default(),
38            enable_ml_optimization: true,
39            enable_realtime_calibration: true,
40            enable_advanced_synthesis: true,
41            enable_error_mitigation: true,
42            enable_adaptive_control: true,
43            enable_visual_output: true,
44            optimization_objectives: vec![
45                PulseOptimizationObjective::MinimizeInfidelity,
46                PulseOptimizationObjective::MinimizeDuration,
47                PulseOptimizationObjective::MinimizePower,
48            ],
49            performance_constraints: PulseConstraints::default(),
50            signal_processing: SignalProcessingConfig::default(),
51            export_formats: vec![
52                PulseExportFormat::OpenPulse,
53                PulseExportFormat::Qiskit,
54                PulseExportFormat::Custom,
55            ],
56        }
57    }
58}
59
60/// Base pulse control configuration
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct PulseControlConfig {
63    /// Sample rate in Hz
64    pub sample_rate: f64,
65    /// Maximum pulse amplitude
66    pub max_amplitude: f64,
67    /// Minimum pulse duration in seconds
68    pub min_duration: f64,
69    /// Maximum pulse duration in seconds
70    pub max_duration: f64,
71    /// Hardware constraints
72    pub hardware_constraints: HardwareConstraints,
73    /// Default pulse shapes
74    pub pulse_library: PulseLibrary,
75}
76
77impl Default for PulseControlConfig {
78    fn default() -> Self {
79        Self {
80            sample_rate: 1e9,
81            max_amplitude: 1.0,
82            min_duration: 1e-9,
83            max_duration: 1e-6,
84            hardware_constraints: HardwareConstraints::default(),
85            pulse_library: PulseLibrary::default(),
86        }
87    }
88}
89
90/// Hardware constraints for pulse control
91#[derive(Debug, Clone, Serialize, Deserialize)]
92pub struct HardwareConstraints {
93    /// AWG specifications
94    pub awg_specs: AWGSpecifications,
95    /// IQ mixer specifications
96    pub iq_mixer_specs: IQMixerSpecifications,
97    /// Control electronics bandwidth
98    pub bandwidth: f64,
99    /// Rise/fall time constraints
100    pub rise_time: f64,
101    /// Phase noise specifications
102    pub phase_noise: PhaseNoiseSpec,
103    /// Amplitude noise specifications
104    pub amplitude_noise: AmplitudeNoiseSpec,
105}
106
107impl Default for HardwareConstraints {
108    fn default() -> Self {
109        Self {
110            awg_specs: AWGSpecifications::default(),
111            iq_mixer_specs: IQMixerSpecifications::default(),
112            bandwidth: 500e6,
113            rise_time: 2e-9,
114            phase_noise: PhaseNoiseSpec::default(),
115            amplitude_noise: AmplitudeNoiseSpec::default(),
116        }
117    }
118}
119
120/// AWG specifications
121#[derive(Debug, Clone, Serialize, Deserialize)]
122pub struct AWGSpecifications {
123    pub resolution_bits: u8,
124    pub max_sample_rate: f64,
125    pub memory_depth: usize,
126    pub channels: usize,
127    pub voltage_range: (f64, f64),
128}
129
130impl Default for AWGSpecifications {
131    fn default() -> Self {
132        Self {
133            resolution_bits: 16,
134            max_sample_rate: 2.5e9,
135            memory_depth: 16_000_000,
136            channels: 4,
137            voltage_range: (-1.0, 1.0),
138        }
139    }
140}
141
142/// IQ mixer specifications
143#[derive(Debug, Clone, Serialize, Deserialize)]
144pub struct IQMixerSpecifications {
145    pub lo_frequency_range: (f64, f64),
146    pub if_bandwidth: f64,
147    pub isolation: f64,
148    pub conversion_loss: f64,
149}
150
151impl Default for IQMixerSpecifications {
152    fn default() -> Self {
153        Self {
154            lo_frequency_range: (1e9, 20e9),
155            if_bandwidth: 1e9,
156            isolation: 40.0,
157            conversion_loss: 6.0,
158        }
159    }
160}
161
162/// Phase noise specifications
163#[derive(Debug, Clone, Serialize, Deserialize)]
164pub struct PhaseNoiseSpec {
165    pub offset_frequencies: Vec<f64>,
166    pub noise_levels: Vec<f64>,
167}
168
169impl Default for PhaseNoiseSpec {
170    fn default() -> Self {
171        Self {
172            offset_frequencies: vec![10.0, 100.0, 1e3, 10e3, 100e3, 1e6],
173            noise_levels: vec![-80.0, -100.0, -110.0, -120.0, -130.0, -140.0],
174        }
175    }
176}
177
178/// Amplitude noise specifications
179#[derive(Debug, Clone, Serialize, Deserialize)]
180pub struct AmplitudeNoiseSpec {
181    pub rms_noise: f64,
182    pub peak_to_peak_noise: f64,
183    pub spectral_density: f64,
184}
185
186impl Default for AmplitudeNoiseSpec {
187    fn default() -> Self {
188        Self {
189            rms_noise: 1e-6,
190            peak_to_peak_noise: 6e-6,
191            spectral_density: 1e-9,
192        }
193    }
194}
195
196/// Pulse optimization objectives
197#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
198pub enum PulseOptimizationObjective {
199    MinimizeInfidelity,
200    MinimizeDuration,
201    MinimizePower,
202    MinimizeLeakage,
203    MaximizeRobustness,
204    MinimizeCrosstalk,
205}
206
207/// Pulse constraints
208#[derive(Debug, Clone, Serialize, Deserialize)]
209pub struct PulseConstraints {
210    pub max_amplitude: Option<f64>,
211    pub max_slew_rate: Option<f64>,
212    pub max_frequency: Option<f64>,
213    pub min_fidelity: Option<f64>,
214    pub max_leakage: Option<f64>,
215}
216
217impl Default for PulseConstraints {
218    fn default() -> Self {
219        Self {
220            max_amplitude: Some(1.0),
221            max_slew_rate: Some(1e12),
222            max_frequency: Some(500e6),
223            min_fidelity: Some(0.999),
224            max_leakage: Some(0.001),
225        }
226    }
227}
228
229/// Signal processing configuration
230#[derive(Debug, Clone, Serialize, Deserialize)]
231pub struct SignalProcessingConfig {
232    pub filter_type: FilterType,
233    pub windowing: WindowType,
234    pub oversampling_factor: usize,
235    pub enable_predistortion: bool,
236    pub enable_feedback: bool,
237}
238
239impl Default for SignalProcessingConfig {
240    fn default() -> Self {
241        Self {
242            filter_type: FilterType::Butterworth(4),
243            windowing: WindowType::Hamming,
244            oversampling_factor: 4,
245            enable_predistortion: true,
246            enable_feedback: true,
247        }
248    }
249}
250
251/// Filter types for signal processing
252#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
253pub enum FilterType {
254    Butterworth(usize),
255    Chebyshev(usize),
256    Bessel(usize),
257    FIR(usize),
258}
259
260/// Window types for spectral analysis
261#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
262pub enum WindowType {
263    Rectangular,
264    Hamming,
265    Hanning,
266    Blackman,
267    Kaiser(u32),
268}
269
270/// Pulse export formats
271#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
272pub enum PulseExportFormat {
273    OpenPulse,
274    Qiskit,
275    Custom,
276}