chore: sync project state and current artifacts

This commit is contained in:
Sepehr
2026-02-22 23:27:31 +01:00
parent 1b6415776e
commit dd77089b22
232 changed files with 37056 additions and 4296 deletions

View File

@@ -1,41 +1,85 @@
const { default: init, version, list_available_fluids, WasmSystem, WasmPressure, WasmTemperature, WasmFallbackConfig } = require('../pkg/entropyk_wasm.js');
const {
init,
version,
list_available_fluids,
WasmSystem,
WasmPressure,
WasmTemperature,
WasmFallbackConfig,
WasmCompressor,
WasmCondenser,
WasmEvaporator,
WasmExpansionValve
} = require('../pkg/entropyk_wasm.js');
async function main() {
// Initialize WASM module
console.log('Entropyk WASM Integration Test');
console.log('==============================');
// Initialize module
await init();
console.log('Entropyk WASM Test');
console.log('===================');
console.log('Version:', version());
// Test fluid listing
console.log('WASM Version:', version());
// Verify fluids
const fluids = list_available_fluids();
console.log('Available fluids:', fluids);
// Test pressure creation
const p = new WasmPressure(101325.0);
console.log('Pressure (Pa):', p.pascals());
console.log('Pressure (bar):', p.bar());
// Test temperature creation
const t = WasmTemperature.from_celsius(25.0);
console.log('Temperature (K):', t.kelvin());
console.log('Temperature (°C):', t.celsius());
// Test system creation
if (!fluids.includes('R134a')) {
throw new Error('R134a should be available');
}
// Create system
const system = new WasmSystem();
console.log('System created');
console.log('Node count:', system.node_count());
console.log('Edge count:', system.edge_count());
// Test solver configuration
// Add components
// coeffs: m1..m10
const compressor = new WasmCompressor(
0.85, 2.5, 500.0, 1500.0, -2.5,
1.8, 600.0, 1600.0, -3.0, 2.0
).into_component();
const condenser = new WasmCondenser(5000.0).into_component();
const evaporator = new WasmEvaporator(3000.0).into_component();
const valve = new WasmExpansionValve().into_component();
const cIdx = system.add_component(compressor);
const condIdx = system.add_component(condenser);
const eIdx = system.add_component(evaporator);
const vIdx = system.add_component(valve);
console.log(`Added 4 components. Node count: ${system.node_count()}`);
// Connect components
system.add_edge(cIdx, condIdx);
system.add_edge(condIdx, vIdx);
system.add_edge(vIdx, eIdx);
system.add_edge(eIdx, cIdx);
console.log(`Connected components. Edge count: ${system.edge_count()}`);
// Finalize system
system.finalize();
console.log('System finalized');
// Solve
const config = new WasmFallbackConfig();
config.timeout_ms(1000);
// Test JSON output
console.log('System JSON:', system.toJson());
console.log('\nAll tests passed!');
console.log('Solving system...');
const result = system.solve(config);
console.log('Solve Result:', result.toJson());
if (result.converged) {
console.log('Convergence achieved in', result.iterations, 'iterations');
// Extract result for a node
const state = system.get_node_result(0);
console.log('Node 0 state:', state.toJson());
} else {
console.error('System failed to converge');
// This is expected if the simple setup without boundary conditions is unstable,
// but it verifies the API pipeline.
}
console.log('\nWASM Integration Test PASSED (API verification complete)');
}
main().catch(err => {