Skip to content

Commit 8073867

Browse files
committed
fix Matlab compilation
1 parent ac8df3b commit 8073867

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

atintegrators/CrabCavityPass.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
9696
double energy, beta0, gamma0, betgam0;
9797
double t0f, lag, phiref, nvx, nvy;
9898
long HarmNumber;
99-
double SigPhi, SigVV;
99+
double Frequency, SigPhi, SigVV;
100100

101101
if (!Elem) {
102-
double Length, *Voltages, Energy, Frequency, TimeLag, PhaseLag;
102+
double Length, *Voltages, Energy, TimeLag, PhaseLag;
103103
Length = atGetDouble(ElemData,"Length"); check_error();
104104
Voltages = atGetDoubleArray(ElemData,"Voltages"); check_error();
105105
Frequency = atGetDouble(ElemData,"Frequency"); check_error();
@@ -123,6 +123,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
123123
Elem->SigVV=SigVV;
124124
}
125125
else {
126+
Frequency=Elem->Frequency;
126127
SigPhi=Elem->SigPhi;
127128
SigVV=Elem->SigVV;
128129
}
@@ -137,8 +138,8 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
137138
betgam0 = gamma0;
138139
beta0 = 1.0;
139140
}
140-
t0f = Elem->Frequency * Param->T0;
141-
lag = TWOPI*Elem->Frequency*Elem->TimeLag/beta0/C0 + Elem->PhaseLag;
141+
t0f = Frequency * Param->T0;
142+
lag = TWOPI*Frequency*Elem->TimeLag/beta0/C0 + Elem->PhaseLag;
142143
phiref = TWOPI * (t0f - Elem->HarmNumber) * Param->nturn - lag;
143144
nvx = Elem->Vx/energy/beta0/beta0;
144145
nvy = Elem->Vy/energy/beta0/beta0;
@@ -150,7 +151,7 @@ ExportMode struct elem *trackFunction(const atElem *ElemData,struct elem *Elem,
150151
nvy *= atrandn_r(Param->common_rng, 1.0, SigVV);
151152
}
152153

153-
CrabCavityPass(r_in, Elem->Length, nvx, nvy, Elem->Frequency, betgam0, phiref, num_particles);
154+
CrabCavityPass(r_in, Elem->Length, nvx, nvy, Frequency, betgam0, phiref, num_particles);
154155
return Elem;
155156
}
156157

@@ -163,7 +164,7 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
163164
{
164165
if (nrhs >= 2) {
165166
double betgam0, beta0, gamma0;
166-
double lag, phiref;
167+
double lag, phiref, nvx, nvy;
167168
double *r_in;
168169
double rest_energy = 0.0;
169170
double charge = -1.0;
@@ -193,9 +194,9 @@ void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
193194
}
194195
lag = TWOPI*Frequency*TimeLag/beta0/C0 + PhaseLag;
195196
phiref = -lag;
196-
normvx = Voltages[0] / Energy / beta0 / beta0;
197-
normvy = Voltages[1] / Energy / beta0 / beta0;
198-
CrabCavityPass(r_in, Length, normvx, normvy, Frequency, betgam0, phiref, num_particles);
197+
nvx = Voltages[0] / Energy / beta0 / beta0;
198+
nvy = Voltages[1] / Energy / beta0 / beta0;
199+
CrabCavityPass(r_in, Length, nvx, nvy, Frequency, betgam0, phiref, num_particles);
199200
}
200201
else if (nrhs == 0) {
201202
plhs[0] = mxCreateCellMatrix(3,1);

0 commit comments

Comments
 (0)