Skip to content
Snippets Groups Projects
Commit b94a01f6 authored by zhang's avatar zhang
Browse files

10/01/2011

1)
 Change SetErr( ) to SetErr2( )  which is delicated for the soleil lattice with two half quadrupoles.
Add SetErr( ) which is delicated for the lattice with full quadrupoles.
parent 31783afa
Branches
Tags
No related merge requests found
......@@ -9,7 +9,8 @@
*/
/**** Protypes ****/
void SetErr(long seed,double fac);
void SetErr2(long seed,double fac); //set error for lattice with two half quadrupoles
void SetErr(long seed,double fac); //set error for lattice with one full quadrupoles
void InducedAmplitude(long spos);
void Hfonction(long pos, double dP);
//void Hcofonction(long pos, double dP,Vector2 H);
......
......@@ -280,6 +280,7 @@ void Hcofonction(long pos, double dP)
Definir une distribution aleatoire de quadripoles tournes associee a chaque
quadripole de la machine
Distribution gaussienne d'ecart type fac et coupe a normcut*sigma
This function works for the lattice with full quadrupoles
Input:
seed: random seed number
......@@ -304,8 +305,82 @@ void Hcofonction(long pos, double dP)
Rotation inversion to do as in BETA code
Test if normal quad sin(theta) = 0. Do not work if tilt error
Modified by Jianfeng Zhang 19/01/2011 @soleil
****************************************************************************/
void SetErr(long seed,double fac)
{
double normcut = 0.0;
long i = 0L;
// CellType Cell;
double theta = 0.0;
bool prt=false;
if(!prt){
printf("\n");
printf(" Setting random rotation errors to quadrupole magnets:\n");
printf(" random seed number is: %ld, rms value of the rotation error is: %lf rad\n",seed,fac);
}
setrancut(normcut=2L);
iniranf(seed);
for (i = 1L; i <= globval.Cell_nLoc; i++)
{
if (Cell[i].Elem.Pkind == 2L)
{
if (Cell[i].Elem.M->Porder == 2L && Cell[i].dT[1] == 0)
{
theta = fac*normranf(); /* random error every 2 elements (quad split into 2) */
Cell[i].Elem.M->PBpar[HOMmax-2L] = -Cell[i].Elem.M->PBpar[HOMmax+2L]*sin(2.0*theta);
Cell[i].Elem.M->PBpar[HOMmax+2L] = Cell[i].Elem.M->PBpar[HOMmax+2L]*cos(2.0*theta);
if (trace) printf("%6s % .5e % .5e % .5e\n",Cell[i].Elem.PName,
Cell[i].Elem.M->PBpar[HOMmax-2L], Cell[i].Elem.M->PBpar[HOMmax+2L],theta);
Mpole_SetPB(Cell[i].Fnum, Cell[i].Knum, -2L);
Mpole_SetPB(Cell[i].Fnum, Cell[i].Knum, 2L);
}
}
}
}
/****************************************************************************/
/* void SetErr2(long seed,double fac)
Purpose:
Set error
Definir une distribution aleatoire de quadripoles tournes associee a chaque
quadripole de la machine
Distribution gaussienne d'ecart type fac et coupe a normcut*sigma
This function works for the lattice with two half quadrupoles
Input:
seed: random seed number
fac : RMS value of the rotation angle of the quadrupole
Output:
none
Return:
none
Global variables:
globval
HOMmax
specific functions:
setrandcut, initranf
getelem, putelem
Mpole_SetPB
Comments:
Only valid if quad split into two part (cf pair variable)
Rotation inversion to do as in BETA code
Test if normal quad sin(theta) = 0. Do not work if tilt error
****************************************************************************/
void SetErr2(long seed,double fac)
{
double normcut = 0.0;
long i = 0L;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment