code wiki / (root) / nx_polymer_thermal_test.nx

nx_polymer_thermal_test.nx source

↩ module page · 79 lines · 3005 B

1// nx_polymer_thermal_test.nx -- per-polymer thermal envelope + 2// validator against operator-supplied temps. 3// 4// Closed-form invariants (hand-verified per polymer literature): 5// (a) PLA envelope: Tg=60, Tm=160, Td=250, print 190-230, bed 50-65 6// (b) PETG envelope: Tg=80, Tm=240, Td=290, print 220-250, bed 70-85 7// (c) ABS envelope: amorphous (Tm=0), Td=270 8// (d) PEEK envelope: Td=575 (high-temp engineering polymer) 9// (e) Unknown material class returns NULL 10// (f) PLA at 210/60 -> SAFE 11// (g) PLA at 160/60 -> PRINT_TOO_LOW 12// (h) PLA at 260/60 -> DECOMP_RISK (260 > Td=250) 13// (i) PLA at 210/100 -> BED_TOO_HIGH (PLA bed max 65) 14// (j) ABS at 210/100 -> PRINT_TOO_LOW (ABS min 220) 15// (k) PETG at 235/80 -> SAFE 16// (l) Generic-PLA profile factory validates SAFE 17// 18// expect_exit: 0 19// license_tier: ORIGINAL 20 21import "nx_syscalls.nx" 22import "nx_material_profile.nx" 23import "nx_polymer_thermal.nx" 24 25func main() -> i64 { 26 // --- (a) PLA --- 27 let pla: *NxPolymerThermal = nx_polymer_thermal_for(NX_MAT_PLA) 28 if (pla as i64) == 0 { return 10 } 29 if pla.tg_c != 60 { return 11 } 30 if pla.tm_c != 160 { return 12 } 31 if pla.td_c != 250 { return 13 } 32 if pla.print_min_c != 190 { return 14 } 33 if pla.print_max_c != 230 { return 15 } 34 if pla.bed_min_c != 50 { return 16 } 35 if pla.bed_max_c != 65 { return 17 } 36 37 // --- (b) PETG --- 38 let petg: *NxPolymerThermal = nx_polymer_thermal_for(NX_MAT_PETG) 39 if petg.tg_c != 80 { return 20 } 40 if petg.tm_c != 240 { return 21 } 41 if petg.td_c != 290 { return 22 } 42 43 // --- (c) ABS amorphous --- 44 let abs: *NxPolymerThermal = nx_polymer_thermal_for(NX_MAT_ABS) 45 if abs.tm_c != 0 { return 30 } 46 if abs.td_c != 270 { return 31 } 47 48 // --- (d) PEEK high-temp --- 49 let peek: *NxPolymerThermal = nx_polymer_thermal_for(NX_MAT_PEEK) 50 if peek.td_c != 575 { return 40 } 51 52 // --- (e) Unknown class --- 53 let bad: *NxPolymerThermal = nx_polymer_thermal_for(99) 54 if (bad as i64) != 0 { return 50 } 55 56 // --- (f) PLA safe --- 57 if nx_polymer_thermal_validate(pla, 210, 60) != NX_POLYTHERM_SAFE { return 60 } 58 59 // --- (g) PLA too low --- 60 if nx_polymer_thermal_validate(pla, 160, 60) != NX_POLYTHERM_PRINT_TOO_LOW { return 70 } 61 62 // --- (h) PLA decomp risk --- 63 if nx_polymer_thermal_validate(pla, 260, 60) != NX_POLYTHERM_DECOMP_RISK { return 80 } 64 65 // --- (i) PLA bed too high --- 66 if nx_polymer_thermal_validate(pla, 210, 100) != NX_POLYTHERM_BED_TOO_HIGH { return 90 } 67 68 // --- (j) ABS too low --- 69 if nx_polymer_thermal_validate(abs, 210, 100) != NX_POLYTHERM_PRINT_TOO_LOW { return 100 } 70 71 // --- (k) PETG safe --- 72 if nx_polymer_thermal_validate(petg, 235, 80) != NX_POLYTHERM_SAFE { return 110 } 73 74 // --- (l) Generic PLA factory composes --- 75 let mat: *NxMaterialProfile = nx_material_profile_generic_pla() 76 if nx_polymer_validate_profile(mat) != NX_POLYTHERM_SAFE { return 120 } 77 78 return 0 79}