scpn_fusion.diagnostics – Diagnostics

The diagnostics subpackage provides synthetic diagnostic instruments, forward models, and tomographic inversion for virtual tokamak experiments.

Synthetic Sensors

class scpn_fusion.diagnostics.synthetic_sensors.SensorSuite(kernel, *, seed=None, rng=None)[source]

Bases: object

Simulates physical diagnostics installed on the tokamak wall. 1. Magnetic Loops (Measure Flux Psi). 2. Bolometer Cameras (Measure Line-Integrated Radiation).

Parameters:
  • kernel (Any)

  • seed (Optional[int])

  • rng (Optional[np.random.Generator])

measure_magnetics()[source]

Returns Flux Psi at sensor locations. Interpolates from Kernel grid.

measure_b_field()[source]

Calculates local B_field (Br, Bz) at sensor locations using Biot-Savart. Harden with toroidal filament integration.

measure_bolometer(emission_profile)[source]

Integrates emission along chords. Signal = Integral( E(l) * dl )

measure_interferometer(density_profile_19)[source]

Simulates Multi-Chord Interferometer. Measures Phase Shift phi = lambda * r_e * Integral(n_e dl). Harden with Phase Wrapping (modulo 2pi) and Refraction noise.

measure_forward_channels(electron_density_m3, neutron_source_m3_s, *, detector_efficiency=0.12, solid_angle_fraction=0.0001, laser_wavelength_m=1.064e-06)[source]

Generate deterministic forward-model raw channels.

Return type:

ForwardDiagnosticChannels

visualize_setup()[source]

Forward Diagnostic Models

Forward-model diagnostics for raw-observable comparison lanes.

class scpn_fusion.diagnostics.forward.ForwardDiagnosticChannels(interferometer_phase_rad, neutron_count_rate_hz, thomson_scattering_voltage_v, ece_temperature_kev=None, sxr_brightness_w_m2=None, bolometer_power_w_m2_sr=None, cxrs_ti_kev=None, cxrs_rotation_km_s=None)[source]

Bases: object

Parameters:
interferometer_phase_rad: ndarray[Any, dtype[float64]]
neutron_count_rate_hz: float
thomson_scattering_voltage_v: ndarray[Any, dtype[float64]]
ece_temperature_kev: ndarray[Any, dtype[float64]] | None = None
sxr_brightness_w_m2: ndarray[Any, dtype[float64]] | None = None
bolometer_power_w_m2_sr: ndarray[Any, dtype[float64]] | None = None
cxrs_ti_kev: ndarray[Any, dtype[float64]] | None = None
cxrs_rotation_km_s: ndarray[Any, dtype[float64]] | None = None
scpn_fusion.diagnostics.forward.interferometer_phase_shift(electron_density_m3, r_grid, z_grid, chords, *, laser_wavelength_m=1.064e-06, samples=96, enforce_domain_bounds=False)[source]

Predict line-integrated interferometer phase shift [rad].

Return type:

ndarray[Any, dtype[float64]]

Parameters:
scpn_fusion.diagnostics.forward.neutron_count_rate(neutron_source_m3_s, *, volume_element_m3, detector_efficiency=0.12, solid_angle_fraction=0.0001)[source]

Predict detector neutron count rate [Hz] from volumetric source.

Return type:

float

Parameters:
scpn_fusion.diagnostics.forward.thomson_scattering_voltage(electron_density_m3, electron_temp_keV, r_grid, z_grid, sample_points, *, gain_v_per_m3=2.5e-24, temp_sensitivity_per_kev=0.08, baseline_voltage_v=0.0, enforce_domain_bounds=False)[source]

Predict Thomson-scattering detector voltage [V] at sample points.

Return type:

ndarray[Any, dtype[float64]]

