src/HSLib/SpinSystem.cc
/* This function attempts to determine the chemical shift for each nucleus in
   the system. The shift may be set in Hz or in PPM, the latter being valid
   only if a field strength has been set. Electrons do not have shifts assigned.
   Instead, electrons will have an istropic g factor. Prior to calling this
   function the number of spins should be known. So should the field strength
   and any isotope labels be set.

         Omega       - Proton Larmor frequency (MHz)
       * GOmega      - EPR base frequency      (GHz)
         Field       - Bo field strength       (Gauss)
         FieldT      - Bo Field strength       (Tesla)

   All parameters are allowed only if there spin is a nucleus.
   * parameters are allowed only if the Bo field has been set
 
        // Input                ssys    : A spin system (this)
        //                      pset    : A parameter set
        // Output               none    : Spin system isotropic shifts
        //                                are set from parameters in pset
	// Note				: If the system spectrometer
	//				  frequency is not present, PPM
	//				  shifts are disabled
	// Note				: Isotope labels should be set
	//				  prior to calling this function!
	//				: Electrons will not have any shifts
	//				  set from this function             */
This function attempts to determine the chemical shift for each nucleus in
the system. The shift may be set in Hz or in PPM, the latter being valid
only if a field strength has been set. Electrons do not have shifts assigned.
Instead, electrons will have an istropic g factor. Prior to calling this
function the number of spins should be known. So should the field strength
and any isotope labels be set.

Omega       - Proton Larmor frequency (MHz)
GOmega      - EPR base frequency      (GHz)
Field       - Bo field strength       (Gauss)
FieldT      - Bo Field strength       (Tesla)

All parameters are allowed only if there spin is a nucleus.
parameters are allowed only if the Bo field has been set


This function attempts to determine the chemical shift for each nucleus in the system . The shift may be set in Hz or in PPM the latter being valid only if a field strength has been set . Electrons do not have shifts assigned . Instead electrons will have an istropic g factor . Prior to calling this function the number of spins should be known . So should the field strength and any isotope labels be set . Omega - Proton Larmor frequency ( MHz ) GOmega - EPR base frequency ( GHz ) Field - Bo field strength ( Gauss ) FieldT - Bo Field strength ( Tesla ) All parameters are allowed only if there spin is a nucleus . parameters are allowed only if the Bo field has been set
void spin_system::setShifts(const ParameterSet& pset)
  {
  int ns = spins();			
  std::vector<int> inPPM(ns, 0);	
  std::string Pst("PPM(");		
  std::string Pfi(")");			
  ParameterSet::const_iterator item;	
  int i, notfound = ns;			
  std::string pname, pst;			
  double dval;				
  if(Omega())				
    {
    for(i=0; i<ns; i++)			
      { 				
      if(!electron(i))			
        {
        pname = Pst + Gdec(i) + Pfi; 	
        item = pset.seek(pname);	
        if(item != pset.end())		
          {
          (*item).parse(pname,dval,pst);
          PPM(i, dval);			
          inPPM[i] = 1;			
          notfound--;			
          }				
        }
      }
    }
  std::string Pstv = "v("; 		
  for(i=0; i<ns; i++)			
    { 					
    if(!inPPM[i] && !electron(i))	
      {
      pname = Pstv + Gdec(i) + Pfi; 	
      item = pset.seek(pname);		
      if(item != pset.end()) 		
        {
        (*item).parse(pname,dval,pst);
        shift(i, dval);			
        inPPM[i] = -1;			
        notfound--;			
        }
      }
    }
  for(i=0; i<ns; i++)			
    if(!inPPM[i] && electron(i))	
      {
      notfound--;			
      inPPM[i] = 2;			
      cshifts[i] = 0;			
      }
  std::string serr;
  if(notfound <= 1) return;		
  if(!warnings()) return;		
  int j=0;			
  for(i=0; i<ns; i++)			
    {
    j++;
    if(j==1 && !inPPM[i])		
      { 				
      if(Omega())			
        {				
        serr = Pst + Gdec(i) + Pfi; 	
        serr += std::string(" nor ");
        serr += pname = Pstv + Gdec(i) + Pfi;
        SYSTerror(104, pname, 1);
        }
      else
        {
        pname = Pstv + Gdec(i) + Pfi;
        SYSTerror(104, pname, 1);
        }
      }
    else if(!inPPM[i])			
      {					
      if(Omega())			
        {				
        pname = Pst + Gdec(i) + Pfi; 	
        std::cout << "; " << pname;
        pname = Pstv + Gdec(i) + Pfi;
        std::cout << " nor " << pname;
        }
      else
        {
        pname = Pstv + Gdec(i) + Pfi;
        std::cout << "; " << pname;
        }
      if(j>=2 && Omega()) j=0;	
      else if(j>5) j=0; 		
      }
    }
  SYSTerror(8); 			
  }
