Changeset 32 in TRACY3 for trunk/tracy/tracy/src/nsls-ii_lib.cc


Ignore:
Timestamp:
Apr 9, 2014, 3:50:11 PM (10 years ago)
Author:
zhangj
Message:

active the transport of the twiss functions and orbits of the transfer line.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tracy/tracy/src/nsls-ii_lib.cc

    r11 r32  
    763763                      1.5  sextupole
    764764                      2.0  bpm
    765       Fnum        family index
     765      Fnum        family index of the BPM.
    766766      all         true, print the cod at all elements
    767                   false, print the cod at the family elements
     767                  false, print the cod at the BPM elements, the name of the BPM must be defined in the "*.prm" file.
    768768   Output:
    769769       none
     
    784784void prt_cod(const char *file_name, const int Fnum, const bool all)
    785785{
    786   long      i;
     786  long      i=0L;
    787787  double    code = 0.0;
    788788  FILE      *outf;
    789   long      FORLIM;
     789  long      FORLIM=0L;
    790790  struct    tm *newtime;
    791791
     
    828828      }
    829829      /* COD is in local coordinates */
    830       fprintf(outf, "%4ld %.*s %6.2f %4.1f %6.3f %6.3f %6.3f %6.3f"
    831               " %6.3f %6.3f %6.3f %6.3f %6.3f %6.3f\n",
     830      fprintf(outf, "%4ld %.*s %6.2f %4.1f %6.4f %6.4f %6.4f %6.4f"
     831              " %6.4f %6.4f %6.4f %6.4f %6.4f %6.4f\n",
    832832              i, SymbolLength, Cell[i].Elem.PName, Cell[i].S, code,
    833833              Cell[i].Beta[X_], Cell[i].Nu[X_],
     
    842842}
    843843
     844/****************************************************************
     845 * void prt_beampos(const char *file_name)
     846 *
     847 *  print the orbits at all lattice elements.
     848 *
     849 * Comments:   
     850 *     To use this command, the BPM name should be defined in the
     851 *  "*.prm" file with the command
     852 *                bpm_name   BPM_names
     853 *
     854 *
     855 ****************************************************************/
    844856
    845857void prt_beampos(const char *file_name)
    846858{
    847   int       k;
     859  int       i=0;
    848860  ofstream  outf;
    849861
    850862  file_wr(outf, file_name);
    851863
    852   outf << "# k  s  name x   px    y   py   delta ct" << endl;
     864  outf << "#   i     name              s[m]     x[mm]   px    y[mm]   py   delta ct" << endl;
    853865  outf << "#" << endl;
    854866
    855   for (k = 0; k <= globval.Cell_nLoc; k++)
    856     outf << scientific << setprecision(5)
    857          << setw(5) << k << setw(11) << Cell[k].Elem.PName
    858          << setw(13) << Cell[k].BeamPos << endl;
    859 
     867 
     868  for (i = 0; i <= globval.Cell_nLoc; i++){
     869   if (Cell[i].Fnum == globval.bpm)
     870        outf << scientific << setprecision(4)
     871          << setw(5) << i << setw(20) << Cell[i].Elem.PName
     872          << setw(5) << Cell[i].S
     873          << setw(13) << Cell[i].BeamPos*1e3 << endl;
     874  }     
    860875  outf.close();
    861876}
     
    874889  // the dT and roll angle are all printed out
    875890{
    876   int i,j;
    877   int  n_girders;
    878   int  gs_Fnum, ge_Fnum;
    879   int  gs_nKid, ge_nKid;
    880   int  dip_Fnum,dip_nKid;
    881   int  loc, loc_gs, loc_ge;
     891  int i=0,j=0;
     892  int  n_girders=0;
     893  int  gs_Fnum=0, ge_Fnum=0;
     894  int  gs_nKid=0, ge_nKid=0;
     895  int  dip_Fnum=0,dip_nKid=0;
     896  int  loc=0, loc_gs=0, loc_ge=0;
    882897  char * name;
    883   double s;
     898  double s=0.0;
    884899  double PdSsys[2], PdSrms[2], PdSrnd[2], dS[2], dT[2];
    885900  fstream fout;
     
    52855300  Purpose:
    52865301           Calculate momentum compact factor up to third order.
    5287            Method:
    5288            track the orbit offset c*tau at the first element,
    5289            at 11 different energy offset(-10-3 to 10-3), then
    5290            use polynomal to fit the momentum compact faction factor
    5291            up to 3rd order.
    5292            The initial coorinates are (x_co,px_co,y_co,py_co,delta,0).
    5293            
     5302           Method:
     5303           track the orbit offset c*tau at the first element,
     5304           at 11 different energy offset(-10-3 to 10-3), then
     5305           use polynomal to fit the momentum compact faction factor
     5306           up to 3rd order.
     5307          The initial coorinates are (x_co,px_co,y_co,py_co,delta,0).
     5308          
    52945309 Input:
    52955310       none
     
    53075322       change the initial coorinates from (0 0 0 0 delta 0) to
    53085323              (x_co,px_co,y_co,py_co,delta,0).  i.e., track
    5309               around the off-momentum close orbit but not zero orbit.     
     5324       around the off-momentum close orbit but not zero orbit.     
    53105325
    53115326*******************************************************************/
     
    53205335 //const double  d_delta  = 1e-4;
    53215336
    5322   int       i, n;
    5323   long int  lastpos;  // last tracking position when the particle is stable
    5324   double    delta[2*n_points+1], alphac[2*n_points+1], sigma;
     5337  int       i=0, n=0;
     5338  long int  lastpos=0L;  // last tracking position when the particle is stable
     5339  double    delta[2*n_points+1], alphac[2*n_points+1], sigma=0.0;
    53255340  Vector    x, b;
    53265341  CellType  Cell;
    5327   bool      cod;
     5342  bool      cod=false;
    53285343 
    53295344  globval.pathlength = false;
    53305345  getelem(globval.Cell_nLoc, &Cell);
    5331   n = 0;
    53325346 
    53335347  for (i = -n_points; i <= n_points; i++) {
     
    53535367
    53545368
     5369/**********************************************************
     5370 * float f_bend(float b0L[])
     5371 *
     5372 *
     5373 *
     5374 **********************************************************/
    53555375float f_bend(float b0L[])
    53565376{
Note: See TracChangeset for help on using the changeset viewer.