63 lines
2.1 KiB
C++
63 lines
2.1 KiB
C++
//
|
|
// Created by Administrator on 2026/1/12.
|
|
//
|
|
|
|
#ifndef COMPUTER_H
|
|
#define COMPUTER_H
|
|
|
|
#include <QVector>
|
|
#include <QString>
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
#include <vector>
|
|
|
|
class Computer {
|
|
public:
|
|
Computer();
|
|
~Computer();
|
|
|
|
struct SpectralLine {
|
|
double wavelength_nm; // λ (nm)
|
|
double intensity; // 积分强度
|
|
double A; // Einstein A (s^-1) 跃迁几率 ($A_{ki}$)
|
|
double g; // 统计权重 $$g_k = 2J + 1 = 2 \times (1.5) + 1 = 4$$
|
|
double E; // 上能级 (eV) $$E_k(eV) = \frac{32,435.453}{8065.54} \approx 4.021 \text{ eV}$$
|
|
};
|
|
|
|
struct PlasmaParams {
|
|
double Te; // K
|
|
double ne; // cm^-3
|
|
double ionRate; // 电离度
|
|
double Ntot; // 总粒子数密度 cm^-3
|
|
};
|
|
|
|
struct Spectrum {
|
|
QVector<double> wavelength;
|
|
QVector<double> intensity; // 已合并(如均值/中值)
|
|
};
|
|
// 读取 CSV 格式谱线数据
|
|
Spectrum readSpectrumCSV(const QString& filename);
|
|
// 计算电子温度
|
|
double computeElectronTemperature(const QVector<SpectralLine>& lines);
|
|
// 计算电子密度
|
|
double computeElectronDensity(double fwhm_nm, double w);
|
|
// 计算电离度
|
|
double computeIonizationRate(double Te, double ne);
|
|
// 计算粒子总数
|
|
double computeTotalParticleDensity(double ne, double ionRate);
|
|
// 计算等离子参数
|
|
PlasmaParams computePlasmaParams(const QVector<SpectralLine>& lines, double fwhm_nm, double stark_w);
|
|
// 线性背景拟合
|
|
void fitLinearBackground(const QVector<double>& x, const QVector<double>& y, double& a, double& b);
|
|
// 计算强度积分:梯形面积
|
|
double integratePeak(const Spectrum& spec, double peak_nm, double half_window_nm = 0.25);
|
|
// 查找指定谱线 FWHM
|
|
double computeFWHMForPeak(const QVector<double>& wavelengths, const QVector<double>& intensities, double lambda_target, double window = 0.5);
|
|
// 计算参数接口
|
|
PlasmaParams computeInter(QString filePath);
|
|
|
|
};
|
|
|
|
|
|
#endif //COMPUTER_H
|