1 | #include "madx.h" |
---|
2 | |
---|
3 | void |
---|
4 | pro_emit(struct in_cmd* cmd) |
---|
5 | /* calls the emit module */ |
---|
6 | { |
---|
7 | char rout_name[] = "pro_emit"; |
---|
8 | struct command* emit = cmd->clone; |
---|
9 | double e_deltap, e_tol, u0; |
---|
10 | int j, error, keep; |
---|
11 | double* tt; |
---|
12 | double emit_v[3], nemit_v[3], bmax[9], gmax[9], dismax[4], tunes[3], |
---|
13 | sig_v[4], pdamp[3], r0mat[4]; |
---|
14 | char tmp[100]; |
---|
15 | |
---|
16 | if (current_sequ == NULL || current_sequ->ex_start == NULL) |
---|
17 | { |
---|
18 | warning("sequence not active,", "EMIT ignored"); |
---|
19 | return; |
---|
20 | } |
---|
21 | fprintf(prt_file, "enter EMIT module\n"); |
---|
22 | if (attach_beam(current_sequ) == 0) |
---|
23 | fatal_error("EMIT - sequence without beam:", current_sequ->name); |
---|
24 | e_deltap = command_par_value("deltap", emit); |
---|
25 | e_tol = command_par_value("tol", emit); |
---|
26 | keep = get_option("twiss_print"); |
---|
27 | j = 0; |
---|
28 | set_option("twiss_print", &j); |
---|
29 | zero_double(orbit0, 6); |
---|
30 | zero_double(disp0, 6); |
---|
31 | zero_double(oneturnmat, 36); |
---|
32 | tt = (double*) mycalloc("pro_emit", 216, sizeof(double)); |
---|
33 | adjust_beam(); |
---|
34 | probe_beam = clone_command(current_beam); |
---|
35 | tmrefe_(oneturnmat); /* one-turn linear transfer map */ |
---|
36 | twcpin_(oneturnmat,disp0,r0mat,&error); /* added for disp0 computation */ |
---|
37 | adjust_probe(e_deltap); /* sets correct gamma, beta, etc. */ |
---|
38 | print_global(e_deltap); |
---|
39 | adjust_rfc(); /* sets freq in rf-cavities from probe */ |
---|
40 | printf(v_format("guess: %I %F %F\n"), |
---|
41 | guess_flag, guess_orbit[0],guess_orbit[1]); |
---|
42 | if (guess_flag) copy_double(guess_orbit, orbit0, 6); |
---|
43 | getclor_(orbit0, oneturnmat, tt, &error); /* closed orbit */ |
---|
44 | myfree(rout_name, tt); |
---|
45 | if (error == 0) |
---|
46 | { |
---|
47 | current_node = current_sequ->ex_start; |
---|
48 | emit_(&e_deltap, &e_tol, orbit0, disp0, oneturnmat, &u0, emit_v, nemit_v, |
---|
49 | bmax, gmax, dismax, tunes, sig_v, pdamp); |
---|
50 | if (e_deltap == zero) |
---|
51 | { |
---|
52 | store_comm_par_value("ex", emit_v[0], current_beam); |
---|
53 | store_comm_par_value("exn", nemit_v[0], current_beam); |
---|
54 | store_comm_par_value("ey", emit_v[1], current_beam); |
---|
55 | store_comm_par_value("eyn", nemit_v[1], current_beam); |
---|
56 | store_comm_par_value("et", emit_v[2], current_beam); |
---|
57 | store_comm_par_value("sigt", sig_v[2], current_beam); |
---|
58 | store_comm_par_value("sige", sig_v[3], current_beam); |
---|
59 | store_comm_par_value("u0", u0, current_beam); |
---|
60 | store_comm_par_value("qs", tunes[2], current_beam); |
---|
61 | store_comm_par_vector("pdamp", pdamp, current_beam); |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | sprintf(tmp, v_format("%F"), e_deltap); |
---|
66 | warning("EMIT: beam not updated, non-zero deltap: ", tmp); |
---|
67 | } |
---|
68 | print_rfc(); |
---|
69 | } |
---|
70 | set_option("twiss_print", &keep); |
---|
71 | } |
---|
72 | |
---|
73 | |
---|