src/Bloch/BlochSys.cc
BlochSys::BlochSys(const spin_system& sys, const RBasic& Rs)
  {
  int ns       = sys.spins();			// Number of spins
  if(!CheckSpins(ns, Rs.spins())) BSfatal(29);	// Check spin count matches
  gen_op H     = How(sys);			// Isotropic Hamiltonian
  gen_op sigma = Fx(sys);			// System total Fx operator
  gen_op D;					// Detection operator
  double mag;					// |M> intensity
  TTable1D TT;					// Transitions table
  int i,j,k;					// Dummy indices
  std::vector<MagVec> Ms;				// Vector of |M>s
  MagVec M;					// Single vector |M>
  int nc, NC=0;					// Components 
  for(i=0; i<ns; i++)				// Loop over all spins
    {
    D = Fm(sys, i);				//   Detect F- spin i
    acquire1D Acq(D, H);			//   Set up acquisition
    TT = Acq.table(sigma);			//   Find all transitions  
    nc = TT.size();				//   Number of transitions
    NC += nc;					//   Total # of transitions
    M = MagVec(nc);				//   Initialize |M>
    for(j=0; j<TT.size(); j++)			//   Loop transitions
      {
      Offsets.push_back(TT.Fr(j));		//     Set offset
      isotopes.push_back(sys.isotope(i));	//     Set spin type
      R1rates.push_back(Rs.R1(i));		//     Set R1 rate
      R2rates.push_back(Rs.R2(i));		//     Set R2 rate
      mag = norm(TT.I(j));			//     Set norm
      M.put(mag, 3*j+2);			//     Sub-vector @ (0,0,mag)
      Spins.push_back(i);			//     Set spin
      }
    Ms.push_back(M);				// Store |M> this spin
    }
  _M = MagVec(NC);				// Concatonated |M>
  for(i=0, k=0; i<ns; i++)
    {
    nc = Ms[i].NComps();
    for(j=0; j<nc; j++, k++)
      _M.put(Ms[i].Mz(j), 3*k+2);
    }
  int nm  = Offsets.size();			// Number of mag. vectors
  int nex = (nm*nm-nm)/2;			// Number of exchange rates 
  Krates  = std::vector<double>  (nex, 0);		// Array of exchange rates
  }
/* The spin system will be assumed to be weakly coupled! In this manner it is
   easier to determine which transitions are associated with which spins.    */
The spin system will be assumed to be weakly coupled. In this manner it is
easier to determine which transitions are associated with which spins.
The spin system will be assumed to be weakly coupled . In this manner it is easier to determine which transitions are associated with which spins .
BlochSys::BlochSys(const spin_system& sys, const RBasic& Rs)
  {
  int ns       = sys.spins();			
  if(!CheckSpins(ns, Rs.spins())) BSfatal(29);	
  gen_op H     = How(sys);			
  gen_op sigma = Fx(sys);			
  gen_op D;					
  double mag;					
  TTable1D TT;					
  int i,j,k;					
  std::vector<MagVec> Ms;				
  MagVec M;					
  int nc, NC=0;					
  for(i=0; i<ns; i++)				
    {
    D = Fm(sys, i);				
    acquire1D Acq(D, H);			
    TT = Acq.table(sigma);			
    nc = TT.size();				
    NC += nc;					
    M = MagVec(nc);				
    for(j=0; j<TT.size(); j++)			
      {
      Offsets.push_back(TT.Fr(j));		
      isotopes.push_back(sys.isotope(i));	
      R1rates.push_back(Rs.R1(i));		
      R2rates.push_back(Rs.R2(i));		
      mag = norm(TT.I(j));			
      M.put(mag, 3*j+2);			
      Spins.push_back(i);			
      }
    Ms.push_back(M);				
    }
  _M = MagVec(NC);				
  for(i=0, k=0; i<ns; i++)
    {
    nc = Ms[i].NComps();
    for(j=0; j<nc; j++, k++)
      _M.put(Ms[i].Mz(j), 3*k+2);
    }
  int nm  = Offsets.size();			
  int nex = (nm*nm-nm)/2;			
  Krates  = std::vector<double>  (nex, 0);		
  }
BlochSys :: BlochSys ( const spin_system & sys , const RBasic & Rs ) { int ns = sys . spins ( ) ; if ( ! CheckSpins ( ns , Rs . spins ( ) ) ) BSfatal ( 29 ) ; gen_op H = How ( sys ) ; gen_op sigma = Fx ( sys ) ; gen_op D ; double mag ; TTable1D TT ; int i , j , k ; std :: vector < MagVec > Ms ; MagVec M ; int nc , NC = 0 ; for ( i = 0 ; i < ns ; i ++ ) { D = Fm ( sys , i ) ; acquire1D Acq ( D , H ) ; TT = Acq . table ( sigma ) ; nc = TT . size ( ) ; NC += nc ; M = MagVec ( nc ) ; for ( j = 0 ; j < TT . size ( ) ; j ++ ) { Offsets . push_back ( TT . Fr ( j ) ) ; isotopes . push_back ( sys . isotope ( i ) ) ; R1rates . push_back ( Rs . R1 ( i ) ) ; R2rates . push_back ( Rs . R2 ( i ) ) ; mag = norm ( TT . I ( j ) ) ; M . put ( mag , 3 * j + 2 ) ; Spins . push_back ( i ) ; } Ms . push_back ( M ) ; } _M = MagVec ( NC ) ; for ( i = 0 , k = 0 ; i < ns ; i ++ ) { nc = Ms [ i ] . NComps ( ) ; for ( j = 0 ; j < nc ; j ++ , k ++ ) _M . put ( Ms [ i ] . Mz ( j ) , 3 * k + 2 ) ; } int nm = Offsets . size ( ) ; int nex = ( nm * nm - nm ) / 2 ; Krates = std :: vector < double > ( nex , 0 ) ; }
The spin system will be assumed to be weakly coupled!
The spin system will be assumed to be weakly coupled!
// Number of spins // Check spin count matches // Isotropic Hamiltonian // System total Fx operator // Detection operator // |M> intensity // Transitions table // Dummy indices // Vector of |M>s // Single vector |M> // Components  // Loop over all spins //   Detect F- spin i //   Set up acquisition //   Find all transitions   //   Number of transitions //   Total # of transitions //   Initialize |M> //   Loop transitions //     Set offset //     Set spin type //     Set R1 rate //     Set R2 rate //     Set norm //     Sub-vector @ (0,0,mag) //     Set spin // Store |M> this spin // Concatonated |M> // Number of mag. vectors // Number of exchange rates  // Array of exchange rates