Products 06 & 07: Moments  
 DESC: 	Product #06  1-species (proton) momenta.
 	Product #07  4-species (proton, He+, alphas, O+) momenta.  
 HIST: 	01-21-93  JLC  	Created file
       	01-25-93  JLC  	Removed table definitions to tbl.asm
       	04-01-93  JLC  	modified test program for FM software
       	05-13-93  JLC  	Overhauled file to embed into FM/CRTOS.
       	07-19-93  JLC  	Finished converting module to product task
       	08-01-93  JLC  	Corrected various minor bugs still hangin'round.
       	08-16-93  JLC  	Final walk through and commenting
       	03-03-94  JLC  	finished re-structuring and mod's per 
                       	scientific review
       	03-09-94  JLC  	further mod's for new struc debug and 
                        Product 09 support
       	95-01-30  CAI  	Fix bug which stopped prod after 1 spin. v1.53
       	95-08-16  CAI  	Fix UPD_MOM loop control; fix IT4-7 save
                        order; add anode efficiency factors. v1.83
       	95-08-23  DWC   Removed single RAM based energy table f(v); 
                      	Use opmode sweep selection criteria to select 
                      	one of two energy tables from vectors in opmode 
                     	table; add energy efficiency term
       	95-09-30  DWC   Change anode eff to separate tables by mass
       	95-08-31  DWC   Change anode eff to separate by hi/lo sens
                      	Offset energy ranges to skip first energy step
       	95-09-05  CAI  	Offset energy ranges to skip last e-step. v1.86
       	95-09-09  CAI  	Adj sweep A/B index offset in UPD_MOM. v1.88
       	95-11-13  CAI  	Update memory use comments.
       	95-11-22  CAI  	Fix r12 setup for MS_TIMOUT. v1.92
       	96-01-13  CAI  	Implement 16-level prioritized tlm queues. v1.94
       	96-02-29  CAI  	Update P09 summation parameters to: 4 sweeps 
                      	180 degrees opposite sweep_b_i, and 4 anodes 
                      	2, 3, 4, & 5. v2.05
       	96-03-20  CAI  	Fix ER_t bug which blocked counts from 3rd energy 
                      	range. v2.05
       	96-03-21  CAI  	Add tlm pkt timeout error post. v2.05
       	96-04-22  CAI  	Update P09 summation parameters to 45x45 deg: 
                      	4 sweeps 180 degrees opposite sweep_b_i, and 
                      	anodes 3 & 4 (of 0-7). v2.07
       	96-04-24  CAI  	Change sweep_b_i to SRP-relative; change P09
                      	beg/end indices from sectors to sweeps. v2.07
         
 	96-06-07  AMD   Ported the code to ESIC. Introduced interleaved mass
                        momenta computation (1 mass at time) both for P6/P7
                        for each 22.5 deg sweep. P7, 4-species, covers the full
                        phase space after 4 spins. Revised PX_ER_t  into a  more 
		 	general info tables P06_Inf_T / P07_Inf_T. 
			Code differences were marked by __$$ as usual.
       	97-01-24  AMD   Fixed a bug concerning right energy band updating
       	97-03-04  AMD   Fixed a bug concerning trig tables ptr updtating (r14)
       	97-22-07  AMD   Added odd/even energy computation
       	97-25-07  AMD   Changed the interleaved mass computation into 1mass/1sp
       	97-03-09  AMD   Add dummy burst memory trigger evaluation to MOM_SUBT.
                      	$2.26
       	97-09-10  AMD   Considered odd spin only for SM trigger evaluation $2.27
                      	(see MOM_TRGR)  
