|
89 | 89 | error('Unknown geometry type: %s. Supported types: cylinder, ellipse, rectangle, airfoil, multi', geometry_type); |
90 | 90 | end |
91 | 91 |
|
| 92 | + % Time-based simulation control (alternative to num_time_steps) |
| 93 | + config.simulation.use_end_time = false; % If true, use end_time instead of num_time_steps |
| 94 | + config.simulation.end_time = 20; % Simulation end time (when use_end_time = true) |
| 95 | + config.simulation.end_time_ci = 0.2; % Reduced end time for CI/testing |
| 96 | + |
| 97 | + % Adaptive time step control |
| 98 | + config.adaptive_dt.enable = false; % Enable adaptive time step reduction |
| 99 | + config.adaptive_dt.cfl_threshold = 0.5; % Convective CFL threshold for time step reduction (lowered for stability) |
| 100 | + config.adaptive_dt.cfl_viscous_threshold = 0.5; % Viscous CFL threshold (nu*dt/h^2 < threshold) |
| 101 | + config.adaptive_dt.reduction_factor = 0.2; % Factor to reduce time step by (dt_new = dt * factor) |
| 102 | + config.adaptive_dt.min_factor = 0.001; % Minimum time step as fraction of original (dt_min = dt_0 * min_factor) |
| 103 | + config.adaptive_dt.max_reductions = 10; % Maximum number of consecutive reductions allowed |
| 104 | + config.adaptive_dt.nan_check_enable = true; % Enable NaN checking after time step reduction (stops simulation if found) |
| 105 | + |
92 | 106 | %% RBF-FD Algorithm Parameters |
93 | 107 | % Main stencil sizes |
94 | 108 | config.rbf.stencil_size_main = 35; |
|
138 | 152 |
|
139 | 153 | %% Logging and Debug Parameters |
140 | 154 | % Master debug switch - set to true to enable all debug features |
141 | | - debug_master = false; % Master switch for all debug features |
| 155 | + debug_master = false; % Master switch for all debug features |
| 156 | + |
| 157 | + % Local CFL diagnostics |
| 158 | + config.logging.cfl_check_frequency = 1; % Run local CFL check every N steps |
| 159 | + config.logging.cfl_local_enable = true; % Enable per-node CFL checks |
| 160 | + config.logging.cfl_percentiles = [90 99]; % Percentiles to report |
142 | 161 |
|
143 | 162 | % Individual debug settings (controlled by master switch unless overridden) |
144 | 163 | config.logging.enable = debug_master; % Enable debug logging |
145 | | - config.logging.step_frequency = 3; % Print diagnostics every N steps |
| 164 | + config.logging.step_frequency = 1; % Print diagnostics every N steps |
146 | 165 | config.logging.trace_substeps = debug_master; % Print substep diagnostics inside fractional step |
147 | 166 | config.logging.snapshot_on_nan = debug_master; % Save snapshot if NaN detected |
148 | 167 | config.logging.snapshot_dir = 'debug'; % Directory to save debug snapshots |
|
164 | 183 | % Stability thresholds |
165 | 184 | config.logging.cfl_warning_threshold = 0.8; % Warn if CFL > this value |
166 | 185 | config.logging.cfl_critical_threshold = 1.5; % Critical CFL threshold |
167 | | - config.logging.velocity_explosion_threshold = 100; % Velocity magnitude explosion threshold |
168 | | - config.logging.pressure_explosion_threshold = 1000; % Pressure explosion threshold |
| 186 | + config.logging.cfl_stop_threshold = 0.9; % Stop simulation if CFL > this value (always active) |
| 187 | + config.logging.velocity_explosion_threshold = 100; % Velocity magnitude explosion threshold |
| 188 | + config.logging.pressure_explosion_threshold = 1000; % Pressure explosion threshold |
169 | 189 | config.logging.divergence_warning_threshold = 10; % Mass conservation warning |
170 | 190 | config.logging.divergence_critical_threshold = 100; % Mass conservation critical |
171 | 191 | config.logging.condition_number_threshold = 1e12; % Matrix conditioning threshold |
| 192 | + config.logging.immediate_nan_check = true; % Check for NaNs immediately after each time step |
| 193 | + config.logging.comprehensive_instability_check = true; % Check for all types of instability (not just NaNs) |
| 194 | + config.logging.periodic_health_check = false; % Periodic health checks during simulation |
| 195 | + config.logging.health_check_frequency = 10; % Health check every N steps |
172 | 196 |
|
173 | 197 | % Environment override for enabling logging |
174 | 198 | dbg_env = getenv('DEBUG'); |
|
0 commit comments