Parameters:
scpn_fusion.diagnostics.forward.generate_forward_channels(*, electron_density_m3, neutron_source_m3_s, r_grid, z_grid, interferometer_chords, volume_element_m3, detector_efficiency=0.12, solid_angle_fraction=0.0001, laser_wavelength_m=1.064e-06, enforce_chord_domain_bounds=False, electron_temp_keV=None, thomson_sample_points=None, thomson_gain_v_per_m3=2.5e-24, thomson_temp_sensitivity_per_kev=0.08, thomson_baseline_voltage_v=0.0, enforce_thomson_domain_bounds=False)[source]

Generate synthetic raw diagnostic channels from plasma state maps.

Return type:

ForwardDiagnosticChannels

Parameters:
scpn_fusion.diagnostics.forward.ece_radiometer_temperature(electron_temp_keV, r_grid, z_grid, channel_r_positions, *, z_observation=0.0, optical_depth_factor=1.0)[source]

Predict ECE radiometer Te [keV] at specified R channel positions.

Assumes optically thick plasma: signal = Te(R_ch, z_obs) * optical_depth_factor.

Return type:

ndarray[Any, dtype[float64]]

Parameters:
scpn_fusion.diagnostics.forward.soft_xray_brightness(electron_density_m3, electron_temp_keV, r_grid, z_grid, chords, *, z_eff=1.5, filter_energy_kev=1.0, samples=96, enforce_domain_bounds=False)[source]

Predict soft X-ray line-integrated brightness [W/m^2].

Emissivity model: epsilon = ne^2 * sqrt(Te) * Z_eff * exp(-E_filter / Te).

Return type:

ndarray[Any, dtype[float64]]

Parameters:
scpn_fusion.diagnostics.forward.bolometer_power_density(electron_density_m3, electron_temp_keV, r_grid, z_grid, chords, *, z_eff=1.5, impurity_fraction=0.02, samples=96, enforce_domain_bounds=False)[source]

Predict bolometer line-integrated radiated power [W/m^2/sr].

Radiation model: P_rad = ne^2 * L_z(Te) where L_z = C_rad * Z_eff^2 * sqrt(Te). C_rad ~ 1e-31 W m^3 (coronal equilibrium approximation).

Return type:

ndarray[Any, dtype[float64]]

Parameters:
scpn_fusion.diagnostics.forward.cxrs_ion_diagnostics(ion_temp_keV, rotation_km_s, r_grid, z_grid, chords, *, beam_r_center=6.2, beam_width=0.1, samples=96)[source]

Predict CXRS ion temperature and toroidal rotation.

Weights signals by a Gaussian beam-emission profile centered at beam_r_center.

Return type:

tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

Parameters:

Tomographic Inversion

class scpn_fusion.diagnostics.tomography.PlasmaTomography(sensors, grid_res=20, *, lambda_reg=0.1, verbose=True)[source]

Bases: object

Reconstruct 2D emissivity profile from line-integrated chord signals.

Parameters:
  • sensors (Any)

  • grid_res (int)

  • lambda_reg (float)

  • verbose (bool)

reconstruct(signals, method='auto')[source]

Solve inversion problem Ax=b with regularization. Supports ‘lsq_linear’ (SciPy), ‘ridge’ (Phillips-Twomey), and ‘sart’ (Iterative).

Return type:

ndarray

Parameters:
plot_reconstruction(ground_truth, reconstruction)[source]
Parameters:

Diagnostic Runner

scpn_fusion.diagnostics.run_diagnostics.run_diag_demo(config_path=PosixPath('/home/runner/work/scpn-fusion-core/scpn-fusion-core/validation/iter_validated_config.json'), output_dir=PosixPath('/home/runner/work/scpn-fusion-core/scpn-fusion-core/artifacts/diagnostics_demo'), *, seed=42, save_figures=True, verbose=True, kernel_factory=<class 'scpn_fusion.core.fusion_kernel.FusionKernel'>, sensor_factory=<class 'scpn_fusion.diagnostics.synthetic_sensors.SensorSuite'>, tomography_factory=<class 'scpn_fusion.diagnostics.tomography.PlasmaTomography'>)[source]

Run synthetic diagnostics + tomography and return deterministic summary.

Return type:

Dict[str, Any]

Parameters: