Simulator¶
The simulator is designed to help you get started with Lima and to test or explore Lima without any hardware. It generates synthetic frames on-the-fly using configurable pattern generators, and supports MPI-based multi-receiver setups.
Initialization parameters¶
The init_params structure configures the detector at startup.
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
2048 |
Frame width in pixels |
|
int |
2048 |
Frame height in pixels |
Acquisition parameters¶
The simulator extends the standard hw::acq_params with a det field containing simulator-specific parameters.
Standard parameters (acq_params.acq)¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
int |
1 |
Number of frames to acquire |
|
duration |
1ms |
Exposure time |
|
duration |
0ms |
Latency between frames |
|
enum |
|
Trigger mode: |
|
int |
1 |
Number of frames produced per trigger |
|
enum |
|
Acquisition mode |
Detector-specific parameters (acq_params.det)¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
— |
Frame generator configuration |
|
int |
1 |
Size of the prefetch ring buffer. Increase to simulate high frame rates. |
|
int |
0 |
Frame index after which frames are dropped. |
|
int |
0 |
Frame index after which acquisition fails. |
|
enum |
|
How frames are dispatched across MPI receivers (see below). |
Frame generators¶
The generator is selected via det.generator.type.
Common generator parameters (generator_params)¶
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
enum |
|
Generator type: |
|
enum |
|
Pixel format: |
|
size_t |
1 |
Number of channels (bands) per frame |
|
|
— |
Parameters for the Gauss generator |
|
|
— |
Parameters for the Diffraction generator |
|
|
— |
Spiral parameters is reusing first peak of gaussian generator parameters |
Gauss generator (type = gauss)¶
Generates frames with one or more Gaussian peaks. Useful for simulating simple spot patterns.
gauss_params
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
|
one default peak |
List of Gaussian peaks |
|
double |
0.0 |
Factor by which peaks grow between frames |
gauss_peak
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
double |
1024.0 |
Center of the peak (pixels) |
|
double |
128.0 |
Full Width at Half Maximum |
|
double |
100.0 |
Peak intensity value |
Diffraction generator (type = diffraction)¶
Generates frames that simulate a diffraction pattern from a moving source.
diffraction_params
Parameter |
Type |
Default |
Description |
|---|---|---|---|
|
double |
1024.0 |
Center of the diffraction pattern (pixels) |
|
double |
5.0 |
Initial source position relative to the pattern center |
|
double |
0.0 |
Source velocity in pixels per frame |
Spiral generator (type = spiral)¶
Generates frames that simulate a spiral of Gaussian peaks. Usefull to simulate accumulated patterns
Frame dispatch modes¶
In MPI setups the simulator distributes frames across receiver processes. The dispatch_mode controls how:
Mode |
Description |
|---|---|
|
Frames are dispatched sequentially in turn to each receiver (deterministic, balanced). |
|
Frames are dispatched pseudo-randomly using a seeded RNG (reproducible across runs). |
|
Frames are dispatched fully randomly with no reproducibility guarantee. |
Fault injection¶
The simulator can inject faults to test error handling:
Dropped frames (
dropped_frame_idx): Setting this toN > 0causes the simulator to stop sending frames after frameN. Receivers will detect a missing frame.Failed acquisition (
failed_frame_idx): Setting this toN > 0causes the acquisition to report a failure after frameN.
Both are disabled by default (value 0).
Prefetching¶
The nb_prefetch_frames parameter controls the size of an internal ring buffer of pre-generated frames. Increasing this value decouples frame generation from frame delivery, which allows the simulator to sustain high frame rates without stalling on generation time. The ring buffer also defines the cycle length: once nb_prefetch_frames frames have been delivered, the sequence repeats from the beginning.