MAOS
Multithreaded Adaptive Optics Simulator
|
Data Structures | |
struct | servo_t |
struct | sho_t |
union | servo_t.__unnamed__ |
union | servo_t.__unnamed__ |
Functions | |
dcell * | servo_optim (real dt, long dtrat, real al, real pmargin, real f0, real zeta, int servo_type, const dmat *psdin, const dmat *sigma2n) |
real | servo_optim_margin (real dt, long dtrat, real al, real pmargin, real f0, real zeta) |
dmat * | servo_cl2ol (const dmat *psdcl, real dt, long dtrat, real al, real gain, real sigma2n) |
real | servo_residual (real *noise_amp, const dmat *psdin, real dt, long dtrat, real al, const dmat *gain, int servo_type) |
servo_t * | servo_new (anyarray merr, const dmat *ap, real al, real dt, const dmat *ep) |
servo_t * | servo_new_scalar (anyarray merr, real ap, real al, real dt, real ep) |
servo_t * | servo_new_sho (anyarray merr, const dmat *ap, real al, real dt, const dmat *ep, real f0, real zeta) |
int | servo_filter (servo_t *st, const anyarray merr) |
void | servo_add (servo_t *st, const anyarray madj, real alpha) |
void | servo_output (const servo_t *st, panyarray out) |
dmat * | servo_test (dmat *mideal, real dt, int dtrat, dmat *sigma2n, dmat *gain) |
void | servo_reset (servo_t *st) |
void | servo_free (servo_t *st) |
sho_t * | sho_new (real f0, real zeta) |
void | sho_free (sho_t *sho) |
void | sho_step (panyarray xout, sho_t *sho, anyarray xi, real dt, int average) |
void | sho_reset (sho_t *sho) |
dmat * | sho_filter (const dmat *xi, real dt, real f0, real zeta, int average) |
Routines for servo optimization, filtering, etc.
struct servo_t |
Struct for servo filtering
Data Fields | ||
---|---|---|
union servo_t | __unnamed__ | |
union servo_t | __unnamed__ | |
cell * | mlead |
lead filter temporary storage |
cell * | merrlast |
recorded errro signal from last step |
cell * | merrhist |
Keep a short history of merr |
int | initialized |
is this data initialized |
int | alint |
Integral part of latency |
real | alfrac |
Fractional latency |
dmat * | ap | |
dmat * | ep | |
real | dt | |
sho_t * | sho |
struct sho_t |
union servo_t.__unnamed__ |
union servo_t.__unnamed__ |
dcell* servo_optim | ( | real | dt, |
long | dtrat, | ||
real | al, | ||
real | pmargin, | ||
real | f0, | ||
real | zeta, | ||
int | servo_type, | ||
const dmat * | psdin, | ||
const dmat * | sigma2n | ||
) |
Optimize the servo gains by balancing errors due to noise and signal propagation.
Written: 2010-06-11
Tested OK: 2010-06-11
2011-01-17: The optimization process is quite slow, but the result is only dependent on the sigma2n and fs. psdin does not change during the simulation. Built a lookup table in skyc using various sigma2n and interpolate to get ress, resn, and gain.
2012-03-28: Cleaned up this routine. groupped similar calculations together. Change g2=a from g=sqrt(a)
2013-06-27: The maximum gain should not be limited to 0.5 beause it is later scaled by sqrt(a);
sigma2n is a dmat array of all wanted sigma2n. Returns a zfarray of a dmat of [g0, a, T, res_sig, res_n]
The upper end of frequency must be nyquist freq so that noise transfer can be computed. But we need to capture the turbulence PSD beyond nyquist freq, which are uncorrectable.
2022-03-04: added SHO response parameter.
real servo_optim_margin | ( | real | dt, |
long | dtrat, | ||
real | al, | ||
real | pmargin, | ||
real | f0, | ||
real | zeta | ||
) |
Optimize integrator control with optional SHO response (output) to have correct phase margin (pi/4) when abs(Hol)==1.
Convert Closed loop residual PSD back to OL psd using rejection transfer function: PSD_OL=PSD_CL/Hrej-sigma2n/F_nyquist; Only implemented for integrator.
real servo_residual | ( | real * | noise_amp, |
const dmat * | psdin, | ||
real | dt, | ||
long | dtrat, | ||
real | al, | ||
const dmat * | gain, | ||
int | servo_type | ||
) |
Compute the residual error after servo rejection of a type II servo given the gain.
Written: 2010-06-11
Tested OK: 2010-06-11
Initialize servo_t. al is additional latency
servo_t* servo_new_scalar | ( | anyarray | merr, |
real | ap, | ||
real | al, | ||
real | dt, | ||
real | ep | ||
) |
Initialize servo_t with scalar ap and ep
servo_t* servo_new_sho | ( | anyarray | merr, |
const dmat * | ap, | ||
real | al, | ||
real | dt, | ||
const dmat * | ep, | ||
real | f0, | ||
real | zeta | ||
) |
Initialize servo_t with an sho
int servo_filter | ( | servo_t * | st, |
const anyarray | _merr | ||
) |
Applies type I or type II filter based on number of entries in gain.
void servo_add | ( | servo_t * | st, |
const anyarray | madj, | ||
real | alpha | ||
) |
Adjust integrator content without shift.
void servo_output | ( | const servo_t * | st, |
panyarray | out_ | ||
) |
Create servo output. It handles st->alfrac. and outputs the averaged position over the integration period.
test type I/II filter with ideal measurement to make sure it is implemented correctly.
void servo_reset | ( | servo_t * | st | ) |
reset the data to 0.
sho_t* sho_new | ( | real | f0, |
real | zeta | ||
) |
Second harmonic oscillator. Initialization. Equation is is d^x/dt^2+c1*dx/dt+c2*x=c2*xi State space model is |x'|' | -c1 -c2 | |x'| |xi| |x | = | 1 0 | | x| + c2 |0 | where x' is dx/dt and written as dx in struct. we use c2*xi so that it is in the same unit and scale as x.
f0 | Resonance frequency |
zeta | Damping |
void sho_step | ( | panyarray | xout_, |
sho_t * | sho, | ||
anyarray | xi_, | ||
real | dt, | ||
int | avg | ||
) |
Second harmonic oscillator state space update. xi is driving position.
Second harmonic oscillator state space update. xi is driving position. Update the position after time dt. Also compute the average position between 0 and dt (for WFS integration) if avg is set.
sho->x +=dt*sho->dx;//update position ddx=sho->dx*(-sho->c1)+sho->x*(-sho->c2)+xi;//update speed sho->dx+=dt*ddx; //update speed
void sho_reset | ( | sho_t * | sho | ) |
Second harmonic oscillator. Reset.