gs
srcgs (Gerchberg-Saxton method) is an algorithm that iterates forward-propagation and back-propagation while alternately imposing amplitude constraints on the transducer side and the focal-point side. It suppresses interference between focal points better than naive, but the amount of computation increases with the number of iterations. The algorithm is based on the paper by Marzo et al. (Marzo & Drinkwater, 2019).
gs( &NalgebraBackend, &geometry, &foci, wavelength, &option, &mut dst,)?;gs(geometry, foci, wavelength, option, dst)Holo.Gs(geometry, foci, wavelength, option, dst);| Parameter | Type | Description |
|---|---|---|
geometry |
&Geometry |
Device layout |
foci |
&[AmplitudeTarget] |
Sequence of focal points (position and target amplitude) |
wavelength |
Length |
Wavelength |
option |
&GsOption |
Additional options (see below) |
dst |
&mut [[Emission; _]] |
Output buffer |
The parameters other than option are the same as Naive.
GsOption
Section titled “GsOption”GsOption { repeat, constraint, directivity, mask, parallel,}GsOption( repeat, constraint, directivity, mask, parallel,)new GsOption( repeat, constraint, directivity, mask, parallel)| Field | Type | Default |
|---|---|---|
repeat |
NonZeroUsize |
100 |
constraint |
EmissionConstraint |
Clamp(MIN, MAX) |
directivity |
Directivity |
Sphere |
mask |
TransducerMask |
AllEnabled |
parallel |
bool |
true |
repeat is the number of iterations.
The larger it is, the higher the quality, but the more computation time increases.
For the meaning of constraint / directivity / mask, see the Holo overview.
parallel decides whether the quantization of the result is spread over several host threads (a GPU backend ignores it).
Example
Section titled “Example”use std::num::NonZeroUsize;
use autd3_rs::geometry::{Autd3, Geometry, offset};use autd3_rs::units::{m, mm, s};use autd3_rs::value::Intensity;use autd3_rs_pattern::wavelength;use autd3_rs_pattern_holo::{ AmplitudeTarget, Directivity, EmissionConstraint, GsOption, NalgebraBackend, Pa, TransducerMask, gs,};
let geometry = Geometry::new(vec![Autd3::default()]);
let mut dst = geometry.pattern_buffer();
gs( &NalgebraBackend, &geometry, &[ AmplitudeTarget { point: geometry.center() + offset(-30.0 * mm, 0.0 * mm, 150.0 * mm), amplitude: 2.5e3 * Pa, }, AmplitudeTarget { point: geometry.center() + offset(30.0 * mm, 0.0 * mm, 150.0 * mm), amplitude: 2.5e3 * Pa, }, ], wavelength(340.0 * m / s), &GsOption { repeat: NonZeroUsize::new(100).unwrap(), constraint: EmissionConstraint::Clamp(Intensity::MIN, Intensity::MAX), directivity: Directivity::Sphere, mask: TransducerMask::AllEnabled, parallel: true, }, &mut dst,)?;import numpy as npfrom autd3.geometry import Autd3, Geometryfrom autd3.units import m, sfrom autd3_pattern import wavelengthfrom autd3_pattern_holo import ( AmplitudeTarget, Directivity, EmissionConstraint, GsOption, Pa, TransducerMask, gs,)
geometry = Geometry([Autd3([0.0, 0.0, 0.0], [1.0, 0.0, 0.0, 0.0])])
dst = geometry.pattern_buffer()
gs( geometry, [ AmplitudeTarget( point=geometry.center() + np.array([-30.0, 0.0, 150.0]), amplitude=2.5e3 * Pa, ), AmplitudeTarget( point=geometry.center() + np.array([30.0, 0.0, 150.0]), amplitude=2.5e3 * Pa, ), ], wavelength(340 * m / s), GsOption( repeat=100, constraint=EmissionConstraint.Clamp(0x00, 0xFF), directivity=Directivity.Sphere, mask=TransducerMask.AllEnabled, ), dst,)using System.Numerics;using AUTD3;using AUTD3.Holo;using static AUTD3.Units;using static AUTD3.Holo.HoloUnits;
var geometry = new Geometry(new[] { new Autd3(Vector3.Zero) });
var dst = geometry.PatternBuffer();
Holo.Gs( geometry, new[] { new AmplitudeTarget(geometry.Center + new Vector3(-30.0f, 0.0f, 150.0f), 2.5e3f * Pa), new AmplitudeTarget(geometry.Center + new Vector3(30.0f, 0.0f, 150.0f), 2.5e3f * Pa), }, Pattern.Wavelength(340.0f * m / s), new GsOption( repeat: 100, constraint: EmissionConstraint.Clamp(Intensity.Min, Intensity.Max), directivity: Directivity.Sphere, mask: TransducerMask.AllEnabled ), dst);