src/Bloch/BlochSys.cc
/* These are protected functions because they allow specific aspects of the
   spin system to be set up without worrying about system consistency! There     
   are two ways to set up a Bloch system: A.) By specific magnetization vectors
   & B.) By a spin network.  While the former is more direct, the latter fits
   into a more generic GAMMA sheme for MR based simulations.

   Magnetization vectors: 1.) Number of vectors
                          2.) Frequency offset for each vector
                          3.) R1 & R2 rates for each vector
                          4.) Kex rates for each vector pair

   Spin system:           1.) A GAMMA spin system 
                              a. Number of spins
                              b. Chemical shifts
                              c. Scalar couplings
                          2.) R1 & R2 rates for each spin 
                          3.) Kex rates for each spin pair

   Since GAMMA spin systems are often used in programs, method B will be used
   preferentially. This will be indicated by parameter NSpins in typical spin
   system fashion. Failing to find NSpins, method A will be used & parameter
   NMagVecs will should indicate how many vectors are defined in the system. */
These are protected functions because they allow specific aspects of the
spin system to be set up without worrying about system consistency. There
are two ways to set up a Bloch system: A.) By specific magnetization vectors
& B.) By a spin network.  While the former is more direct, the latter fits
into a more generic GAMMA sheme for MR based simulations.

Magnetization vectors: 1.) Number of vectors
2.) Frequency offset for each vector
3.) R1 & R2 rates for each vector
4.) Kex rates for each vector pair

Spin system:           1.) A GAMMA spin system
a. Number of spins
b. Chemical shifts
c. Scalar couplings
2.) R1 & R2 rates for each spin
3.) Kex rates for each spin pair

Since GAMMA spin systems are often used in programs, method B will be used
preferentially. This will be indicated by parameter NSpins in typical spin
system fashion. Failing to find NSpins, method A will be used & parameter
NMagVecs will should indicate how many vectors are defined in the system.
These are protected functions because they allow specific aspects of the spin system to be set up without worrying about system consistency . There are two ways to set up a Bloch system : A . ) By specific magnetization vectors & B . ) By a spin network . While the former is more direct the latter fits into a more generic GAMMA sheme for MR based simulations . Magnetization vectors : 1 . ) Number of vectors 2 . ) Frequency offset for each vector 3 . ) R1 & R2 rates for each vector 4 . ) Kex rates for each vector pair Spin system : 1 . ) A GAMMA spin system a . Number of spins b . Chemical shifts c . Scalar couplings 2 . ) R1 & R2 rates for each spin 3 . ) Kex rates for each spin pair Since GAMMA spin systems are often used in programs method B will be used preferentially . This will be indicated by parameter NSpins in typical spin system fashion . Failing to find NSpins method A will be used & parameter NMagVecs will should indicate how many vectors are defined in the system .
bool BlochSys::SetSystem(const ParameterSet& pset, int idx, bool warn)
  {
  ParameterSet  subpset;                        
  if(idx != -1) subpset = pset.strip(idx);      
  else          subpset = pset;                 
  Offsets.clear();				
  R1rates.clear();				
  R2rates.clear();				
  isotopes.clear();				
  Krates.clear();				
  Spins.clear();				
  _M = MagVec();				
  int nm;					
  if(!GetNVects(subpset, nm, false))		
    {						
    if(!GetNSpins(subpset, nm, false))		
      {						
      if(warn) BSerror(56, 1);			
      if(warn) BSerror(102, "NMagVects", 1);	
      if(warn) BSerror(102, "NSpins", 1);	
      if(warn) BSerror(40, 1);			
      return false;				
      }
    }
  if(!_M.SetSubVects(pset,nm,true))		
    {						
    if(warn) BSerror(40, 1);			
    return false;				
    }
  if(!SetVects(subpset, nm, warn))		
    {						
    if(warn) BSerror(40, 1);			
    return false;				
    }
  SetExchange(subpset, nm, false);		
  return true;					
  }
bool BlochSys :: SetSystem ( const ParameterSet & pset , int idx , bool warn ) { ParameterSet subpset ; if ( idx != -1 ) subpset = pset . strip ( idx ) ; else subpset = pset ; Offsets . clear ( ) ; R1rates . clear ( ) ; R2rates . clear ( ) ; isotopes . clear ( ) ; Krates . clear ( ) ; Spins . clear ( ) ; _M = MagVec ( ) ; int nm ; if ( ! GetNVects ( subpset , nm , false ) ) { if ( ! GetNSpins ( subpset , nm , false ) ) { if ( warn ) BSerror ( 56 , 1 ) ; if ( warn ) BSerror ( 102 , " " , 1 ) ; if ( warn ) BSerror ( 102 , " " , 1 ) ; if ( warn ) BSerror ( 40 , 1 ) ; return false ; } } if ( ! _M . SetSubVects ( pset , nm , true ) ) { if ( warn ) BSerror ( 40 , 1 ) ; return false ; } if ( ! SetVects ( subpset , nm , warn ) ) { if ( warn ) BSerror ( 40 , 1 ) ; return false ; } SetExchange ( subpset , nm , false ) ; return true ; }
These are protected functions because they allow specific aspects of the
spin system to be set up without worrying about system consistency!
These are protected functions because they allow specific aspects of the spin system to be set up without worrying about system consistency!
//               Filter Out Parameters With Prefix [idx] // Working parameter set // Get only params with [#] // Or use full pset //                    Zero Current Bloch System // Set chemical shift // Set R1 rate // Set R2 rate // Set isotope // No exchange rates // No vector spins // Zero mag vector //               Read Number Of Sub-Vectors In System // For # spins or vectors // If # vectors not found // look for # of spins //   If # spins not found //   we are in trouble //     Warn no # mag vects //     Warn no # mag vects //     Warn no # mag vects //     Warn not enough params //     Return we failed //                    Read Magnetization Vector // Try to read |M> in // If that fails //   Warn insufficient params //   Return we failed //                    Read System Vector Quatities // Set up nm vectors // If that fails //   Warn insufficient params //   Return we failed // Set nex exchange rates // Didn't set things up