coolprop-wasm
v6.6.0
Published
CoolProp thermodynamic property library compiled to WebAssembly - Complete AbstractState API
Maintainers
Readme
CoolProp WASM JavaScript Wrapper
A comprehensive WebAssembly (WASM) wrapper for CoolProp that provides full access to the AbstractState class and low-level API functionality in JavaScript environments.
🚀 Quick Start
Installation
# Clone the repository
git clone https://github.com/CoolProp/CoolProp.git
cd CoolProp/wrappers/Javascript
# Install dependencies (if using Node.js)
npm installBasic Usage
// Node.js
import Module from './coolprop.js';
const CoolProp = await Module();
// Create an AbstractState instance using factory function
const state = CoolProp.factory('HEOS', 'Water');
// Update state with temperature and pressure using correct enum access
state.update(CoolProp.input_pairs.PT_INPUTS, 101325, 373.15); // 1 atm, 100°C
// Get properties
console.log('Density:', state.rhomass(), 'kg/m³');
console.log('Enthalpy:', state.hmass(), 'J/kg');Browser Usage
<!DOCTYPE html>
<html>
<head>
<title>CoolProp WASM Demo</title>
</head>
<body>
<script src="coolprop.js"></script>
<script>
Module().then(CoolProp => {
const state = CoolProp.factory('HEOS', 'Water');
state.update(CoolProp.input_pairs.PT_INPUTS, 101325, 373.15);
console.log('Temperature:', state.T(), 'K');
});
</script>
</body>
</html>🧪 Testing
Run All Tests
# Comprehensive validation (all test types)
node scripts/run_comprehensive_validation.mjs
# Enhanced test suite (performance, memory, browser)
node scripts/run_enhanced_test_suite.mjs
# Final integration tests
node scripts/run_final_integration_tests.mjsRun Specific Test Categories
# Unit tests
node tests/unit/test_basic.mjs
# Property-based tests
node tests/property-based/test_derivative_accuracy.mjs
# Integration tests
node tests/integration/test_error_handling.mjs
# Performance tests
node tests/performance/test_performance_validation.mjs
# Memory tests
node tests/memory/test_memory_management.mjs
# Browser tests (open in browser)
open tests/browser/test_browser_compatibility.html🔧 Building
Standard Build
# Basic build
./build/build.sh
# Enhanced build with optimizations
./build/build_enhanced.shDocker Build
# Build using Docker
./build/docker_build.sh
# Or use Docker Compose
docker-compose -f build/docker-compose.yml up📚 Documentation
- API Documentation - Complete API reference
- Deployment Guide - Integration and deployment
- Build System - Build configuration and options
- Testing Framework - Testing methodology and tools
- TypeScript Guide - TypeScript usage and definitions
- Troubleshooting - Common issues and solutions
🎯 Features
Core Functionality
- ✅ Complete AbstractState class exposure
- ✅ All thermodynamic property calculations
- ✅ Derivative calculations (1st, 2nd, 3rd, 4th order)
- ✅ Mixture handling with composition management
- ✅ Phase envelope calculations
- ✅ Saturation property calculations
- ✅ Critical and limiting property access
- ✅ Ancillary equation support
Developer Experience
- ✅ Full TypeScript definitions
- ✅ Comprehensive error handling
- ✅ Memory management and leak prevention
- ✅ Browser and Node.js compatibility
- ✅ Build tool integration (Webpack, Rollup, Vite)
- ✅ Extensive test coverage (unit, integration, property-based)
- ✅ Performance benchmarking
- ✅ Debug utilities
Quality Assurance
- ✅ Property-based testing framework
- ✅ Cross-browser compatibility testing
- ✅ Memory leak detection
- ✅ Performance regression testing
- ✅ Comprehensive validation suite
🤝 Contributing
- Follow the organized directory structure
- Add tests in the appropriate test category
- Update documentation for new features
- Run the comprehensive validation suite before submitting
📄 License
This project follows the same license as CoolProp. See the main CoolProp repository for license details.
🔗 Links
Last Updated: January 2, 2026 Version: Enhanced WASM Implementation v2.0