void spin_system :: setShifts ( const ParameterSet & pset ) { int ns = spins ( ) ; std :: vector < int > inPPM ( ns , 0 ) ; std :: string Pst ( " " ) ; std :: string Pfi ( " " ) ; ParameterSet :: const_iterator item ; int i , notfound = ns ; std :: string pname , pst ; double dval ; if ( Omega ( ) ) { for ( i = 0 ; i < ns ; i ++ ) { if ( ! electron ( i ) ) { pname = Pst + Gdec ( i ) + Pfi ; item = pset . seek ( pname ) ; if ( item != pset . end ( ) ) { ( * item ) . parse ( pname , dval , pst ) ; PPM ( i , dval ) ; inPPM [ i ] = 1 ; notfound -- ; } } } } std :: string Pstv = " " ; for ( i = 0 ; i < ns ; i ++ ) { if ( ! inPPM [ i ] && ! electron ( i ) ) { pname = Pstv + Gdec ( i ) + Pfi ; item = pset . seek ( pname ) ; if ( item != pset . end ( ) ) { ( * item ) . parse ( pname , dval , pst ) ; shift ( i , dval ) ; inPPM [ i ] = -1 ; notfound -- ; } } } for ( i = 0 ; i < ns ; i ++ ) if ( ! inPPM [ i ] && electron ( i ) ) { notfound -- ; inPPM [ i ] = 2 ; cshifts [ i ] = 0 ; } std :: string serr ; if ( notfound <= 1 ) return ; if ( ! warnings ( ) ) return ; int j = 0 ; for ( i = 0 ; i < ns ; i ++ ) { j ++ ; if ( j == 1 && ! inPPM [ i ] ) { if ( Omega ( ) ) { serr = Pst + Gdec ( i ) + Pfi ; serr += std :: string ( " " ) ; serr += pname = Pstv + Gdec ( i ) + Pfi ; SYSTerror ( 104 , pname , 1 ) ; } else { pname = Pstv + Gdec ( i ) + Pfi ; SYSTerror ( 104 , pname , 1 ) ; } } else if ( ! inPPM [ i ] ) { if ( Omega ( ) ) { pname = Pst + Gdec ( i ) + Pfi ; std :: cout << " " << pname ; pname = Pstv + Gdec ( i ) + Pfi ; std :: cout << " " << pname ; } else { pname = Pstv + Gdec ( i ) + Pfi ; std :: cout << " " << pname ; } if ( j >= 2 && Omega ( ) ) j = 0 ; else if ( j > 5 ) j = 0 ; } } SYSTerror ( 8 ) ; }
This function attempts to determine the chemical shift for each nucleus in
the system.
This function attempts to determine the chemical shift for each nucleus in the system .
// Number of spins // Flag if shifts in PPM // Start of PPM parameter name // Finish of PPM param. names // A pix into parameter list // No. with no shift assinged // For parameter name & statement // For parameter value //	     First See If Shift Information Is Specified in PPM //             (All That Are Have PPM Values Set & Flagged) // Don't do if no Omega set // Attempt to retrieve the // chemical shifts in PPM // Look for shift in PPM (if not e-) // All shifts need not be present // Pix in parameter list for PPM(i) // Retrieve the number of spins // Parse out the value as double // Set shift in PPM // Flag that PPM units used // Decrement count of shifts // we don't know yet //	       See If Shift Information Is Specified in Hz  // Start/finish Hz param. names // Attempt to retrieve chemical // shifts in Hz. Only do this // if not input in PPM // All shifts need not be present // Pix in parameter list for v(i) // Retrieve the number of spins // Set the shift in Hz // Flag that this is found // Decrement not found count //	       See If Spins With No Shift Assigned Are Electrons // Attempt to retrieve chemical // if not input in PPM // Decrement not found count // Flag that (no) value is OK // Set electron shift to 0 //	       Now Output Warnings If Any Spins Not Shift Assigned  //		       (Only Done if Warnings Are Active) // Exit if all are found // Exit if warnings not wanted // Loop over shifts not set // 	Start a new line of //	parameter warnings // 	Output PPM(#) if Omega //	has been set and v(#) //	in all cases //	Continuation of line //	Output PPM(#) if Omega //	has been set and v(#) //	if Omega has been set //	in all cases // 	Flag that new line of warnings //	should start // Warning, unspecified shifts at 0 Hz