use crate::models::GridPointParams; use std::path::PathBuf; #[derive(Debug, Clone)] pub struct SeedMatch { pub name: String, pub path: PathBuf, pub distance: f64, } pub const MAX_GLOBAL_SEED_DISTANCE: f64 = 3.0; pub fn calculate_seed_distance(cand: &GridPointParams, target: &GridPointParams) -> (bool, f64) { let d_teff = (cand.teff - target.teff).abs(); let d_logg = (cand.logg - target.logg).abs(); let d_loghe = (cand.loghe - target.loghe).abs(); let d_cno = (cand.logc - target.logc).abs() + (cand.logn - target.logn).abs() + (cand.logo - target.logo).abs(); // exact family 判定:Teff/logg/logHe 视为“同物理族”,仅 CNO 丰度不同。 // Teff 容忍度取半步 5000K:实际网格 Teff 档位通常为整数千(20000/30000/.../60000), // 半步既能覆盖 config_dense 等 10000K 步长的相邻档互作种子, // 又避免跨过大 Teff 间距导致 sdB 高温模型用低温种子而不收敛(sdB_cno 步长 40000K 仍不命中 exact)。 if d_teff < 5000.0 && d_logg < 0.01 && d_loghe < 0.01 { (true, d_cno) } else { // 距离公式物理意义与标定阐释: // 在恒星非局部热力学平衡(NLTE)辐射流体力学与光谱大气计算中,不同物理自由度对于迭代收敛过程的基本影响层级截然相反: // 1. Teff (有效温度) 通常达数千至数十万 K,主导连续谱黑体势函数与强激发电离步阶,故除以 5000.0 归一化为基底主控距离量; // 2. logg (表面重力加速度) 对静力学与辐射光致压差梯度的平衡破坏力极烈,压强差稍高会触发极大激波不平衡,因此乘上 2.0 予以最高维权惩罚; // 3. loghe (氦丰度) 对自由电子密度与热库贡献次于 H-He 电离梯度,乘 0.5 作为次要控制项; // 4. CNO 金属元素虽然影响紫外谱线辐射驱动但整体状态基本可作次优微扰微增系数看待,乘 0.1; // 通过上述尺度正态映射可挑选得到高收敛继承性的初态迭代种子模型。 let global_d = (d_teff / 5000.0) + (d_logg * 2.0) + (d_loghe * 0.5) + (d_cno * 0.1); (false, global_d) } }