|
1 | | -# Manual/Diagnostic Tests |
| 1 | +# Manual Diagnostic Tests |
2 | 2 |
|
3 | | -This directory contains diagnostic tools for **visual verification** of HydroChrono components. These are NOT automated tests - they generate data files that you can plot and inspect. |
| 3 | +This directory contains diagnostic tools for **visual verification** of the state-space radiation damping implementation in HydroChrono. These are NOT automated tests - they generate comparison figures showing convolution vs state-space methods. |
4 | 4 |
|
5 | | -## Available Diagnostics |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +# Build |
| 9 | +cmake --build build --config Release --target sphere_decay_ss_comparison |
6 | 10 |
|
7 | | -### RadiationStateSpaceModel Verification |
| 11 | +# Run (generates CSV data files) |
| 12 | +cd build/bin/tests/manual |
| 13 | +./sphere_decay_ss_comparison |
8 | 14 |
|
9 | | -**Executable:** `radiation_ss_visual_check` |
10 | | -**Python script:** `plot_radiation_ss.py` |
| 15 | +# Plot (generates verification figure) |
| 16 | +python plot_model_comparison.py sphere --save |
| 17 | +``` |
11 | 18 |
|
12 | | -Verifies the state-space radiation model by comparing numerical results against analytical solutions. |
| 19 | +--- |
13 | 20 |
|
14 | | -#### Scenarios covered: |
| 21 | +## Available Diagnostics |
15 | 22 |
|
16 | | -1. **Constant velocity response** - Single mode, constant velocity input |
17 | | - - Verifies exponential approach to steady state |
18 | | - - Checks force = H × z relationship |
| 23 | +### Sphere Decay Test |
19 | 24 |
|
20 | | -2. **Step velocity response** - Velocity step change |
21 | | - - Shows the "memory" effect of radiation damping |
22 | | - - Tests transient response to input changes |
| 25 | +Single-body heave decay simulation comparing convolution and state-space radiation. |
23 | 26 |
|
24 | | -3. **Multiple modes** - Superposition of slow and fast modes |
25 | | - - Verifies that mode contributions add correctly |
26 | | - - Shows different time constants interacting |
| 27 | +```bash |
| 28 | +cmake --build build --config Release --target sphere_decay_ss_comparison |
| 29 | +./sphere_decay_ss_comparison |
| 30 | +python plot_model_comparison.py sphere --save |
| 31 | +``` |
27 | 32 |
|
28 | | -4. **Time step sensitivity** - Same scenario with dt = 0.01, 0.1, 0.5, 1.0 s |
29 | | - - Demonstrates unconditional stability of the exact integrator |
30 | | - - Even very large time steps give reasonable results |
| 33 | +**Output**: `output/sphere_ss_verification.png` |
31 | 34 |
|
32 | | -## Usage |
| 35 | +### OSWEC Decay Test |
33 | 36 |
|
34 | | -### 1. Build the diagnostic |
| 37 | +Two-body pitch decay simulation (flap + base) with increased fitting parameters for complex coupled kernels. |
35 | 38 |
|
36 | 39 | ```bash |
37 | | -cmake --build build --target radiation_ss_visual_check |
| 40 | +cmake --build build --config Release --target oswec_decay_ss_comparison |
| 41 | +./oswec_decay_ss_comparison |
| 42 | +python plot_model_comparison.py oswec --save |
38 | 43 | ``` |
39 | 44 |
|
40 | | -### 2. Run it (generates CSV files) |
| 45 | +**Output**: `output/oswec_ss_verification.png` |
41 | 46 |
|
42 | | -```bash |
43 | | -# From the manual tests directory (recommended): |
44 | | -cd build/bin/tests/manual |
45 | | -./radiation_ss_visual_check |
| 47 | +--- |
46 | 48 |
|
47 | | -# This creates output/ subdirectory with CSV files: |
48 | | -# output/radiation_ss_constant_v.csv |
49 | | -# output/radiation_ss_step_v.csv |
50 | | -# ... |
| 49 | +## Output Files |
51 | 50 |
|
52 | | -# Or specify a custom output directory: |
53 | | -./radiation_ss_visual_check my_output_dir |
54 | | -``` |
| 51 | +### Data Files (CSV) |
55 | 52 |
|
56 | | -### 3. Plot the results |
| 53 | +| File | Description | |
| 54 | +|------|-------------| |
| 55 | +| `{model}_kernel_fit.csv` | RIRF kernel vs state-space fit for key DOF | |
| 56 | +| `{model}_convolution.csv` | Time series from convolution method | |
| 57 | +| `{model}_state_space.csv` | Time series from state-space method | |
| 58 | +| `{model}_performance.csv` | Computation time scaling data | |
57 | 59 |
|
58 | | -```bash |
59 | | -# From the manual tests directory: |
60 | | -cd build/bin/tests/manual |
61 | | -python plot_radiation_ss.py |
| 60 | +### Figures (PNG) |
62 | 61 |
|
63 | | -# This reads from output/ and displays plots |
| 62 | +Each verification figure (`{model}_ss_verification.png`) contains: |
64 | 63 |
|
65 | | -# Save plots to PNG files: |
66 | | -python plot_radiation_ss.py --save |
| 64 | +1. **Top row**: Kernel fit quality (RIRF vs SS fit for key DOF) |
| 65 | +2. **Middle row**: Time series comparison (convolution vs state-space) |
| 66 | +3. **Bottom row**: Performance scaling (total time, per-step cost, speedup) |
67 | 67 |
|
68 | | -# Or specify a custom data directory: |
69 | | -python plot_radiation_ss.py my_output_dir --save |
70 | | -``` |
| 68 | +--- |
71 | 69 |
|
72 | 70 | ## Directory Structure |
73 | 71 |
|
74 | | -After running, you'll have: |
75 | 72 | ``` |
76 | | -build/bin/tests/ |
77 | | -├── unit/ |
78 | | -│ ├── test_radiation_ss_model.exe |
79 | | -│ └── test_hydro_yaml_parser.exe |
80 | | -├── manual/ |
81 | | -│ ├── radiation_ss_visual_check.exe |
82 | | -│ ├── plot_radiation_ss.py |
83 | | -│ └── output/ |
84 | | -│ ├── radiation_ss_constant_v.csv |
85 | | -│ ├── radiation_ss_step_v.csv |
86 | | -│ ├── radiation_ss_multi_mode.csv |
87 | | -│ ├── radiation_ss_dt_sensitivity.csv |
88 | | -│ ├── plot_constant_velocity.png (if --save) |
89 | | -│ ├── plot_step_velocity.png |
90 | | -│ ├── plot_multi_mode.png |
91 | | -│ └── plot_dt_sensitivity.png |
92 | | -└── regression/ |
93 | | - └── ... |
| 73 | +tests/manual/ |
| 74 | +├── sphere_decay_ss_comparison.cpp # Sphere heave decay test |
| 75 | +├── oswec_decay_ss_comparison.cpp # OSWEC pitch decay test |
| 76 | +├── plot_model_comparison.py # Unified plotting script |
| 77 | +├── CMakeLists.txt |
| 78 | +└── README.md |
| 79 | +
|
| 80 | +build/bin/tests/manual/ |
| 81 | +├── sphere_decay_ss_comparison.exe |
| 82 | +├── oswec_decay_ss_comparison.exe |
| 83 | +├── plot_model_comparison.py |
| 84 | +└── output/ |
| 85 | + ├── sphere_ss_verification.png |
| 86 | + ├── oswec_ss_verification.png |
| 87 | + └── *.csv (data files) |
94 | 88 | ``` |
95 | 89 |
|
96 | | -## Requirements |
| 90 | +--- |
| 91 | + |
| 92 | +## What These Diagnostics Show |
| 93 | + |
| 94 | +### Kernel Fit Quality |
| 95 | + |
| 96 | +Shows how accurately the Hankel-SVD fitter approximates the RIRF kernel: |
| 97 | +- Blue line: Actual RIRF from BEM data |
| 98 | +- Red dashed: State-space reconstruction |
| 99 | +- Good fit: Lines overlap, R² close to 1.0 |
| 100 | + |
| 101 | +### Time Series Comparison |
| 102 | + |
| 103 | +Verifies the state-space model produces forces equivalent to direct convolution: |
| 104 | +- Blue: Convolution-based simulation |
| 105 | +- Red dashed: State-space simulation |
| 106 | +- Key metric: Maximum position/angle difference |
| 107 | + |
| 108 | +### Performance Scaling |
97 | 109 |
|
98 | | -The plotting script requires: |
99 | | -- Python 3.6+ |
100 | | -- matplotlib |
101 | | -- pandas |
| 110 | +Demonstrates the computational advantage of state-space: |
| 111 | +- **Convolution**: O(N) per step - time grows with simulation length |
| 112 | +- **State-space**: O(1) per step - constant time regardless of history |
| 113 | +- Speedup factor grows with simulation duration (typically 10-20× for long simulations) |
102 | 114 |
|
103 | | -Install with: |
| 115 | +--- |
| 116 | + |
| 117 | +## Requirements |
| 118 | + |
| 119 | +Python dependencies: |
104 | 120 | ```bash |
105 | | -pip install matplotlib pandas |
| 121 | +pip install matplotlib pandas numpy |
106 | 122 | ``` |
107 | 123 |
|
108 | | -## Output Files |
109 | | - |
110 | | -| File | Description | |
111 | | -|------|-------------| |
112 | | -| `radiation_ss_constant_v.csv` | Constant velocity response data | |
113 | | -| `radiation_ss_step_v.csv` | Step velocity response data | |
114 | | -| `radiation_ss_multi_mode.csv` | Multiple modes superposition data | |
115 | | -| `radiation_ss_dt_sensitivity.csv` | Time step sensitivity data | |
| 124 | +--- |
116 | 125 |
|
117 | | -## Why Visual Checks? |
| 126 | +## Notes |
118 | 127 |
|
119 | | -Unit tests verify *numerical correctness* - the numbers match expected values within tolerance. But visual checks help to build intuition about how the model behaves, spot unexpected patterns and communicate results to others effectively. |
| 128 | +- The sphere test uses default fitting parameters (`max_order=10`, `max_hankel_size=200`) |
| 129 | +- The OSWEC test uses increased parameters (`max_order=15`, `max_hankel_size=500`) due to more complex coupled dynamics |
| 130 | +- Both tests use the `RadiationStateSpaceComponent` integrated with `HydroSystem` |
0 commit comments