You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Goal:** Migrate helper/utility code from Fortran-order to C-order internally, while keeping the legacy API functional. No structural API changes — Future warnings only. Fix hacky shaping/indexing throughout.
130
+
131
+
**Scope:** 55 occurrences of `order="F"` across 10 files. Migrate where possible, keep F-order only at explicit boundaries.
**Goal:** Port remaining examples from legacy `kspaceFirstOrder2D/3D` to `kspaceFirstOrder()`, validated against MATLAB reference outputs.
162
+
163
+
### Strategy
164
+
165
+
Port examples one at a time using MATLAB as ground truth — not old Python results. Use the k-wave-cupy interop layer as the bridge between MATLAB and Python.
166
+
167
+
**Per-example workflow:**
168
+
169
+
1.**MATLAB reference** — Run the example in MATLAB k-Wave, save outputs to `.mat`
170
+
2.**k-wave-cupy validation** — Call the Python solver from MATLAB via k-wave-cupy (`simulate_from_dicts`). Compare against MATLAB output. This catches F/C ordering and interop issues at the boundary.
171
+
3.**Standalone Python port** — Port the example to `kspaceFirstOrder()`, compare against the same MATLAB `.mat` reference
172
+
4.**CI fixture** — Add the MATLAB `.mat` as a reference test in `tests/integration/`
173
+
174
+
**Why k-wave-cupy first:** The interop layer handles F→C conversion at the boundary. Validating there first means ordering bugs are caught before they propagate to the standalone Python example. Once the k-wave-cupy version matches MATLAB, the Python port is a straightforward translation.
175
+
176
+
**Order of work:**
177
+
1. Migrate example in k-wave-cupy repo (MATLAB calls Python solver)
178
+
2. Validate against MATLAB reference output
179
+
3. Port the standalone Python example in k-wave-python
180
+
4. Add integration test with `.mat` fixture
181
+
182
+
### Examples to port
183
+
184
+
| Example | Blocker | Resolution |
185
+
|---------|---------|------------|
186
+
|`pr_2D_TR_line_sensor`, `pr_3D_TR_planar_sensor`|`TimeReversal` class uses legacy API internally | Refactor `TimeReversal` to call `kspaceFirstOrder()`|
187
+
|`us_defining_transducer`, `us_beam_patterns`, `us_bmode_linear_transducer`, `us_bmode_phased_array`|`NotATransducer`-as-source pipeline untested with new API | Validate transducer pipeline end-to-end via k-wave-cupy first |
188
+
|`checkpointing/checkpoint.py`|`checkpoint_file`/`checkpoint_timesteps` not exposed in new API | Add checkpoint kwargs to `kspaceFirstOrder()`|
189
+
190
+
---
191
+
192
+
## Phase 2.3: v0.6.3 - Axisymmetric Support
193
+
194
+
**Goal:** Add axisymmetric simulation to `kspaceFirstOrder()` and port AS examples.
195
+
196
+
**What axisymmetric means:** Dimensionality reduction for problems with cylindrical symmetry. A 3D symmetric problem is simulated on a 2D (r, z) half-domain; a 2D symmetric problem on a 1D half-domain. Results are mirrored around the symmetry axis to reconstruct the full field.
197
+
198
+
**Current state:**`kspaceFirstOrderAS.py` / `kspaceFirstOrderASC.py` are standalone entry points using the legacy `kWaveSimulation` pipeline. The new API hardcodes `axisymmetric_flag=0`.
199
+
200
+
**Design:** Not a separate solver — a wrapper around `kspaceFirstOrder()` that:
201
+
1. Takes `axisymmetric=True` kwarg
202
+
2. Reduces the grid to a half-domain (y ≥ 0 = radial direction)
203
+
3. Adds radial symmetry terms: special PML at axis (no absorption at y=0), expanded grid for FFT symmetries (WSWA: 4× radial, WSWS: 2×-2), radial coordinate vectors for geometric source terms
204
+
4. Runs the lower-dimensional simulation via `Simulation`
-**MATLAB interop** (`simulate_from_dicts`) — converts F→C on input, C→F on output. Single conversion boundary.
247
+
-**kWaveArray** — rewrite `combine_sensor_data` and `get_distributed_source_signal` to use `np.where` (0-based) and C-order.
248
+
-**sensor.record_start_index** — require 0-based (deprecated 1-based in v0.6.1).
249
+
250
+
**Principle:** Python-native (C-order, 0-based) everywhere internally. MATLAB compatibility at two explicit boundaries: (1) `simulate_from_dicts` for k-wave-cupy interop, (2) `cpp_simulation._write_hdf5` for the C++ binary.
251
+
144
252
---
145
253
146
254
## Phase 3.5: v0.7.0 - CLI (`kwp`)
@@ -207,15 +315,30 @@ result = kspaceFirstOrder(kgrid, medium, source, sensor,
207
315
## Testing Strategy
208
316
209
317
**Existing (keep):**
210
-
- MATLAB reference tests via CI
211
-
- Multi-platform pytest (Windows, Ubuntu, macOS)
212
-
- Python 3.10-3.13 coverage
318
+
- MATLAB reference tests via CI (66 MATLAB collectors → `.mat` fixtures, `scipy.io.loadmat`)
0 commit comments