Skip to content

Commit 430249d

Browse files
committed
Fix to enable bbeat in the two planes.
1 parent a229e0f commit 430249d

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

src/mad_aper.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,14 @@ aper_adj_quad(double angle, double x, double y, double* xquad, double* yquad)
228228
}
229229

230230
static void
231-
aper_adj_halo_si(double ex, double ey, double betx, double bety, double bbeat,
231+
aper_adj_halo_si(double ex, double ey, double betx, double bety, double bbeat_x, double bbeat_y,
232232
double halox[], double haloy[], int halolength, double haloxsi[], double haloysi[])
233233
{
234234
int j;
235235

236236
for (j=0; j <= halolength + 1; j++) {
237-
haloxsi[j] = halox[j] * bbeat * sqrt(ex*betx);
238-
haloysi[j] = haloy[j] * bbeat * sqrt(ey*bety);
237+
haloxsi[j] = halox[j] * bbeat_x * sqrt(ex*betx);
238+
haloysi[j] = haloy[j] * bbeat_y * sqrt(ey*bety);
239239
}
240240
}
241241

@@ -1307,7 +1307,7 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
13071307
double on_ap=1, on_elem=0;
13081308
double ex, ey;
13091309
double dqf, betaqfx, dp, dparx, dpary;
1310-
double cor, bbeat, nco, halo[4], interval, spec, notsimple;
1310+
double cor, bbeat, nco, halo[4], interval, spec, notsimple, bbeat_x, bbeat_y;
13111311
double s=0, x=0, y=0, px=0, py=0, betx=0, bety=0, dx=0, dy=0, ratio, n1, length, pt_ele; // nr not used
13121312
double xeff=0,yeff=0;
13131313
double n1x_m, n1y_m;
@@ -1378,6 +1378,14 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
13781378

13791379
cmd_refnode = command_par_string("refnode", this_cmd->clone);
13801380

1381+
if (bbeat==0) {
1382+
bbeat_x = command_par_value("bbeat_x", this_cmd->clone);
1383+
bbeat_y = command_par_value("bbeat_y", this_cmd->clone);
1384+
}
1385+
else {
1386+
bbeat_x = bbeat;
1387+
bbeat_y = bbeat;
1388+
}
13811389
/* calculate delta angle */
13821390
dangle = twopi/(nco*4);
13831391

@@ -1432,7 +1440,7 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
14321440

14331441
// LD: shift further results by one step (?) and finish outside the table
14341442
// (*tw_cnt)++;
1435-
aper_adj_halo_si(ex, ey, betx, bety, bbeat, halox, haloy, halolength, haloxsi, haloysi);
1443+
aper_adj_halo_si(ex, ey, betx, bety, bbeat_x, bbeat_y, halox, haloy, halolength, haloxsi, haloysi);
14361444

14371445
/* calculate initial normal+parasitic disp. */
14381446
/* modified 27feb08 BJ */
@@ -1523,7 +1531,7 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
15231531
parxd = dparx * sqrt(betx/betaqfx) * dqf;
15241532
paryd = dpary * sqrt(bety/betaqfx) * dqf;
15251533

1526-
aper_adj_halo_si(ex, ey, betx, bety, bbeat, halox, haloy, halolength, haloxsi, haloysi);
1534+
aper_adj_halo_si(ex, ey, betx, bety, bbeat_x,bbeat_y, halox, haloy, halolength, haloxsi, haloysi);
15271535

15281536
/*do survey to have ready init for next node */
15291537
if (do_survey) {
@@ -1609,7 +1617,7 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
16091617
jslice, s, betx, bety, dx, dy);
16101618

16111619
s_curr = s_start + s;
1612-
aper_adj_halo_si(ex, ey, betx, bety, bbeat, halox, haloy, halolength, haloxsi, haloysi);
1620+
aper_adj_halo_si(ex, ey, betx, bety, bbeat_x, bbeat_y, halox, haloy, halolength, haloxsi, haloysi);
16131621

16141622
/* calculate normal+parasitic disp.*/
16151623
/* modified 27feb08 BJ */
@@ -1652,10 +1660,10 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
16521660
dispdesx = dx*dp; //Design dispersion
16531661
dispdesy = dy*dp;
16541662

1655-
dispparax = bbeat*(parxd*(fabs(lim_pt->deltap_twiss/beta0 + pt_ele)+dp))
1656-
+(bbeat-1)*fabs(dx*dp); //Parasitic disperison
1657-
dispparay = bbeat*(paryd*(fabs(lim_pt->deltap_twiss/beta0 + pt_ele)+dp))
1658-
+(bbeat-1)*fabs(dy*dp);
1663+
dispparax = bbeat_x*(parxd*(fabs(lim_pt->deltap_twiss/beta0 + pt_ele)+dp))
1664+
+(bbeat_x-1)*fabs(dx*dp); //Parasitic disperison
1665+
dispparay = bbeat_y*(paryd*(fabs(lim_pt->deltap_twiss/beta0 + pt_ele)+dp))
1666+
+(bbeat_y-1)*fabs(dy*dp);
16591667

16601668
if(notsimple){
16611669
nchecks = 8; //Extra checks
@@ -1729,8 +1737,8 @@ aperture(char *table, struct node* use_range[], struct table* tw_cp, int *tw_cnt
17291737

17301738
if (debug) printf("\n Found ratio: %f n1: %f \n",ratio,n1);
17311739

1732-
n1x_m = n1 * bbeat * sqrt(betx*ex);
1733-
n1y_m = n1 * bbeat * sqrt(bety*ey);
1740+
n1x_m = n1 * bbeat_x * sqrt(betx*ex);
1741+
n1y_m = n1 * bbeat_y * sqrt(bety*ey);
17341742

17351743
/* Change below, BJ 23oct2008 */
17361744
/* test block 'if (n1 < node_n1)' included in test block */

src/mad_dict.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ const char *const_command_def =
122122
"dpary = [r, 0.273], " /* fractional parasitic dispersion - vertical */
123123
"cor = [r, 0.004], " /* maximum radial closed orbit */
124124
"bbeat = [r, 1.1], " /* beta beating coefficient applying to beam size*/
125+
"bbeat_x = [r, 1.1], " /* beta beating coefficient applying to beam size*/
126+
"bbeat_y = [r, 1.1], " /* beta beating coefficient applying to beam size*/
125127
"nco = [i, 5], " /* number of azimuth for radial scan */
126128
"halo = [r, {6., 8.4, 7.3, 7.3}], " /* halo parameters: n, r, h, v */
127129
"interval = [r, 1.], " /* length in meters between measurements */

0 commit comments

Comments
 (0)