#actor-model #telescope #simulation #optical #modeling #dynamic #giant

gmt_dos-actors

Giant Magellan Telescope Dynamic Optical Simulation Actor Model

26 stable releases (8 major)

11.1.0 Oct 30, 2024
11.0.0 May 3, 2024
10.2.1 Mar 13, 2024
10.1.1 Dec 6, 2023
3.0.1 Sep 20, 2022

#128 in Science

Download history 84/week @ 2024-07-28 39/week @ 2024-08-04 29/week @ 2024-08-11 26/week @ 2024-08-18 23/week @ 2024-08-25 24/week @ 2024-09-01 32/week @ 2024-09-08 28/week @ 2024-09-15 135/week @ 2024-09-22 39/week @ 2024-09-29 24/week @ 2024-10-13 14/week @ 2024-10-20 155/week @ 2024-10-27 43/week @ 2024-11-03 10/week @ 2024-11-10

223 downloads per month
Used in 17 crates (11 directly)

MIT license

245KB
3.5K SLoC

gmt_dos-actors

Crates.io Documentation

gmt_dos-actors is an implementation of the actor model applied to integrated modeling for the Giant Magellan Telescope.

Features

  • Asynchronous actors model
  • Channel based data exchange between actors
  • channels validation at compile time
  • formal interface definition (trait based) between actors and actor clients
  • scripting macro to reduce boilerplate clutter

lib.rs:

GMT Dynamic Optics Simulation Actors

The GMT DOS Actors are the building blocks of the GMT DOS integrated model. Each Actor has 3 properties:

  1. input objects
  2. output objects
  3. client

Input/Outputs

input objects are a collection of inputs and output objects are a collection of outputs. An actor must have at least either 1 input or 1 output. A pair of input/output is linked with a channel where the input is the receiver and the output is the sender. The same output may be linked to several inputs. channels are used to synchronize the Actors.

Each Actor performs the same task, within an infinite loop, consisting of 3 operations:

  1. receiving the inputs if any
  2. updating the client state
  3. sending the outputs if any

The loop exits when one of the following error happens: ActorError::NoData, ActorError::DropSend, ActorError::DropRecv.

Sampling rates

All the inputs of an Actor are collected are the same rate NI, and all the outputs are distributed at the same rate NO, however both inputs and outputs rates may be different. The inputs rate NI is inherited from the rate NO of outputs that the data is collected from i.e. (next actor)::NI=(current actor)::NO.

The rates NI or NO are defined as the ratio between the simulation sampling frequency [Hz] and the actor inputs or outputs sampling frequency [Hz], it must be an integer ≥ 1. If NI>NO, outputs are upsampled with a simple sample-and-hold for NI/NO samples. If NO>NI, outputs are decimated by a factor NO/NI

For a 1000Hz simulation sampling frequency, the following table gives some examples of inputs/outputs sampling frequencies and rate:

Inputs [Hz] Ouputs [Hz] NI NO Upsampling Decimation
1000 1000 1 1 - 1
1000 100 1 10 - 10
100 1000 10 1 10 -
500 100 2 10 - 5
100 500 10 2 5 -

Client

A client must be assigned to an Actor and the client must implement some of the following traits:

  • Write if the actor has some outputs,
  • Read if the actor has some inputs,
  • Update, this trait must always be implemented (but the default empty implementation is acceptable)

Model

An integrated model is build as follows:

  1. select and instanciate the clients

  2. assign clients to Actors

  3. add outputs to the Actors and connect them to inputs of other Actors

  4. build a Model

  5. Check, run and wait for the Model completion

Dependencies

~5–12MB
~127K SLoC