NOTE: PRODUCT GENERATION
         
       The following Moments are computed across 3 energy ranges 
       for 4 masses:  
          * Density (N)
          * Bulk Velocity (Vx, Vy, Vz)
          * Heat Flux Vector (Hx, Hy, Hz)
          * Pressure Tensor (Pxx, Pyy, Pzz, Pxy, Pxz, Pyz)  
       Which results in 12 (3Ex4M) sets of 13 moment values (156 
       values) computed and summed in floating point format and 
       then compressed to 12-bits and packed into 16-bit words 
       (117 words).  Moment products are computed using the 
       following algorithm:  
     [ Product 06/07 ]  
       For sixteen 22.5-degree Energy Sweeps (full spin), 
       summing 8 anodes  
     [ Product XX ]
     For two 22.5-degree Energy Sweeps when running the
       RPA sweeps, summing only anodes TBD  
     [ both products ]  
       For Each Energy Step (assigned to three buckets - see P6/7_Inf_T),
          Compute phi-based intermediate (IP) values (see below)
          For Each Mass (at a specific energy step)
              Compute theta-based intermediate (IT) values (see below)
              Update Vz (bulk velocity) 
                 and Hz (heat flux vector)
              Update Pxz and Pyz (pressure tensor)
              Update N (density)
              Update Vx, Vy (bulk velocity), 
                 and Hx, Hy (Heat flux vector)
              Update Pxx, Pyy, and Pxy (pressure tensor)
              Update Pzz (pressure tensor)  
       Computing the theta-based intermediate values entails 
       summing the product of each anode counter and a trig 
       function (depending on moment being computed).  Anodes and 
       corresponding theta angles are shown below:  
          Anode 0 = 78.75 degress     Anode 7 = -78.75 degress
          Anode 1 = 56.25 degress     Anode 6 = -56.25 degress
          Anode 2 = 33.75 degress     Anode 5 = -33.75 degress
          Anode 3 = 11.25 degress     Anode 4 = -11.25 degress  
       (?? Being changed to floating point with efficiency factors.  
       950817:)
       The summing of the trig/counter products is performed in fixed 
       point math with 17-bits integer and 15 bits fraction.  The 
       theta trig functions are look-up tables with 16-bit fixed 
       point values - 15 bits of fraction, multiplied by a 16-bit 
       integer counter value resulting in a 32-bit sum (17-bits 
       integer, 15 bits fraction.  The 16 LS-bits of the integer 
       portion is then converted to single precision floating point.  
       "Updating" a moment value entails multiplying the trig/
       counter product sum by a phi-based intermediate value 
       (velocity vector and/or a phi-based trig function 
       multiplied).  All computation after the counter/trig
       multiply and addition outlined above is performed in single-
       precision floating point.
  
       MOMENT EQUATIONS
         
       The algorithm above uses the following equations for each 
       moment update:  
       Density:
          N   += 1/V * C[t,p,e]  
       Bulk Velocity:
          Vx  += cos(p) * SUM( cos(t) * C[t,p,e] )
          Vy  += sin(p) * SUM( cos(t) * C[t,p,e] )
          Vz  += SUM( sin(t) * C[t,p,e] )  
       Heat Flux Vector:
          Hx  += V^2 * cos(p) * SUM( cos(t) * C[t,p,e] )
          Hy  += V^2 * sin(p) * SUM( cos(t) * C[t,p,e] )
          Hz  += V^2 * tSUM( sin(t) * C[t,p,e] )  
       Pressure Tensor:
          Pxx += V * cos^2(p) * SUM( cos^2(t) * C[t,p,e] )
          Pyy += V * sin^2(p) * SUM( cos^2(t) * C[t,p,e] )
          Pzz += V * SUM( sin^2(t) * C[t,p,e] )
          Pxy += V * cos*sin(p) * SUM( cos^2(t) * C[t,p,e] )
          Pxz += V * cos(p) * SUM( cos*sin(t) * C[t,p,e] )
          Pyz += V * sin(p) * SUM( cos*sin(t) * C[t,p,e] )  
       Where,
          t = theta (anode) angle
          p = phi (spin) angle
          e = energy step index (0..31)
          V = velocity (indexed by energy step number)
          C = counter buf (indexed by theta, phi, and energy index)
              Multiplied by an anode efficiency factor F(t), and an
              energy efficiency factor, F(e,m)
          SUM = sum of specified function over all 8 thetas  
       PHI INTERMEDIATE VALUES  
       An index into the phi (spin angle) tables is updated 
       for each energy step of each sweep throughout the entire 
       spin.  The Intermediate Phi products are computed at each 
       energy step as follows (where e=energy_step_index, 
       p=phi_spin_angle):  
          IP0 = V^2[e] * cos(p)      IP4 = V[e] * cos(p) * sin(p)
          IP1 = V^2[e] * sin(p)      IP5 = V[e] * cos(p)
          IP2 = V[e] * cos^2(p)      IP6 = V[e] * sin(p)
          IP3 = V[e] * sin^2(p)  
       The counters are read every 22.5 degrees.   
       THETA INTERMEDIATE VALUES
        
       The theta (anode) intermediate values are updated for each 
       energy step of each sweep throughout the entire spin.  These 
       intermediate values are used by several different moment 
       calculations.    
       The symmetry of the trig multiplication and summations then 
       allow the software to save half of the potential 16x32 
       multiplies per energy step.  The IT Values are:  
          ODD:                  EVEN:
          -----------------     -----------------
          IT0 = Ctr0 - Ctr7     IT4 = Ctr0 + Ctr7
          IT1 = Ctr1 - Ctr6     IT5 = Ctr1 + Ctr6
          IT2 = Ctr2 - Ctr5     IT6 = Ctr2 + Ctr5
          IT3 = Ctr3 - Ctr4     IT7 = Ctr3 + Ctr4  
       Thus, counter summations of the form:  
                   (Sin(+78)*Ctr0) + (Sin(-78)*Ctr7) +
                   (Sin(+56)*Ctr1) + (Sin(-56)*Ctr6) + ...  
       can be simplified to:  
            (Sin(+78)*(Ctr0-Ctr7)) + (Sin(+56)*(Ctr1-Ctr6)) + ...  
       or:
                       Sin(78)*IT0 + Sin(56)*IT1 + ...  
       which has half as many multiplies.  The difference between 
       IT0 and IT4, or IT1 and IT5 ,..., is the symmetry of the 
       trig function.  Odd trig functions use IT0 through IT3, 
       and even functions use IT4 through IT7.  
       COUNTER BUFFER  
       The counter buffer (ctr_b) supplied by the code in cis.asm 
       is structured as 32 energy sets of 4 mass sets of 8 theta 
       values, as follows:  
          Buffer                    Theta
          Offset   E-Step   Mass   (Anode)
          ------   ------   ----    -----
             0        0       0       0
             1        0       0       1
             2        0       0       2
           ...       ...     ...     ...
             7        0       0       7          Masses #1 and #2  
             8        0       2       0   <---   are out of numer- 
             9        0       2       1       |  ical order in the 
           ...       ...     ...     ...      |- buffer.  This is  
            15        0       2       7       |  caused by the     
            16        0       1       0   <---   comparator/counter
            17        0       1       1          wiring.           
           ...       ...     ...     ...
            30        0       3       6
            31        0       3       7
            32        1       0       0
            33        1       0       1
           ...       ...     ...     ...
          1021       31       3       5
          1022       31       3       6
          1023       31       3       7
  
       MEMORY USE
         
       The summation buffer memory is reused for the telemetry 
       packet buffer.  In addition four words are allocated just 
       before the summation buffer for a 2-word packet handling 
       structure and 2-word packet header.  Memory use is:  
            Length
           (words)   Description
            ------   ---------------
                2    packet handling structure
                2    packet header
              312    summation buffer
            ------   
              316    total per product buffer
               53    product variables
               27    sub-task tss
            ------
              396    Allocation for 1st buffer
               27    task tss (at prod task creation)
            ------
              423    Total allocation for 1-buffer product
              316    Allocation for 2nd buffer
            ------
              739    Total allocation for 2-buffer product  
SAMPLING MODES
Mass Interleaved mode:  up to Ver. $2.23

The on-board software is able to compute one mass momenta contribute per
sweep for each momenta product P6 or P7. Therefore, in case of P7, just a quarter 
of the phase space is covered in one spin if all together the 4 species are considered.Being 16 (sweeps) a multiple of 4 (species) is necessary to change once per spin the selected mass on which the moments are computed, otherwise some azimuthal gap will appear in the azimuthal coverage.
This is controlled by a dedicated  mass modulo 4 counter which is reset at P7 creation and next incremented for each sweep. As soon as 16 (one spin) is reached the current mass # is incremented by 2 insted of one.

Odd/even energies mode: since Ver. $ 2.24
Due to the lack of computational resource computations have  been  modified
to be able to perform the momenta computations by skipping odd/even energy ac-
cording to the spin number at the time of the data collection starting.
The dedicated var SPIN_EOV will be reset to 1 or 0 according to the LSB bit 
of the spin. During each spin collection the bit will be toggled. The status of the 
bit will correspond to odd (1) energies or (0) energies steps collection. Note
that this collection is independently from the entry energy step put in the
energy range tables P6_Inf_T or P7_Inf_T.
Mass inteleaved mode suppression: since   Ver $ 2.27 

Full one mass per spin computation has been preferred for P7. Note that this
has been simply achieved by placing a comment to the mass register setting instruction which holds the selected mass to be updated. A 'nop' instruct. has been left in the code to be able to switch back to the previous interleaved mode which performs the mass average over 4 spins by a simple S/W patch.

 MOMENT SUM BUFFER ALLOCATION SIZE
 The moment summation buffer size is 156 (3x4x13) floating values, 
 or 312 words.  This memory space is reused for the packet 
 data to conserve RAM use.  Thus 4 additional words must be 
 allocated to store a 2-word packet processing structure plus a 
 2-word packet header just before the sum buffer.

 


TLM tables ] Diag events ] Mag field ] [ Moments ] 3D Mass ] 3D distributions ] 3D compr ] Scrtch Pxs ]

Home Page