nx_heat_conduction2d_test.nx source
↩ module page · 27 lines · 1328 B
1// nx_heat_conduction2d_test.nx -- smoke for nx_heat_conduction2d. Proves
2// the 2-D transient conduction relaxation: cold spot lags, then heats
3// monotonically toward the surface without overshoot.
4// Exit code = failed assertion number; 0 = all pass.
5
6import "nx_syscalls.nx"
7import "nx_heat_conduction2d.nx"
8
9func main() -> i64 {
10 // --- 5x5: centre lags, then heats to the exact neighbour-average ---
11 if hc2d_run(5, 121, 20, 0) != 20 { return 1 } // no steps: still cold
12 if hc2d_run(5, 121, 20, 1) != 20 { return 2 } // centre neighbours still cold
13 if hc2d_run(5, 121, 20, 2) != 45 { return 3 } // (121+20+20+20)/4 wave reached centre
14
15 // --- 11x11: partial penetration then monotone approach to surface ---
16 if hc2d_run(11, 121, 20, 0) != 20 { return 4 }
17 if hc2d_run(11, 121, 20, 30) <= 20 { return 5 } // penetrated
18 if hc2d_run(11, 121, 20, 30) >= 121 { return 6 } // not yet fully cooked
19 if hc2d_run(11, 121, 20, 300) < hc2d_run(11, 121, 20, 30) { return 7 } // monotone
20 if hc2d_run(11, 121, 20, 300) > 121 { return 8 } // never overshoots surface
21
22 // --- penetration predicate ---
23 if hc2d_penetrated(70, 121, 20, 40) != 1 { return 9 } // 50/101 = 49% >= 40%
24 if hc2d_penetrated(30, 121, 20, 40) != 0 { return 10 } // 10/101 = 10% < 40%
25
26 return 0
27}