nx_vessel_geometry_test.nx source
↩ module page · 48 lines · 2089 B
1// nx_vessel_geometry_test.nx -- smoke for nx_vessel_geometry (C0).
2//
3// Proves the geometry -> thermal-twin -> certification design loop:
4// - a 4 L / r=80 mm cylinder gets a sane height + area (1-2)
5// - heat capacity matches water physics (~16744 J/K) (3)
6// - insulation conductance is sane and DROPS with thicker insulation (4-5)
7// - bigger volume -> bigger heat capacity (6)
8// - CLOSED LOOP: the geometry-derived device CERTIFIES for yogurt (7)
9// Exit code = failed assertion number; 0 = all pass.
10
11import "nx_syscalls.nx"
12import "nx_ferment_safety.nx"
13import "nx_ferment_kinetics.nx"
14import "nx_ferment_recipes.nx"
15import "nx_vessel_thermal.nx"
16import "nx_vessel_io.nx"
17import "nx_vessel_faults.nx"
18import "nx_vessel_design.nx"
19import "nx_vessel_twin.nx"
20import "nx_vessel_geometry.nx"
21
22func main() -> i64 {
23 // 4 L, 80 mm radius, 3 mm wall, 5 mm cork insulation (k = 0.043 W/m.K)
24 let g: *NxVesselGeom = nx_vessel_geom_design(4000, 80, 3, 5, 43)
25 if g.height_mm < 150 { return 1 } // ~199 mm
26 if g.height_mm > 260 { return 2 }
27 let c: i64 = nx_vessel_geom_heat_capacity_jk(g)
28 if c < 16000 { return 3 } // ~16744 J/K (water physics)
29 if c > 17500 { return 3 }
30 let u: i64 = nx_vessel_geom_insulation_mwk(g)
31 if u < 800 { return 4 } // ~1.2 W/K with 5 mm cork
32 if u > 1600 { return 4 }
33
34 // thicker insulation -> lower conductance
35 let g2: *NxVesselGeom = nx_vessel_geom_design(4000, 80, 3, 10, 43)
36 if nx_vessel_geom_insulation_mwk(g2) >= u { return 5 }
37
38 // bigger volume -> bigger heat capacity
39 let g8: *NxVesselGeom = nx_vessel_geom_design(8000, 100, 3, 5, 43)
40 if nx_vessel_geom_heat_capacity_jk(g8) <= c { return 6 }
41
42 // --- CLOSED LOOP: build the twin FROM geometry and certify for yogurt ---
43 let env: *NxFermentSafetyEnvelope = nx_ferment_safety_envelope_default(1)
44 let twin: *NxVesselThermal = nx_vessel_geom_to_twin(g, 50000, 20000)
45 if nx_vessel_twin_certify(env, twin, 60000, NX_RCP_YOGURT) != NX_TWIN_CERTIFIED { return 7 }
46
47 return 0
48}