Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.mex
*.mexa64
*.mexmaci64
*.mexw64

# Compiled python
*.pyc
*.pyd

# pytest cache
.cache
Expand Down
16 changes: 13 additions & 3 deletions atintegrators/GWigSymplecticPass.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
*---------------------------------------------------------------------------
* Modification Log:
* -----------------
* .03 2024-05-06 J. Arenillas, ALBA, jarenillas@axt.email
* Adding rotations and translations to wiggler.
* Bug fix in wiggler initialisation.
* Energy parameter bug fix.
*
* .02 2003-06-18 J. Li
* Cleanup the code
*
Expand Down Expand Up @@ -123,11 +128,13 @@ void GWigSymplecticPass(double *r, double Energy, double Ltot, double Lw,
/* Energy is defined in the lattice in eV but GeV is used by the gwig code. */
Energy = Energy / 1e9;

GWigInit(&Wig, Energy, Ltot, Lw, Bmax, Nstep, Nmeth, NHharm, NVharm, By, Bx, T1, T2, R1, R2);

for (c = 0;c<num_particles;c++) {
GWigInit(&Wig, Energy, Ltot, Lw, Bmax, Nstep, Nmeth, NHharm, NVharm, By, Bx, T1, T2, R1, R2);
r6 = r+c*6;
if (!atIsNaN(r6[0])) {
/* Misalignment at entrance */
if (T1) ATaddvv(r6,T1);
if (R1) ATmultmv(r6,R1);
switch (Nmeth) {
case second:
GWigPass_2nd(&Wig, r6);
Expand All @@ -139,6 +146,9 @@ void GWigSymplecticPass(double *r, double Energy, double Ltot, double Lw,
printf("Invalid wiggler integration method %d.\n", Nmeth);
break;
}
/* Misalignment at exit */
if (R2) ATmultmv(r6,R2);
if (T2) ATaddvv(r6,T2);
}
}
}
Expand All @@ -158,7 +168,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
int Nstep, Nmeth;
int NHharm, NVharm;

Energy = atGetDouble(ElemData, "Energy"); check_error();
Energy=atGetOptionalDouble(ElemData,"Energy",Param->energy); check_error();
Ltot = atGetDouble(ElemData, "Length"); check_error();
Lw = atGetDouble(ElemData, "Lw"); check_error();
Bmax = atGetDouble(ElemData, "Bmax"); check_error();
Expand Down
17 changes: 13 additions & 4 deletions atintegrators/GWigSymplecticRadPass.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
*---------------------------------------------------------------------------
* Modification Log:
* -----------------
* .03 2024-05-06 J. Arenillas, ALBA, jarenillas@axt.email
* Adding rotations and translations to wiggler.
* Bug fix in wiggler initialisation.
* Energy parameter bug fix.
* .02 2003-06-18 J. Li
* Cleanup the code
*
Expand Down Expand Up @@ -123,7 +127,7 @@ void GWigInit(struct gwigR *Wig,double design_energy, double Ltot, double Lw,

#define second 2
#define fourth 4
void GWigSymplecticRadPass(double *r,double Energy, double Ltot, double Lw,
void GWigSymplecticRadPass(double *r, double Energy, double Ltot, double Lw,
double Bmax, int Nstep, int Nmeth, int NHharm, int NVharm,
double *By, double *Bx, double *T1, double *T2,
double *R1, double *R2, int num_particles)
Expand All @@ -141,11 +145,13 @@ void GWigSymplecticRadPass(double *r,double Energy, double Ltot, double Lw,
zEndPointV[0] = 0;
zEndPointV[1] = Ltot;

GWigInit(&Wig, Energy, Ltot, Lw, Bmax, Nstep, Nmeth, NHharm, NVharm,0, 0, zEndPointH, zEndPointV, By, Bx, T1, T2, R1, R2);

for(c = 0;c<num_particles;c++) {
GWigInit(&Wig, Energy, Ltot, Lw, Bmax, Nstep, Nmeth, NHharm, NVharm,0, 0, zEndPointH, zEndPointV, By, Bx, T1, T2, R1, R2);
r6 = r+c*6;
if(!atIsNaN(r6[0])) {
/* Misalignment at entrance */
if (T1) ATaddvv(r6,T1);
if (R1) ATmultmv(r6,R1);
switch (Nmeth) {
case second:
GWigPass_2nd(&Wig, r6);
Expand All @@ -157,6 +163,9 @@ void GWigSymplecticRadPass(double *r,double Energy, double Ltot, double Lw,
printf("Invalid wiggler integration method %d.\n", Nmeth);
break;
}
/* Misalignment at exit */
if (R2) ATmultmv(r6,R2);
if (T2) ATaddvv(r6,T2);
}
}
}
Expand All @@ -176,7 +185,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
int Nstep, Nmeth;
int NHharm, NVharm;

Energy = atGetDouble(ElemData, "Energy"); check_error();
Energy=atGetOptionalDouble(ElemData,"Energy",Param->energy); check_error();
Ltot = atGetDouble(ElemData, "Length"); check_error();
Lw = atGetDouble(ElemData, "Lw"); check_error();
Bmax = atGetDouble(ElemData, "Bmax"); check_error();
Expand Down
Loading