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

width

int

2048

Frame width in pixels

height

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

nb_frames

int

1

Number of frames to acquire

expo_time

duration

1ms

Exposure time

latency_time

duration

0ms

Latency between frames

trigger_mode

enum

internal

Trigger mode: internal, software, external

nb_frames_per_trigger

int

1

Number of frames produced per trigger

acq_mode

enum

normal

Acquisition mode

Detector-specific parameters (acq_params.det)

Parameter

Type

Default

Description

generator

generator_params

Frame generator configuration

nb_prefetch_frames

int

1

Size of the prefetch ring buffer. Increase to simulate high frame rates.

dropped_frame_idx

int

0

Frame index after which frames are dropped. 0 disables frame dropping.

failed_frame_idx

int

0

Frame index after which acquisition fails. 0 disables failure injection.

dispatch_mode

enum

round_robin

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

type

enum

gauss

Generator type: gauss or diffraction

pixel_type

enum

gray8

Pixel format: gray8, gray16, gray32, gray32f

nb_channels

size_t

1

Number of channels (bands) per frame

gauss

gauss_params

Parameters for the Gauss generator

diffraction

diffraction_params

Parameters for the Diffraction generator

spiral

gauss_params

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

peaks

vector<gauss_peak>

one default peak

List of Gaussian peaks

grow_factor

double

0.0

Factor by which peaks grow between frames

gauss_peak

Parameter

Type

Default

Description

x0, y0

double

1024.0

Center of the peak (pixels)

fwhm

double

128.0

Full Width at Half Maximum

max

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

x0, y0

double

1024.0

Center of the diffraction pattern (pixels)

source_pos_x, source_pos_y

double

5.0

Initial source position relative to the pattern center

source_speed_x, source_speed_y

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

round_robin

Frames are dispatched sequentially in turn to each receiver (deterministic, balanced).

predictive_random

Frames are dispatched pseudo-randomly using a seeded RNG (reproducible across runs).

full_random

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 to N > 0 causes the simulator to stop sending frames after frame N. Receivers will detect a missing frame.

  • Failed acquisition (failed_frame_idx): Setting this to N > 0 causes the acquisition to report a failure after frame N.

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.