pub enum ModelType {
Xinanjiang,
Topmodel,
Swat,
Apicont,
}Expand description
Identifier for the four distributed hydrology models orchestrated by the platform crate.
Used as a machine-friendly tag in scenario configs and parameter
overrides; for the human-readable label, see ModelType::name or
HydroModel::name.
Variants§
Xinanjiang
Xinanjiang model (三水源, saturation-excess + unit-hydrograph routing).
Topmodel
TOPMODEL (Beven & Kirkby 1979, saturation-excess, TWI-based).
Swat
SWAT+ LTE (USDA-ARS, daily, hydrology-only subset).
Apicont
API-CONT (antecedent precipitation index continuous baseline).
Implementations§
Source§impl ModelType
impl ModelType
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Human-readable display name in conventional Chinese/English
("新安江", "TOPMODEL", "SWAT", "API-CONT"), suitable for UI
tables and reports.
Examples found in repository?
examples/huagrahuma_check.rs (line 123)
39fn main() {
40 let path = concat!(env!("CARGO_MANIFEST_DIR"), "/huagrahuma.csv");
41 let data = read_csv(path);
42 let n = data.len();
43 let rain_mm: Vec<f64> = data.iter().map(|(r, _, _)| r * 1000.0).collect(); // m→mm
44 let etp_mm: Vec<f64> = data.iter().map(|(_, _, e)| e * 1000.0).collect();
45 let qobs_mm: Vec<f64> = data.iter().map(|(_, q, _)| q * 1000.0).collect(); // m→mm, 含 nan
46
47 // ── huagrahuma 官方 TOPMODEL 参数 + topidx + channel delay ──
48 let params = TopmodelParams {
49 qs0: 3.1679137e-05,
50 lnTe: -0.59906153,
51 m: 0.021297228,
52 Sr0: 0.0026263734,
53 Srmax: 0.86832448,
54 td: 2.85,
55 vch: 1000.0,
56 vr: 1199.17146,
57 K0: 0.0093610525,
58 CD: 0.72355726,
59 dt: 0.25,
60 topidx: Some(TopidxHistogram {
61 atb: vec![
62 16.215282, 15.271870, 14.328457, 13.385044, 12.441632, 11.498219, 10.554807,
63 9.611394, 8.667981, 7.724569, 6.781156, 5.837743, 4.894331, 3.950918, 3.007506,
64 2.064093,
65 ],
66 Aatb_r: vec![
67 0.000619, 0.000464, 0.001857, 0.004488, 0.003869, 0.009595, 0.019963, 0.030641,
68 0.057103, 0.084184, 0.147787, 0.213711, 0.227329, 0.147323, 0.043794, 0.007273,
69 ],
70 }),
71 channel: Some(ChannelDelay {
72 d: vec![0.0, 1000.0, 3000.0, 5000.0],
73 Ad_r: vec![0.0, 0.1, 0.5, 1.0],
74 }),
75 area_km2: 1.0,
76 };
77
78 // ── TOPMODEL 忠实跑(run_topmodel_full → Qt 水深 mm/时步)──
79 let out = run_topmodel_full(¶ms, &rain_mm, &etp_mm);
80 let qt = &out.Qt;
81 let nse_q = nse(qt, &qobs_mm);
82 let rc_obs = {
83 let valid: Vec<f64> = qobs_mm.iter().filter(|v| !v.is_nan()).copied().collect();
84 let mean = valid.iter().sum::<f64>() / valid.len() as f64;
85 mean * n as f64 / rain_mm.iter().sum::<f64>()
86 };
87 let rc_tm = qt.iter().sum::<f64>() / rain_mm.iter().sum::<f64>();
88
89 println!("=== huagrahuma TOPMODEL 忠实验证(n={}, 15min 步长)===", n);
90 println!(" TOPMODEL vs Qobs NSE = {:.4}", nse_q);
91 println!(" 径流系数: TOPMODEL {:.3} | 实测(Qobs) {:.3}", rc_tm, rc_obs);
92 println!(
93 " 峰值(mm/h): TOPMODEL {:.2} | 实测 {:.2} | 雨 {:.1}",
94 qt.iter().cloned().fold(0.0_f64, f64::max) * 4.0,
95 qobs_mm.iter().cloned().fold(0.0_f64, f64::max) * 4.0,
96 rain_mm.iter().cloned().fold(0.0_f64, f64::max) * 4.0
97 );
98
99 // ── 新安江 / SWAT 默认参数在同 rain 上的径流系数(看量级)──
100 println!("\n=== 三模型默认参数在 huagrahuma rain 上的长期径流系数 ===");
101 println!(" (注:新安江/SWAT 用各自默认参数,非 huagrahuma 率定;TOPMODEL 用官方参数)");
102 println!(" 真实(huagrahuma Qobs) = {:.3}", rc_obs);
103 // TOPMODEL 官方参数
104 println!(" TOPMODEL(官方参数) = {:.3} ← NSE {:.3}", rc_tm, nse_q);
105 // 新安江 / SWAT:用默认参数跑,累加 discharge 转回水深
106 for mt in [ModelType::Xinanjiang, ModelType::Swat] {
107 let p = default_params(mt);
108 let mut m = create_model(mt, &p);
109 let mut sum_q_mm = 0.0_f64;
110 for i in 0..n {
111 if mt == ModelType::Swat {
112 // 日尺度近似:把 mm/15min 当作"该 15min 雨持续全天"→ mm/day = ×96(放大,仅看量级)
113 m.step(&Forcing { p_mm: rain_mm[i] * 96.0, pet_mm: etp_mm[i] * 96.0, t_c: 12.0 }, 24.0);
114 let raw = m.discharge();
115 sum_q_mm += raw * 86400.0 / (100.0 * 1e4) * 1000.0 / 96.0; // m³/s→mm/day→mm/15min
116 } else {
117 // 小时/亚小时尺度:p_mm = mm/时步 = mm/15min(dt=0.25h)
118 m.step(&Forcing { p_mm: rain_mm[i], pet_mm: etp_mm[i], t_c: 12.0 }, 0.25);
119 sum_q_mm += m.discharge() * 0.25 * 3600.0 / (1000.0 * 1e6) * 1000.0;
120 }
121 }
122 let rc = sum_q_mm / rain_mm.iter().sum::<f64>();
123 println!(" {:>10}(默认) = {:.3}", mt.name(), rc);
124 }
125}Trait Implementations§
impl Copy for ModelType
Source§impl<'de> Deserialize<'de> for ModelType
impl<'de> Deserialize<'de> for ModelType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ModelType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for ModelType
Source§impl Serialize for ModelType
impl Serialize for ModelType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for ModelType
Auto Trait Implementations§
impl Freeze for ModelType
impl RefUnwindSafe for ModelType
impl Send for ModelType
impl Sync for ModelType
impl Unpin for ModelType
impl UnsafeUnpin for ModelType
impl UnwindSafe for ModelType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more