67 lines
1.8 KiB
Rust
67 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"));
|
|
}
|
|
}
|
|
|