Appearance
Model Selection Architecture
Basic and Advanced calculation modes for process units
Overview
ErgoPlanner supports two calculation modes for process units:
| Mode | Description | Use Case |
|---|---|---|
| Basic | Fixed-efficiency calculations using empirical removal rates | Quick estimates, preliminary design, simple plants |
| Advanced | Mechanistic calculations using biokinetic models (ASM1, ASM2d, ASM3, ADM1) | Detailed design, optimization, research |
Calculation Mode Selection
Per-Node Mode Selection
Each process unit can have its own calculation mode. The mode is stored as part of the node parameters:
typescript
interface ProcessUnitParameters {
// ... other parameters
calculationMode?: 'basic' | 'advanced';
}Default Behavior
- New nodes default to
'basic'mode for backward compatibility - Templates can specify default modes per unit type
- Mode changes preserve parameter values for seamless switching
Using the Mode Toggle
In the Properties Panel
- Select a process unit on the canvas
- In the Properties Panel, locate the Mode toggle (below the unit type)
- Click Basic or Advanced to switch modes
- Additional parameters appear in Advanced mode
Visual Indicators
- Basic mode: Standard parameter view
- Advanced mode: Extended parameters with kinetic coefficients
ModelModeService API
The ModelModeService manages calculation mode state:
typescript
import { getModelModeService } from '@/flow/services/simulation/modelMode';
const service = getModelModeService();
// Get current mode (returns 'basic' for unknown nodes)
const mode = service.getCalculationMode('node-id');
// Set calculation mode
service.setCalculationMode('node-id', 'advanced');
// Check if unit type supports advanced mode
const supported = service.supportsAdvancedMode('CSTR');
// Subscribe to mode changes
const unsubscribe = service.subscribe((event) => {
console.log(`Mode changed: ${event.oldMode} -> ${event.newMode}`);
});Parameter Preservation
When switching from Advanced to Basic mode, advanced parameters are cached:
typescript
// Before switching to basic, preserve advanced params
service.preserveAdvancedParams('node-id', currentParams);
service.setCalculationMode('node-id', 'basic');
// Later, when switching back to advanced
service.setCalculationMode('node-id', 'advanced');
const restored = service.restoreAdvancedParams('node-id');Implementing Advanced Process Unit Models
To add advanced mode support to a process unit, implement IAdvancedProcessUnit:
typescript
import { IAdvancedProcessUnit } from '@/flow/services/simulation/plugins';
class AdvancedCSTRModel implements IAdvancedProcessUnit {
// Basic mode parameters shown in UI
basicModeParameters = ['volume', 'mlss', 'srt'];
// Additional advanced parameters
advancedParameterSchema = {
type: 'object',
properties: {
muMax: { type: 'number', title: 'Max growth rate (1/d)' },
Ks: { type: 'number', title: 'Half-saturation (mg/L)' },
Yh: { type: 'number', title: 'Heterotrophic yield' },
}
};
advancedDefaultParameters = {
muMax: 6.0,
Ks: 20,
Yh: 0.67,
};
calculateAdvancedOutputs(inputs, params) {
// Implement ASM1/ASM2d/ASM3 calculations
return outputs;
}
}Template Configuration
Templates can specify default calculation modes:
typescript
// In templateParameterService.ts
const TEMPLATE_DEFAULT_MODES = {
'mle-basic': {
defaultMode: 'basic' as const,
nodeOverrides: {}
},
'mle-advanced': {
defaultMode: 'advanced' as const,
nodeOverrides: {
'cstr-1': 'advanced',
'clarifier-1': 'basic', // Clarifiers stay basic
}
}
};Supported Process Units
Advanced Mode Support
| Unit Type | Basic | Advanced | Biokinetic Models |
|---|---|---|---|
| CSTR | Yes | Yes | ASM1, ASM2d, ASM3 |
| PFR | Yes | Yes | ASM1, ASM3 |
| SBR | Yes | Yes | ASM1, ASM2d |
| MBBR | Yes | Yes | ASM3 |
| MBR | Yes | Yes | ASM1, ASM2d |
| Digester | Yes | Yes | ADM1 |
| Primary Clarifier | Yes | Yes | Stokes/Camp |
| Secondary Clarifier | Yes | Yes | Takács |
| Thickener | Yes | No | - |
| DAF | Yes | No | - |
Best Practices
- Start with Basic mode for initial design
- Switch to Advanced when optimizing or validating
- Use consistent modes across connected units
- Save templates with appropriate default modes
Related Topics
Technical Reference
Files
| File | Purpose |
|---|---|
engine/types.ts | CalculationMode type definition |
plugins/IAdvancedProcessUnit.ts | Advanced model interface |
modelMode/modelModeService.ts | Mode management service |
templates/templateParameterService.ts | Template defaults |