DCTS/crates/common/src/nst_writer.rs
Asfmq b91f1e4fa5 feat(server,dashboard): 引入多工作流数据隔离、安全中间件与前端 ESM 模块化重构
- server: 实现按 workflow_name 的多工作流数据隔离与旧数据库平滑迁移机制
- server: 新增 API Key 认证(auth)、限流中间件(rate_limit)与运维备份接口(admin)
- server: 统一 AppError 错误处理体系,重构调度器 scheduler 支持工作流级重置与抢占
- node: 节点 ID 缺失时自动生成随机 UUID,原生支持 `docker compose --scale node=N` 动态扩容
- dashboard: 前端模块化重构(state/api/components),升级 CSS 变量设计系统与 Toast 通知
- docker/docs: 更新 /healthz 健康检查、部署脚本 IP 配置及数据库设计文档
2026-07-28 21:54:02 +08:00

66 lines
1.8 KiB
Rust

use crate::config::StageConfig;
pub fn generate_nst_content(stage: &StageConfig) -> String {
let mut line1_parts = vec![
"ND=50".to_string(),
"NLAMBD=3".to_string(),
"VTB=2.".to_string(),
"ISPODF=1".to_string(),
"DDNU=50.".to_string(),
"CNU1=6.".to_string(),
];
if let Some(chmax) = stage.chmax {
line1_parts.push(format!("CHMAX={}", chmax));
}
if let Some(itek) = stage.itek {
line1_parts.push(format!("ITEK={}", itek));
}
line1_parts.push(format!("NITER={}", stage.niter));
let mut line2_parts = Vec::new();
if let Some(orelax) = stage.orelax {
line2_parts.push(format!("ORELAX={}", orelax));
}
if let Some(idlte) = stage.idlte {
line2_parts.push(format!("IDLTE={}", idlte));
}
if let Some(iacc) = stage.iacc {
line2_parts.push(format!("IACC={}", iacc));
}
if let Some(ichang) = stage.ichang {
line2_parts.push(format!("ICHANG={}", ichang));
}
line2_parts.push("IELCOR=-1".to_string());
format!("{}\n{}\n", line1_parts.join(","), line2_parts.join(","))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_nst_generation() {
let stage = StageConfig {
label: "nc".to_string(),
lte: "F".to_string(),
ltgray: "F".to_string(),
ilvlin: 0,
require_converged: false,
niter: 10,
chmax: None,
itek: None,
metals: None,
ichang: None,
idlte: None,
iacc: None,
orelax: None,
};
let content = generate_nst_content(&stage);
assert!(content.contains("ND=50"));
assert!(content.contains("NITER=10"));
assert!(content.contains("IELCOR=-1"));
}
}