00001 #include "Translate/BmadParser.hpp"
00002
00003 using namespace std;
00004 using namespace BasicUtilities;
00005
00006
00007
00008
00009 BmadParser::BmadParser() : TranslateCore() {
00010 language = "Bmad";
00011 include_file_string = "call:filename";
00012 knl_tn_style_multipoles = true;
00013 c_style_format = false;
00014 continuation_char = "&";
00015 abbreviations_permitted = true;
00016 init_lists_bmad();
00017 init_lists_core();
00018 }
00019
00020
00021
00022
00023 UAPNode* BmadParser::XRepToAMLRep (UAPNode* x_root, UAPNode* aml_root) {
00024
00025
00026
00027 lcavity_found = false;
00028 lattice_type_set = false;
00029
00030
00031
00032 UAPNode* aml_rep = TranslateCore::XRepToAMLRep (x_root, aml_root);
00033
00034
00035
00036
00037 if (!lattice_type_set) {
00038
00039
00040 NodeVec lat_list = aml_rep->getSubNodesByName("lattice");
00041 UAPNode* lat_node;
00042 if (lat_list.size() == 0) {
00043 lat_node = aml_rep->getChildByName("laboratory")->addChild("lattice");
00044 lat_node->addAttribute("name", "lattice");
00045 } else {
00046 lat_node = lat_list.front();
00047 }
00048
00049 string type = "CIRCULAR";
00050 if (lcavity_found) type = "LINEAR";
00051 lat_node->addChild("geometry")->addAttribute("type", type);
00052 }
00053
00054
00055
00056 return aml_rep;
00057
00058 }
00059
00060
00061
00062
00063 bool BmadParser::custom_x_statement_to_x (StrList word_list, string comment,
00064 UAPNode* x_rep_root) {
00065
00066
00067
00068
00069 if (word_list.size() < 3) return false;
00070 string word1 = next_word(word_list);
00071 string word2 = next_word(word_list);
00072 string word3 = next_word(word_list);
00073
00074
00075
00076 if (word1 == "use") {
00077 if (!word_list.size() == 0 || word2 != ",") {
00078 info_out.error ("Malformed USE Statement");
00079 return true;
00080 }
00081 UAPNode* node = x_rep_root->addChild(word1);
00082 node->addAttribute("line", word3);
00083 return true;
00084 }
00085
00086
00087
00088
00089 if (word2 == "[") {
00090 string value = next_word(word_list);
00091 if (value != "]") {
00092 info_out.error ("Missing or misplaced \"]\"");
00093 return true;
00094 }
00095 value = next_word(word_list);
00096 if (value == ":") value = next_word(word_list);
00097 if (value != "=") {
00098 info_out.error ("Missing or misplaced \"=\"");
00099 return true;
00100 }
00101 value = next_word(word_list);
00102 while (word_list.size() != 0) value += next_word(word_list);
00103 if (x_attribute_case(word3) == TO_UPPER) value = str_to_upper(value);
00104
00105 if (word1 == "parameter" || word1 == "beginning" || word1 == "beam_start") {
00106 UAPNode* node = x_rep_root->addChild(word1);
00107 node->addAttribute(word3, value);
00108 } else {
00109 UAPNode* node = x_rep_root->addChild("set");
00110 node->addAttribute("element", word1);
00111 node->addAttribute("attribute", word3);
00112 node->addAttribute("value", value);
00113 }
00114 return true;
00115 }
00116
00117
00118
00119 if (word3 == "overlay" || word3 == "group") {
00120
00121 UAPNode* element_node = x_rep_root->addChild(word3);
00122 element_node->addAttribute("name", word1);
00123 name_to_x_class_map[word1] = word3;
00124
00125 if (comment != "") element_node->addAttribute("comment", comment);
00126
00127 if (word_list.size() < 6) {
00128 info_out.error ("Malformed overlay or group statement");
00129 return true;
00130 }
00131
00132 if (next_word(word_list) != "=" || next_word(word_list) != "{") {
00133 info_out.error ("Missing or misplaced \"= {\" in overllay or group statement");
00134 return true;
00135 }
00136
00137 while (true) {
00138 if (word_list.size() < 4) {
00139 info_out.error ("Malformed overlay or group statement");
00140 return true;
00141 }
00142 string w1 = next_word(word_list);
00143 string w2 = next_word(word_list);
00144
00145 string attrib = "";
00146 if (w2 == "[") {
00147 attrib = next_word(word_list);
00148 w2 = next_word(word_list);
00149 if (w2 != "]") {
00150 info_out.error ("Expecting ending \"]\" in overlay or group statement but got: " + w2);
00151 return true;
00152 }
00153 w2 = next_word(word_list);
00154 }
00155
00156 string factor = "";
00157 if (w2 == "/") {
00158 factor = next_word(word_list);
00159 while (true) {
00160 w2 = next_word(word_list);
00161 if (w2 == "," || w2 == "}" || word_list.size() < 2) break;
00162 factor += w2;
00163 }
00164 }
00165
00166 UAPNode* slave = element_node->addChild("slave");
00167 slave->addAttribute("element", w1);
00168 if (attrib != "") slave->addAttribute("attribute", attrib);
00169 if (factor != "") slave->addAttribute("coef", factor);
00170
00171 if (w2 == "}") break;
00172 if (w2 != ",") {
00173 info_out.error ("Expecting \",\" or \"}\" in slave list but got: " + w2);
00174 return true;
00175 }
00176 }
00177
00178 string attrib = next_word(word_list);
00179 if (attrib != ",") {
00180 info_out.error ("Expecting \",\" after \"}\" in overlay or group");
00181 return true;
00182 }
00183
00184 attrib = next_word(word_list);
00185 element_node->addAttribute("attribute", attrib);
00186 if (word_list.size() == 0) return true;
00187
00188 if (word_list.size() == 1) {
00189 info_out.error ("Extra characters in overlay or group: " + next_word(word_list));
00190 return true;
00191 }
00192
00193 string sep = next_word(word_list);
00194 if (sep == "=") {
00195 word_list.push_front("=");
00196 word_list.push_front("value");
00197 word_list.push_front(",");
00198 x_add_attributes (word_list, word3, element_node);
00199 return true;
00200 } else if (sep == ",") {
00201 word_list.push_front(",");
00202 x_add_attributes (word_list, word3, element_node);
00203 return true;
00204 } else {
00205 info_out.error ("Expecting \"=\" or \",\" after attribute of overlay or group");
00206 return true;
00207 }
00208
00209 }
00210
00211
00212
00213 return false;
00214
00215 }
00216
00217
00218
00219
00220 bool BmadParser::custom_x_add_attributes (StrList& word_list, string ele_class,
00221 string& attrib_name, UAPNode* x_ele_root) {
00222
00223
00224
00225 if (ele_class == "taylor" && attrib_name == "{") {
00226 if (word_list.size() < 11) {
00227 info_out.error ("Malformed taylor element term");
00228 return true;
00229 }
00230 string i_out = next_word(word_list);
00231 string delim = next_word(word_list);
00232 if (delim != ":") {
00233 info_out.error ("Expected \":\" in a taylor term but got: " + delim);
00234 return true;
00235 }
00236 string coef = next_word(word_list);
00237 delim = next_word(word_list);
00238 if (delim != ",") {
00239 info_out.error ("Expected \",\" in a taylor term but got: " + delim);
00240 return true;
00241 }
00242 string exp;
00243 for (int i = 0; i < 6; i++) {
00244 exp += next_word(word_list);
00245 if (i != 5) exp += " ";
00246 }
00247 delim = next_word(word_list);
00248 if (delim != "}") {
00249 info_out.error ("Expected \"}\" in a taylor term but got: " + delim);
00250 return true;
00251 }
00252 UAPNode* term = x_ele_root->addChild("term");
00253 term->addAttribute("i_out", i_out);
00254 term->addAttribute("coef", coef);
00255 term->addAttribute("exp", exp);
00256 return true;
00257 }
00258
00259
00260
00261 if (attrib_name == "term" && ele_class == "wiggler") {
00262 if (word_list.size() < 15) {
00263 info_out.error ("Malformed wiggler term.");
00264 return true;
00265 }
00266 if (next_word(word_list) != "(" || !is_int(next_word(word_list)) ||
00267 next_word(word_list) != ")" || next_word(word_list) != "=" ||
00268 next_word(word_list) != "{") {
00269 info_out.error ("Bad \"term(int)={\" in wiggler term.");
00270 return true;
00271 }
00272 UAPNode* term = x_ele_root->addChild("term");
00273 for (int i = 0; i < 5; i++) {
00274 string val = next_word(word_list);
00275 string d;
00276 while (word_list.size() > 0) {
00277 d = next_word(word_list);
00278 if (d == "," || d == "}") break;
00279 val += d;
00280 }
00281 string who;
00282 switch (i) {
00283 case 0: who = "coef"; break;
00284 case 1: who = "k_x"; break;
00285 case 2: who = "k_y"; break;
00286 case 3: who = "k_z"; break;
00287 case 4: who = "phi_z"; break;
00288 }
00289 term->addAttribute(who, val);
00290 if (i == 4 && d != "}") {
00291 info_out.error ("Missing or misplaced \"}\" in wiggler term.");
00292 return true;
00293 }
00294 if (i < 4 && d != ",") {
00295 info_out.error ("Missing or misplaced \",\" in wiggler term.");
00296 return true;
00297 }
00298 }
00299 return true;
00300 }
00301
00302 return false;
00303
00304 }
00305
00306
00307
00308
00309 bool BmadParser::custom_x_node_to_aml (UAPNode* x_node, UAPNode* aml_root, UAPNode* aml_node) {
00310
00311 string x_class = x_node_to_x_class (x_node);
00312
00313
00314
00315 if (x_class == "lcavity") lcavity_found = true;
00316 if (x_class == "parameter" && x_node->getAttribute("lattice_type")) lattice_type_set = true;
00317
00318
00319
00320
00321
00322
00323
00324 UAPNode* aml_class_node;
00325
00326 if (x_class == "group" || x_class == "overlay") {
00327
00328
00329
00330 UAPNode* aml_control_node = aml_node->addChild("controller");
00331 aml_class_node = aml_control_node;
00332 string ele_name = x_node->getAttributeString("name");
00333 aml_control_node->addAttribute ("name", ele_name);
00334 string aml_class = "controller";
00335 name_to_aml_node_map[ele_name] = aml_control_node;
00336
00337 if (x_class == "group") aml_control_node->addAttribute("variation", "DELTA");
00338
00339
00340
00341 string design_str = x_node->getAttributeString("value");
00342 if (design_str != "") aml_control_node->addAttribute("design", design_str);
00343
00344
00345
00346 string dflt_attrib = x_node->getAttributeString("attribute");
00347 IntMap counter;
00348
00349 NodeVec child_list = x_node->getChildren();
00350 for (NodeVecCIter in = child_list.begin(); in != child_list.end(); in++) {
00351
00352 UAPNode* x_slave = *in;
00353 UAPNode* aml_slave = aml_control_node->addChild("slave");
00354 string element = x_slave->getAttributeString("element");
00355 string x_attrib = x_slave->getAttributeString("attribute");
00356 if (x_attrib == "") x_attrib = dflt_attrib;
00357
00358 string slave_x_class = ele_name_to_x_class(element);
00359 if (slave_x_class == "") {
00360 info_out.error ("Cannot find element: " + element,
00361 "Which is a slave of an overlay or group.");
00362 }
00363 string aml_attrib;
00364 if (slave_x_class == "overlay" || slave_x_class == "group") {
00365 aml_attrib = "";
00366 } else {
00367 attribute_convert_struct attrib_info;
00368 if (!found_x_attrib (slave_x_class, x_attrib, attrib_info)) {
00369 info_out.error ("Unknown attribute: " + x_attrib,
00370 "In: " + x_node->toString());
00371 return false;
00372 }
00373 aml_attrib = attrib_info.aml_twig.toNodeString();
00374 }
00375 aml_slave->addAttribute ("target", element);
00376 aml_slave->addAttribute ("attribute", aml_attrib);
00377
00378 if (counter.find(aml_attrib) == counter.end()) {
00379 counter[aml_attrib] = 1;
00380 } else {
00381 counter[aml_attrib]++;
00382 }
00383
00384 string coef = x_slave->getAttributeString("coef");
00385 if (coef != "") aml_slave->addAttribute("expression", coef + " * " + ele_name + "[@actual]");
00386
00387 }
00388
00389 name_to_x_class_map[ele_name] = x_class;
00390 x_element_attributes_to_aml (x_node, aml_root, aml_control_node);
00391
00392
00393
00394 IntMapIter it;
00395 IntMapIter heighest = counter.begin();
00396
00397 for (it = counter.begin(); it != counter.end(); it++) {
00398 if ((*it).second > (*heighest).second) heighest = it;
00399 }
00400
00401 dflt_attrib = (*heighest).first;
00402 aml_control_node->addAttribute("default_attribute", dflt_attrib);
00403
00404
00405
00406 child_list = aml_control_node->getChildren();
00407 for (NodeVecCIter in = child_list.begin(); in != child_list.end(); in++) {
00408 UAPNode* aml_slave = *in;
00409 if (aml_slave->getName() != "slave") continue;
00410 if (aml_slave->getAttributeString("attribute") != dflt_attrib)
00411 aml_slave->addAttribute ("target", aml_slave->getAttributeString("target") +
00412 "[" + aml_slave->getAttributeString("attribute") + "]");
00413 aml_slave->removeAttribute("attribute");
00414 }
00415
00416 return true;
00417 }
00418
00419
00420
00421 return false;
00422
00423 }
00424
00425
00426
00427
00428 bool BmadParser::custom_x_element_attribute_to_aml (string x_class,
00429 UAPAttribute x_attrib, UAPNode* aml_node) {
00430
00431
00432
00433
00434 if ((x_attrib.getName() == "design" || x_attrib.getName() == "err") &&
00435 (x_class == "overlay" || x_class == "group")) return true;
00436
00437
00438
00439 return false;
00440
00441 }
00442
00443
00444
00445
00446
00447 void BmadParser::custom2_x_element_attribute_to_aml (UAPNode* x_node, UAPNode* aml_node) {
00448
00449 string x_class = x_node_to_x_class (x_node);
00450
00451
00452
00453 if (x_class == "taylor") {
00454 UAPNode* aml_taylor_node = aml_node->getChildByName("taylor_map");
00455 NodeVec terms = x_node->getChildren();
00456 for (NodeVecCIter in = terms.begin(); in != terms.end(); in++)
00457 aml_taylor_node->addChildCopy(*in);
00458 }
00459
00460
00461
00462 if (x_class == "wiggler") {
00463
00464 UAPNode* aml_wiggler_node = aml_node->getChildByName("wiggler");
00465 NodeVec terms = x_node->getChildren();
00466 UAPNode* wig_field;
00467 if (terms.size() > 0) {
00468 wig_field = aml_wiggler_node->addChild("wiggler_field");
00469 }
00470 for (NodeVecCIter in = terms.begin(); in != terms.end(); in++)
00471 wig_field->addChildCopy(*in);
00472 }
00473
00474
00475
00476 if (x_node->getAttribute("superimpose")) {
00477 UAPNode* aml_super = aml_node->addChild("superimpose");
00478
00479 if (UAPAttribute* attrib = x_node->getAttribute("ref"))
00480 aml_super->addAttribute("ref_element", attrib->getValue());
00481
00482 if (UAPAttribute* attrib = x_node->getAttribute("offset"))
00483 aml_super->addAttribute("offset", attrib->getValue());
00484
00485 if (UAPAttribute* attrib = x_node->getAttribute("ref_beginning"))
00486 aml_super->addAttribute("ref_origin", "ENTRANCE");
00487
00488 if (x_node->getAttribute("ref_center"))
00489 aml_super->addAttribute("ref_origin", "CENTER");
00490
00491 if (x_node->getAttribute("ref_end"))
00492 aml_super->addAttribute("ref_origin", "EXIT");
00493
00494 if (x_node->getAttribute("ele_beginning"))
00495 aml_super->addAttribute("ele_origin", "ENTRANCE");
00496
00497 if (x_node->getAttribute("ele_center"))
00498 aml_super->addAttribute("ele_origin", "CENTER");
00499
00500 if (x_node->getAttribute("ele_end"))
00501 aml_super->addAttribute("ele_origin", "EXIT");
00502 }
00503
00504 }
00505
00506
00507
00508
00509 void BmadParser::custom_aml_rep_to_x (UAPNode* lab, UAPNode* x_rep) {
00510
00511
00512
00513 NodeVec overlay_list = x_rep->getSubNodesByName("overlay");
00514 NodeVec lord_list = x_rep->getSubNodesByName("group");
00515 lord_list.insert(lord_list.begin(), overlay_list.begin(), overlay_list.end());
00516
00517
00518
00519
00520
00521 bool resolved_all;
00522 for (int i = 0; i < 100; i++) {
00523
00524 resolved_all = true;
00525 set_overlay_group_slave_attribute (x_rep, resolved_all);
00526
00527
00528
00529 for (NodeVecIter il = lord_list.begin(); il != lord_list.end(); il++) {
00530
00531 UAPNode* lord = *il;
00532 if (lord->getAttributeString("attribute") != "") continue;
00533
00534
00535
00536
00537 IntMap counter;
00538 bool found_dummy = false;
00539
00540 NodeVec slaves = lord->getChildren();
00541 for (NodeVecCIter is = slaves.begin(); is != slaves.end(); is++) {
00542 UAPNode* slave = *is;
00543
00544 string attrib_str = slave->getAttributeString("attribute");
00545 if (attrib_str == "DUMMY!") {
00546 resolved_all = false;
00547 found_dummy = true;
00548 break;
00549 }
00550 if (counter.find(attrib_str) == counter.end()) {
00551 counter[attrib_str] = 1;
00552 } else {
00553 counter[attrib_str]++;
00554 }
00555
00556 }
00557
00558
00559 if (found_dummy) continue;
00560
00561 IntMapIter it;
00562 IntMapIter heighest = counter.begin();
00563
00564 for (it = counter.begin(); it != counter.end(); it++) {
00565 if ((*it).second > (*heighest).second) heighest = it;
00566 }
00567
00568
00569
00570 lord->addAttribute ("attribute", (*heighest).first);
00571 }
00572
00573 if (resolved_all) break;
00574
00575 }
00576
00577 if (!resolved_all) info_out.error ("CANNOT RESOLVE OVERLAY/GROUP DEFAULT ATTRIBUTES.");
00578
00579
00580
00581 for (NodeVecIter il = lord_list.begin(); il != lord_list.end(); il++) {
00582
00583 UAPNode* lord = *il;
00584 string dflt_attrib = lord->getAttributeString("attribute");
00585
00586
00587
00588 NodeVec slaves = lord->getChildren();
00589 for (NodeVecCIter is = slaves.begin(); is != slaves.end(); is++) {
00590 UAPNode* slave = *is;
00591 string attrib = slave->getAttributeString("attribute");
00592 if (attrib == dflt_attrib) slave->removeAttribute("attribute");
00593 }
00594
00595 }
00596
00597 }
00598
00599
00600
00601
00602 void BmadParser::set_overlay_group_slave_attribute (UAPNode* x_rep, bool& resolved_all) {
00603
00604
00605
00606
00607
00608 NodeVec nl = x_rep->getChildren();
00609 for (NodeVecIter ic = nl.begin(); ic != nl.end(); ic++) {
00610 UAPNode* child = *ic;
00611
00612 set_overlay_group_slave_attribute (child, resolved_all);
00613 if (child->getName() != "slave") continue;
00614 if (child->getAttributeString("attribute") != "DUMMY!") continue;
00615 string dflt_attrib = x_rep->getAttributeString("attribute");
00616 string ele_name = child->getAttributeString("element");
00617 UAPNode* element_node = name_to_x_node_map[ele_name];
00618
00619 if (!element_node) {
00620 info_out.error ("CANNOT FIND GROUP OR OVERLAY NAMED: " + ele_name);
00621 continue;
00622 }
00623
00624 string element_attrib_str = element_node->getAttributeString("attribute");
00625 if (element_attrib_str == "") {
00626 resolved_all = false;
00627 continue;
00628 }
00629
00630 child->addAttribute("attribute", element_attrib_str);
00631
00632 }
00633
00634 return;
00635
00636 }
00637
00638
00639
00640
00641 bool BmadParser::custom_aml_node_to_x (UAPNode* aml_ele, UAPNode* x_rep) {
00642
00643 string aml_name = aml_ele->getName();
00644 bool ok;
00645
00646 if (aml_name == "set") {
00647 Twig twig;
00648 if (!twig.fromString(aml_ele->getAttributeString("attribute"))) return false;
00649 string ele_name = twig.name;
00650 string x_class = ele_name_to_x_class(ele_name);
00651
00652 if (twig.nodeid_vec.size() != 2) return false;
00653 string n0 = twig.nodeid_vec[0].name, n1 = twig.nodeid_vec[1].name;
00654
00655
00656
00657 if (x_class == "ab_multipole" && n0 == "multipole" &&
00658 (n1 == "kl" || n1 == "ksl" || n1 == "tilt")) {
00659 string n_str = twig.nodeid_vec[1].attribute[0].value;
00660 int n_int = string_to_int(n_str, ok);
00661 if (!ok) {
00662 info_out.error ("Bad multipole integer order: " + n_str,
00663 "In AML element:", aml_ele->toStringTree());
00664 return true;
00665 }
00666 string ele_name = twig.name;
00667
00668 string kl_set, ksl_set, tilt_set;
00669 string value = aml_ele->getAttributeString("value");
00670 if (n1 == "kl") kl_set = value;
00671 else if (n1 == "ksl") ksl_set = value;
00672 else if (n1 == "tilt") tilt_set = value;
00673
00674 string kl_ele, ksl_ele, tilt_ele;
00675 if (found (aml_multi_tilt_map, ele_name)) {
00676 kl_ele = aml_multi_kl_map[ele_name][n_int];
00677 ksl_ele = aml_multi_ksl_map[ele_name][n_int];
00678 tilt_ele = aml_multi_tilt_map[ele_name][n_int];
00679 required_multipole_transfer ("tilt", kl_ele, ksl_ele, tilt_ele,
00680 kl_set, ksl_set, tilt_set);
00681 } else {
00682 aml_multi_kl_map[ele_name] = StrVec(N_MULTIPOLE);
00683 aml_multi_ksl_map[ele_name] = StrVec(N_MULTIPOLE);
00684 aml_multi_tilt_map[ele_name] = StrVec(N_MULTIPOLE);
00685 }
00686
00687
00688 string knl, ksl;
00689 multipole_to_k_ks (kl_set, ksl_set, tilt_set, n_str, knl, ksl);
00690
00691 if (knl != "") {
00692 UAPNode* x_set = x_rep->addChild("set");
00693 x_set->addAttribute("element", ele_name);
00694 x_set->addAttribute("attribute", "b" + n_str);
00695 x_set->addAttribute("value", divide_by_n_factorial (n_int, knl));
00696 }
00697
00698 if (ksl != "") {
00699 UAPNode* x_set = x_rep->addChild("set");
00700 x_set->addAttribute("element", ele_name);
00701 x_set->addAttribute("attribute", "a" + n_str);
00702 x_set->addAttribute("value", divide_by_n_factorial (n_int, ksl));
00703 }
00704
00705
00706
00707 if (n1 == "kl") aml_multi_kl_map[ele_name][n_int] = value;
00708 else if (n1 == "ksl") aml_multi_ksl_map[ele_name][n_int] = value;
00709 else if (n1 == "tilt") aml_multi_tilt_map[ele_name][n_int] = value;
00710
00711 return true;
00712 }
00713
00714 }
00715
00716
00717
00718
00719
00720
00721 if (aml_name == "controller") {
00722
00723
00724
00725
00726 string x_class;
00727 aml_ele_to_x_class(aml_ele, x_class);
00728 UAPNode* x_ele = x_rep->addChild(x_class);
00729
00730
00731
00732 string name = aml_ele->getAttributeString("name");
00733 x_ele->addAttribute("name", name);
00734 name_to_x_node_map[name] = x_ele;
00735
00736
00737
00738 string design = aml_ele->getAttributeString("design");
00739 if (design != "") x_ele->addAttribute("value", design);
00740
00741 aml_element_attributes_to_x (aml_ele, aml_ele, x_ele);
00742 return true;
00743
00744 }
00745
00746
00747
00748 return false;
00749
00750 }
00751
00752
00753
00754
00755 bool BmadParser::custom_aml_element_attribute_to_x(UAPNode* aml_root, UAPNode* aml_ele,
00756 UAPNode* aml_attrib_node, UAPNode* x_ele) {
00757
00758 string aml_parent_name = aml_ele->getName();
00759 string aml_name = aml_attrib_node->getName();
00760
00761
00762
00763 if (aml_parent_name == "taylor_map" && aml_name == "term") {
00764 x_ele->addChildCopy(aml_attrib_node);
00765 return true;
00766 }
00767
00768
00769
00770 if (aml_name == "term" & aml_parent_name == "wiggler_field") {
00771 x_ele->addChildCopy(aml_attrib_node);
00772 return true;
00773 }
00774
00775
00776
00777 if (aml_name == "slave") {
00778 UAPNode* x_slave = x_ele->addChild("slave");
00779 string dflt_attrib = x_ele->getAttributeString("attribute");
00780
00781
00782
00783
00784 string target_name = aml_attrib_node->getAttributeString("target");
00785
00786
00787
00788
00789 Twig twig(target_name, true);
00790 x_slave->addAttribute("element", twig.name);
00791
00792
00793
00794 string x_slave_class = ele_name_to_x_class(twig.name);
00795 if (x_slave_class == "")
00796 info_out.error ("Cannot find AML element: " + twig.name,
00797 "Which is a slave of a controller.");
00798
00799
00800
00801 string aml_attrib;
00802 if (twig.has_brackets)
00803 aml_attrib = twig.toNodeString();
00804 else
00805 aml_attrib = aml_ele->getAttributeString("default_attribute");
00806
00807
00808
00809 if (x_slave_class == "group") {
00810 if (dflt_attrib != "command") x_slave->addAttribute ("attribute", "command");
00811 aml_attrib == "";
00812
00813
00814
00815
00816 } else if (x_slave_class == "overlay") {
00817
00818 x_slave->addAttribute ("attribute", "DUMMY!");
00819
00820
00821
00822 } else {
00823 attribute_convert_struct attrib_info;
00824 if (!found_aml_attrib (x_slave_class, aml_attrib, attrib_info)) {
00825 info_out.error ("Unknown controller slave attribute: " + aml_attrib,
00826 "Of: " + aml_attrib_node->toString(),
00827 "In: " + aml_attrib_node->getParent()->toString());
00828 return false;
00829 }
00830 if (attrib_info.ignore_aml_to_x) return false;
00831 if (attrib_info.x_name != dflt_attrib)
00832 x_slave->addAttribute ("attribute", attrib_info.x_name);
00833 }
00834
00835
00836
00837 string expression = aml_attrib_node->getAttributeString("expression");
00838 if (expression != "") {
00839 bool ok = false;
00840 string con_name = aml_attrib_node->getParent()->getAttributeString("name") + "[@actual]";
00841 size_t n_exp = expression.size();
00842 size_t n_con = con_name.size();
00843 if (n_con < n_exp) {
00844 if (expression.substr(0, n_con) == con_name) {
00845 expression.erase(0, n_exp);
00846 while(true) {
00847 if (expression.size() == 0) break;
00848 char c0 = expression[0];
00849 if (ok && c0 != ' ') break;
00850 if (!ok && c0 != ' ' && c0 != '*') break;
00851 expression.erase(0,1);
00852 if (c0 == ' ') continue;
00853 if (c0 == '*') ok = true;
00854 }
00855 }
00856
00857 if (expression.substr(n_exp-n_con, n_con) == con_name) {
00858 expression.erase(n_exp-n_con, n_con);
00859 while (true) {
00860 n_exp = expression.size();
00861 if (n_exp == 0) break;
00862 char c0 = expression[n_exp-1];
00863 if (ok && c0 != ' ') break;
00864 if (!ok && c0 != ' ' && c0 != '*') break;
00865 expression.erase(n_exp-1,1);
00866 if (c0 == ' ') continue;
00867 if (c0 == '*') ok = true;
00868 }
00869 }
00870 }
00871
00872 x_slave->addAttribute ("coef", expression);
00873 if (!ok) {
00874 info_out.error ("Cannot form valid coefficient for overlay or group slave.",
00875 aml_attrib_node->getParent()->toString());
00876 }
00877 }
00878
00879 return true;
00880 }
00881
00882
00883
00884 if (aml_name == "superimpose") {
00885
00886 x_ele->addAttribute("superimpose", "");
00887
00888 AttributeVec attribs = aml_attrib_node->getAttributes();
00889 for (AttributeVecIter ia = attribs.begin(); ia != attribs.end(); ia++) {
00890 string name = ia->getName();
00891 string value = ia->getValue();
00892
00893 if (name == "ref_element")
00894 x_ele->addAttribute("ref", value);
00895
00896 else if (name =="offset")
00897 x_ele->addAttribute("offset", value);
00898
00899 else if (name =="ele_origin") {
00900 string a_name = value;
00901 if (a_name == "ENTRANCE") x_ele->addAttribute("ele_beginning", "");
00902 else if (a_name == "CENTER" || a_name == "") x_ele->addAttribute("ele_center", "");
00903 else if (a_name == "EXIT") x_ele->addAttribute("ele_end", "");
00904 else info_out.error("Bad ele_origin superimose attribute: " + aml_ele->toStringTree());
00905 }
00906
00907 else if (name =="ref_origin") {
00908 string a_name = value;
00909 if (a_name == "ENTRANCE") x_ele->addAttribute("ref_beginning", "");
00910 else if (a_name == "CENTER" || a_name == "") x_ele->addAttribute("ref_center", "");
00911 else if (a_name == "EXIT") x_ele->addAttribute("ref_end", "");
00912 else info_out.error("Bad ref_origin superimose attribute: " + aml_ele->toStringTree());
00913 }
00914
00915 else
00916 info_out.error ("superimpose attribute not recognized: " + name,
00917 "For: " + aml_ele->toStringTree());
00918 }
00919
00920 return true;
00921 }
00922
00923
00924
00925 return false;
00926
00927 }
00928
00929
00930
00931
00932 void BmadParser::custom2_aml_element_attribute_to_x (UAPNode* aml_ele, UAPNode* x_ele) {
00933
00934 string aml_attrib_name = aml_ele->getName();
00935 string ele_name = x_ele->getAttributeString("name");
00936
00937
00938
00939 if (aml_attrib_name == "multipole" && name_to_x_class_map[ele_name] == "ab_multipole") {
00940
00941 string inherit = x_ele->getAttributeString("inherit");
00942 if (aml_multi_kl_map.find(inherit) == aml_multi_kl_map.end()) inherit = "";
00943
00944 for (int n = 0; n < N_MULTIPOLE; n++) {
00945 string kl_base, ksl_base, tilt_base, kl_ele, ksl_ele, tilt_ele;
00946 if (inherit != "") {
00947 kl_base = aml_multi_kl_map[inherit][n];
00948 ksl_base = aml_multi_ksl_map[inherit][n];
00949 tilt_base = aml_multi_tilt_map[inherit][n];
00950 }
00951 kl_ele = aml_multi_kl_map[ele_name][n];
00952 ksl_ele = aml_multi_ksl_map[ele_name][n];
00953 tilt_ele = aml_multi_tilt_map[ele_name][n];
00954 string kl, ksl, n_str = int_to_string(n);
00955 if (inherit != "") required_multipole_transfer ("tilt",
00956 kl_base, ksl_base, tilt_base, kl_ele, ksl_ele, tilt_ele);
00957
00958 multipole_to_k_ks (kl_ele, ksl_ele, tilt_ele, n_str, kl, ksl);
00959
00960 string n_fact = n_factorial[n];
00961
00962 if (kl != "") x_ele->addAttribute("b" + n_str, divide_by_n_factorial (n, kl));
00963 if (ksl != "") x_ele->addAttribute("a" + n_str, divide_by_n_factorial (n, ksl));
00964
00965 if (inherit != "") {
00966 if (kl_ele == "") aml_multi_kl_map[ele_name][n] = kl_base;
00967 if (ksl_ele == "") aml_multi_ksl_map[ele_name][n] = ksl_base;
00968 if (tilt_ele == "") aml_multi_tilt_map[ele_name][n] = tilt_base;
00969 }
00970
00971 }
00972
00973 return;
00974 }
00975
00976
00977
00978 return;
00979
00980 }
00981
00982
00983
00984
00985 bool BmadParser::custom_x_element_to_x_file (UAPNode* x_node, string& comment,
00986 StreamStruct& x_out) {
00987
00988 string x_name = x_node->getName();
00989
00990
00991
00992 if (x_name == "use") {
00993 x_out << "use, " << x_node->getAttributeString("line") << comment << fini;
00994 return true;
00995 }
00996
00997
00998
00999 if (x_name == "set") {
01000 string a_name = x_node->getAttributeString("attribute");
01001 string a_value = x_node->getAttributeString("value");
01002 x_add_quote_marks (a_name, a_value);
01003 x_out << x_node->getAttributeString("element") << "[" <<
01004 a_name << "] = " << a_value << comment << fini;
01005 return true;
01006 }
01007
01008
01009
01010 if (x_name == "beginning" || x_name == "beam_start" || x_name == "parameter") {
01011 x_out << x_name;
01012 AttributeVec al = x_node->getAttributes();
01013 for (AttributeVecCIter it = al.begin(); it != al.end(); it++) {
01014 if (it->getName() == "comment") continue;
01015 x_out << "[" << it->getName() << "] = " << it->getValue();
01016 }
01017 x_out << comment << fini;
01018 return true;
01019 }
01020
01021
01022
01023 if (x_name == "overlay" || x_name == "group") {
01024 x_out << x_node->getAttributeString("name") << ": " <<
01025 x_node->getName() << " = {";
01026 NodeVec nt = x_node->getChildren();
01027 for (NodeVecCIter it = nt.begin(); it != nt.end(); it++) {
01028 UAPNode* slave = *it;
01029 if (it != nt.begin()) x_out << ", ";
01030 x_out << slave->getAttributeString("element");
01031 string attrib = slave->getAttributeString("attribute");
01032 if (attrib != "") x_out << "[" << attrib << "]";
01033 string coef = slave->getAttributeString("coef");
01034 if (coef != "") x_out << "/" << coef;
01035 }
01036 string attrib = x_node->getAttributeString("attribute");
01037 string value = x_node->getAttributeString("value");
01038 x_out << "}, " << attrib;
01039 if (value != "") x_out << " = " << value;
01040
01041 AttributeVec al = x_node->getAttributes();
01042 for (AttributeVecCIter att = al.begin(); att != al.end(); att++) {
01043 string a_name = att->getName();
01044 string a_value = att->getValue();
01045 if (a_name == "name") continue;
01046 if (a_name == "comment") continue;
01047 if (a_name == "attribute") continue;
01048 if (a_name == "value") continue;
01049 x_out << ", " << a_name;
01050 x_add_quote_marks (a_name, a_value);
01051 if (a_value != "") x_out << " = " << a_value;
01052 }
01053
01054 x_out << comment << fini;
01055 return true;
01056 }
01057
01058
01059
01060
01061 return false;
01062
01063 }
01064
01065
01066
01067
01068 void BmadParser::custom_x_ele_attributes_to_x_file (UAPNode* x_node,
01069 const string& ele_class, StreamStruct& x_out) {
01070
01071 if (ele_class == "taylor") {
01072 NodeVec nt = x_node->getChildren();
01073 for (NodeVecCIter it = nt.begin(); it != nt.end(); it++) {
01074 UAPNode* term = *it;
01075 x_out << ", {" << term->getAttributeString("i_out") << ": " <<
01076 term->getAttributeString("coef") << ", " <<
01077 term->getAttributeString("exp") << "}";
01078 }
01079 }
01080
01081 if (ele_class == "wiggler") {
01082 NodeVec nt = x_node->getChildren();
01083 int i = 0;
01084 for (NodeVecCIter it = nt.begin(); it != nt.end(); it++) {
01085 UAPNode* term = *it;
01086 i++;
01087 x_out << ", term(" << i << ") = {" <<
01088 term->getAttributeString("coef") << ", " <<
01089 term->getAttributeString("k_x") << ", " <<
01090 term->getAttributeString("k_y") << ", " <<
01091 term->getAttributeString("k_z") << ", " <<
01092 term->getAttributeString("phi_z") << "}";
01093 }
01094 }
01095
01096
01097 }
01098
01099
01100
01101
01102 bool BmadParser::aml_ele_to_x_class (UAPNode* aml_ele, string& x_class) {
01103
01104
01105
01106
01107 x_class = "BAD!";
01108
01109
01110
01111 if (aml_ele->getName() == "controller") {
01112 string var = aml_ele->getAttributeString("variation");
01113 if (var == "" || var == "ABSOLUTE") {
01114 x_class = "overlay";
01115 } else {
01116 x_class = "group";
01117 }
01118 return true;
01119 }
01120
01121
01122
01123 StrList names;
01124 NodeVec children = aml_ele->getChildren();
01125 for (NodeVecCIter it = children.begin(); it != children.end(); it++) {
01126 string name = (*it)->getName();
01127 if (!found(aml_class_names, name)) continue;
01128 if (name == "rf_cavity") {
01129 if ((*it)->getAttributeString("type") == "LINAC") {
01130 names << "lcavity";
01131 continue;
01132 }
01133 }
01134 names << name;
01135 }
01136
01137 UAPNode* instrument = aml_ele->getChildByName("instrument");
01138
01139
01140
01141 if (names.size() == 0) {
01142 x_class = "drift";
01143 if (instrument) {
01144 x_class = "instrument";
01145 string i_type = instrument->getAttributeString("type");
01146 if (i_type == "monitor") x_class = i_type;
01147 }
01148 return true;
01149 }
01150
01151
01152
01153
01154 if (names.size() > 1) names.remove("aperture");
01155 if (names.size() > 1) names.remove("scaled_multipole");
01156 if (names.size() > 1) names.remove("multipole");
01157 if (names.size() > 1) names.remove("kicker");
01158
01159
01160
01161 if (names.size() == 1) {
01162
01163 x_class = names.front();
01164
01165 if (x_class == "taylor_map") x_class = "taylor";
01166 if (x_class == "bend") x_class = "sbend";
01167 if (x_class == "electric_kicker") x_class = "elseparator";
01168 if (x_class == "rf_cavity") x_class = "rfcavity";
01169 if (x_class == "lcavity") x_class = "lcavity";
01170
01171 if (x_class == "aperture") {
01172 x_class = "rcollimator";
01173 string shape = aml_ele->getChildByName("aperture")->getAttributeString("shape");
01174 if (shape == "ELLIPTICAL") x_class = "ecollimator";
01175 }
01176
01177
01178
01179
01180
01181 if (x_class == "multipole") {
01182 int n_tilt(0), n_ksl(0);
01183 UAPNode* mult = aml_ele->getChildByName("multipole");
01184
01185 NodeVec children = mult->getChildren();
01186 for (NodeVecCIter it = children.begin(); it != children.end(); it++) {
01187 UAPNode* child = *it;
01188 if (child->getName() == "tilt") n_tilt++;
01189 if (child->getName() == "ksl") n_ksl++;
01190 }
01191 if (n_tilt == 0 && n_ksl > 0) x_class = "ab_multipole";
01192 }
01193
01194 return true;
01195 }
01196
01197
01198
01199 if (found(names, "solenoid") && found(names, "quadrupole")) {
01200 if (names.size() == 2) x_class = "sol_quad";
01201 }
01202
01203 if (x_class == "BAD!" && found(names, "bend")) x_class = "sbend";
01204
01205 if (x_class == "BAD!") {
01206 info_out.error ("AML element does not have a corresponding " + language +
01207 " type", aml_ele->toStringTree());
01208 return false;
01209 }
01210
01211 return true;
01212
01213 }
01214
01215
01216
01217
01218 string BmadParser::divide_by_n_factorial (int n, string k) {
01219
01220
01221
01222 if (n < 2) return k;
01223
01224
01225
01226
01227 int m = k.size() - (3 + n_factorial[n].size());
01228
01229 if (m > 0 && k.substr(m) == " * " + n_factorial[n])
01230 return k.substr(0, m);
01231 else
01232 return add_parens(k, 1) + " / " + n_factorial[n];
01233
01234 }
01235
01236
01237
01238
01239 bool BmadParser::custom_aml_sector_or_element_to_x (UAPNode* aml_sector,
01240 UAPNode* x_root) {
01241
01242 return false;
01243
01244 }
01245
01246
01247
01248
01249 void BmadParser::init_lists_bmad () {
01250
01251 x_param_names << "beam" << "parameter" << "beginning" << "beam_start";
01252
01253 x_attributes_needing_quote_marks << "type" << "alias" << "descrip";
01254 x_attributes_to_upper_case << "lattice_type" << "tracking_method"
01255 << "mat6_calc_method" << "aperture_at";
01256 x_attributes_no_case_change << "alias" << "descrip";
01257
01258 x_class_to_aml_map["sol_quad"] = "quadrupole:solenoid";
01259 x_class_to_aml_map["bend_sol_quad"] = "quadrupole:solenoid:dipole";
01260 x_class_to_aml_map["custom"] = "custom";
01261 x_class_to_aml_map["ab_multipole"] = "multipole";
01262 x_class_to_aml_map["girder"] = "girder";
01263 x_class_to_aml_map["match"] = "match";
01264 x_class_to_aml_map["patch"] = "patch";
01265 x_class_to_aml_map["taylor"] = "taylor_map";
01266 x_class_to_aml_map["wiggler"] = "wiggler";
01267 x_class_to_aml_map["overlay"] = "controller";
01268 x_class_to_aml_map["group"] = "controller(variation=DELTA)";
01269
01270 StrVec ab_mul_attrib;
01271 ab_mul_attrib << "a1" << "a2" << "a3" << "a4" << "a5"
01272 << "a6" << "a7" << "a8" << "a9" << "a10" << "a11" << "a12" << "a13"
01273 << "a14" << "a15" << "a16" << "a17" << "a18" << "a19" << "a20" << "b1"
01274 << "b2" << "b3" << "b4" << "b5" << "b6" << "b7" << "b8" << "b9"
01275 << "b10" << "b11" << "b12" << "b13" << "b14" << "b15" << "b16" << "b17"
01276 << "b18" << "b19" << "b20";
01277
01278 StrVec scaled_mul_attrib;
01279 scaled_mul_attrib << "k_coef(n=0)"
01280 << "k_coef(n=1)" << "k_coef(n=2)" << "k_coef(n=3)" << "k_coef(n=4)" << "k_coef(n=5)"
01281 << "k_coef(n=6)" << "k_coef(n=7)" << "k_coef(n=8)" << "k_coef(n=9)" << "k_coef(n=10)"
01282 << "k_coef(n=11)" << "k_coef(n=12)" << "k_coef(n=13)" << "k_coef(n=14)" << "k_coef(n=15)"
01283 << "k_coef(n=16)" << "k_coef(n=17)" << "k_coef(n=18)" << "k_coef(n=19)" << "k_coef(n=20)"
01284 << "k_coef(n=0)" << "ks_coef(n=1)" << "ks_coef(n=2)" << "ks_coef(n=3)" << "ks_coef(n=4)"
01285 << "ks_coef(n=5)" << "ks_coef(n=6)" << "ks_coef(n=7)" << "ks_coef(n=8)" << "ks_coef(n=9)"
01286 << "ks_coef(n=10)" << "ks_coef(n=11)" << "ks_coef(n=12)" << "ks_coef(n=13)" << "ks_coef(n=14)"
01287 << "ks_coef(n=15)" << "ks_coef(n=16)" << "ks_coef(n=17)"
01288 << "ks_coef(n=18)" << "ks_coef(n=19)" << "ks_coef(n=20)" << "radius";
01289
01290 StrVec superimpose_attrib;
01291 superimpose_attrib << "superimpose" << "ref_beginning" << "ref_center" <<
01292 "ref_end" << "ele_beginning" << "ele_center" <<
01293 "ele_end" << "reference" << "offset" << "ref";
01294
01295 StrVec descrip_attrib;
01296 descrip_attrib <<"descrip" << "type" << "alias";
01297
01298 StrVec method_attrib;
01299 method_attrib << "x1_limit" << "y1_limit" << "x2_limit" << "y2_limit"
01300 << "x_limit" << "y_limit" << "aperture" << "aperture_at"
01301 << "mat6_calc_method" << "tracking_method" << "is_on";
01302
01303 StrVec track_attrib;
01304 track_attrib << "symplectify" << "map_with_offsets" << "integrator_order"
01305 << "ds_step" << "rel_tol" << "abs_tol" << "csr_calc_on"
01306 << "num_steps";
01307
01308 StrVec kick_attrib;
01309 kick_attrib << "hkick" << "vkick" << "bl_hkick" << "bl_vkick";
01310
01311 StrVec offset_attrib;
01312 offset_attrib << "x_offset" << "y_offset" << "s_offset";
01313
01314 StrVec pitch_attrib;
01315 pitch_attrib << "x_pitch" << "y_pitch";
01316
01317 StrVec drift_attrib;
01318 drift_attrib << "l" << "rel_tol";
01319 map_element_to_attribs["drift"] << kick_attrib;
01320 map_element_to_attribs["drift"] << method_attrib;
01321 map_element_to_attribs["drift"] << track_attrib;
01322 map_element_to_attribs["drift"] << descrip_attrib;
01323 map_element_to_attribs["drift"] << drift_attrib;
01324
01325 StrVec bend_attrib;
01326 bend_attrib << "l" << "tilt" << "angle" << "k1" << "k2" << "g_err"
01327 << "g" << "e1" << "l_chord" << "roll"
01328 << "e2" << "fint" << "fintx" << "rho" << "hgap" << "hgapx"
01329 << "h1" << "h2" << "rel_tol" << "b_field" << "b_field_err";
01330 bend_attrib << pitch_attrib;
01331 bend_attrib << kick_attrib;
01332 bend_attrib << offset_attrib;
01333 bend_attrib << method_attrib;
01334 bend_attrib << track_attrib;
01335 bend_attrib << descrip_attrib;
01336 bend_attrib << scaled_mul_attrib;
01337 bend_attrib << superimpose_attrib;
01338 map_element_to_attribs["sbend"] << bend_attrib;
01339 map_element_to_attribs["rbend"] << bend_attrib;
01340
01341
01342 StrVec quadrupole_attrib;
01343 quadrupole_attrib << "l" << "tilt" << "k1" << "rel_tol" << "b1_gradient";
01344 map_element_to_attribs["quadrupole"] << pitch_attrib;
01345 map_element_to_attribs["quadrupole"] << kick_attrib;
01346 map_element_to_attribs["quadrupole"] << offset_attrib;
01347 map_element_to_attribs["quadrupole"] << method_attrib;
01348 map_element_to_attribs["quadrupole"] << track_attrib;
01349 map_element_to_attribs["quadrupole"] << descrip_attrib;
01350 map_element_to_attribs["quadrupole"] << scaled_mul_attrib;
01351 map_element_to_attribs["quadrupole"] << superimpose_attrib;
01352 map_element_to_attribs["quadrupole"] << quadrupole_attrib;
01353
01354 StrVec group_attrib;
01355 group_attrib << "command" << "old_command" << "coef" << "symmetric_edge"
01356 << "start_edge" << "end_edge" << "accordion_edge" << "value" << "err";
01357 map_element_to_attribs["group"] << descrip_attrib;
01358 map_element_to_attribs["group"] << group_attrib;
01359
01360 StrVec sextupole_attrib;
01361 sextupole_attrib << "l" << "tilt" << "k2" << "rel_tol" << "b2_gradient";
01362 map_element_to_attribs["sextupole"] << pitch_attrib;
01363 map_element_to_attribs["sextupole"] << kick_attrib;
01364 map_element_to_attribs["sextupole"] << offset_attrib;
01365 map_element_to_attribs["sextupole"] << method_attrib;
01366 map_element_to_attribs["sextupole"] << track_attrib;
01367 map_element_to_attribs["sextupole"] << descrip_attrib;
01368 map_element_to_attribs["sextupole"] << scaled_mul_attrib;
01369 map_element_to_attribs["sextupole"] << superimpose_attrib;
01370 map_element_to_attribs["sextupole"] << sextupole_attrib;
01371
01372 StrVec overlay_attrib;
01373 overlay_attrib << "attribute" << "value" << "err";
01374 map_element_to_attribs["overlay"] << descrip_attrib;
01375 map_element_to_attribs["overlay"] << overlay_attrib;
01376
01377 StrVec custom_attrib;
01378 custom_attrib << "l" << "tilt" << "val1" << "val2" << "val3" << "val4"
01379 << "val6" << "val7" << "val8" << "val9" << "val10" << "val5"
01380 << "val11" << "delta_e" << "val12" << "rel_tol";
01381 map_element_to_attribs["custom"] << pitch_attrib;
01382 map_element_to_attribs["custom"] << offset_attrib;
01383 map_element_to_attribs["custom"] << method_attrib;
01384 map_element_to_attribs["custom"] << track_attrib;
01385 map_element_to_attribs["custom"] << descrip_attrib;
01386 map_element_to_attribs["custom"] << custom_attrib;
01387
01388 StrVec taylor_attrib;
01389 taylor_attrib << "l" << "tilt";
01390 map_element_to_attribs["taylor"] << pitch_attrib;
01391 map_element_to_attribs["taylor"] << offset_attrib;
01392 map_element_to_attribs["taylor"] << method_attrib;
01393 map_element_to_attribs["taylor"] << track_attrib;
01394 map_element_to_attribs["taylor"] << descrip_attrib;
01395 map_element_to_attribs["taylor"] << taylor_attrib;
01396
01397 StrVec rfcavity_attrib;
01398 rfcavity_attrib << "l" << "harmon" << "voltage" << "dphi0"
01399 << "rf_frequency" << "phi0" << "rel_tol";
01400 map_element_to_attribs["rfcavity"] << pitch_attrib;
01401 map_element_to_attribs["rfcavity"] << kick_attrib;
01402 map_element_to_attribs["rfcavity"] << offset_attrib;
01403 map_element_to_attribs["rfcavity"] << method_attrib;
01404 map_element_to_attribs["rfcavity"] << track_attrib;
01405 map_element_to_attribs["rfcavity"] << descrip_attrib;
01406 map_element_to_attribs["rfcavity"] << rfcavity_attrib;
01407
01408 StrVec elseparator_attrib;
01409 elseparator_attrib << "l" << "tilt" << "voltage" << "gap" << "rel_tol" << "e_field";
01410 map_element_to_attribs["elseparator"] << pitch_attrib;
01411 map_element_to_attribs["elseparator"] << kick_attrib;
01412 map_element_to_attribs["elseparator"] << offset_attrib;
01413 map_element_to_attribs["elseparator"] << method_attrib;
01414 map_element_to_attribs["elseparator"] << track_attrib;
01415 map_element_to_attribs["elseparator"] << descrip_attrib;
01416 map_element_to_attribs["elseparator"] << scaled_mul_attrib;
01417 map_element_to_attribs["elseparator"] << superimpose_attrib;
01418 map_element_to_attribs["elseparator"] << elseparator_attrib;
01419
01420 StrVec beambeam_attrib;
01421 beambeam_attrib << "tilt" << "sig_x" << "sig_y" << "sig_z"
01422 << "charge" << "n_slice";
01423 map_element_to_attribs["beambeam"] << pitch_attrib;
01424 map_element_to_attribs["beambeam"] << offset_attrib;
01425 map_element_to_attribs["beambeam"] << method_attrib;
01426 map_element_to_attribs["beambeam"] << descrip_attrib;
01427 map_element_to_attribs["beambeam"] << beambeam_attrib;
01428
01429 StrVec wiggler_attrib;
01430 wiggler_attrib << "l" << "tilt" << "k1" << "b_max" << "n_pole" << "polarity"
01431 << "z_patch" << "rho" << "x_patch" << "l_pole" << "x_ray_line_len"
01432 << "rel_tol" << "term";
01433 map_element_to_attribs["wiggler"] << pitch_attrib;
01434 map_element_to_attribs["wiggler"] << kick_attrib;
01435 map_element_to_attribs["wiggler"] << offset_attrib;
01436 map_element_to_attribs["wiggler"] << method_attrib;
01437 map_element_to_attribs["wiggler"] << track_attrib;
01438 map_element_to_attribs["wiggler"] << descrip_attrib;
01439 map_element_to_attribs["wiggler"] << scaled_mul_attrib;
01440 map_element_to_attribs["wiggler"] << superimpose_attrib;
01441 map_element_to_attribs["wiggler"] << wiggler_attrib;
01442
01443 StrVec sol_quad_attrib;
01444 sol_quad_attrib << "l" << "tilt" << "k1" << "ks" << "rel_tol";
01445 map_element_to_attribs["sol_quad"] << pitch_attrib;
01446 map_element_to_attribs["sol_quad"] << kick_attrib;
01447 map_element_to_attribs["sol_quad"] << offset_attrib;
01448 map_element_to_attribs["sol_quad"] << method_attrib;
01449 map_element_to_attribs["sol_quad"] << track_attrib;
01450 map_element_to_attribs["sol_quad"] << descrip_attrib;
01451 map_element_to_attribs["sol_quad"] << scaled_mul_attrib;
01452 map_element_to_attribs["sol_quad"] << superimpose_attrib;
01453 map_element_to_attribs["sol_quad"] << sol_quad_attrib;
01454
01455 StrVec marker_attrib;
01456 marker_attrib << "tilt";
01457 map_element_to_attribs["marker"] << offset_attrib;
01458 map_element_to_attribs["marker"] << method_attrib;
01459 map_element_to_attribs["marker"] << descrip_attrib;
01460 map_element_to_attribs["marker"] << superimpose_attrib;
01461 map_element_to_attribs["marker"] << marker_attrib;
01462
01463 StrVec kicker_attrib;
01464 kicker_attrib << "l" << "tilt" << "h_displace" << "v_displace" << "rel_tol";
01465 map_element_to_attribs["kicker"] << kick_attrib;
01466 map_element_to_attribs["kicker"] << method_attrib;
01467 map_element_to_attribs["kicker"] << track_attrib;
01468 map_element_to_attribs["kicker"] << descrip_attrib;
01469 map_element_to_attribs["kicker"] << scaled_mul_attrib;
01470 map_element_to_attribs["kicker"] << superimpose_attrib;
01471 map_element_to_attribs["kicker"] << kicker_attrib;
01472
01473 StrVec octupole_attrib;
01474 octupole_attrib << "l" << "tilt" << "k3" << "rel_tol" << "b3_gradient";
01475 map_element_to_attribs["octupole"] << pitch_attrib;
01476 map_element_to_attribs["octupole"] << kick_attrib;
01477 map_element_to_attribs["octupole"] << offset_attrib;
01478 map_element_to_attribs["octupole"] << method_attrib;
01479 map_element_to_attribs["octupole"] << track_attrib;
01480 map_element_to_attribs["octupole"] << descrip_attrib;
01481 map_element_to_attribs["octupole"] << scaled_mul_attrib;
01482 map_element_to_attribs["octupole"] << superimpose_attrib;
01483 map_element_to_attribs["octupole"] << octupole_attrib;
01484
01485 StrVec multipole_attrib;
01486 multipole_attrib << "l" << "tilt" << "k0l" << "k1l"
01487 << "k2l" << "k3l" << "k4l" << "k5l" << "k6l" << "k7l" << "k8l" << "k9l"
01488 << "k10l" << "k11l" << "k12l" << "k13l" << "k14l" << "k15l" << "k16l" << "k17l"
01489 << "k18l" << "k19l" << "k20l" << "t0" << "t1" << "t2" << "t3" << "t4"
01490 << "t5" << "t6" << "t7" << "t8" << "t9" << "t10" << "t11" << "t12"
01491 << "t13" << "t14" << "t15" << "t16" << "t17" << "t18" << "t19" << "t20";
01492 map_element_to_attribs["multipole"] << offset_attrib;
01493 map_element_to_attribs["multipole"] << method_attrib;
01494 map_element_to_attribs["multipole"] << descrip_attrib;
01495 map_element_to_attribs["multipole"] << superimpose_attrib;
01496 map_element_to_attribs["multipole"] << multipole_attrib;
01497
01498 StrVec ab_multipole_attrib;
01499 ab_multipole_attrib << "l" << "tilt";
01500 map_element_to_attribs["ab_multipole"] << offset_attrib;
01501 map_element_to_attribs["ab_multipole"] << method_attrib;
01502 map_element_to_attribs["ab_multipole"] << descrip_attrib;
01503 map_element_to_attribs["ab_multipole"] << ab_mul_attrib;
01504 map_element_to_attribs["ab_multipole"] << superimpose_attrib;
01505 map_element_to_attribs["ab_multipole"] << ab_multipole_attrib;
01506
01507 StrVec beam_attrib;
01508 beam_attrib << "particle" << "n_part" << "energy";
01509 map_element_to_attribs["beam"] << beam_attrib;
01510
01511 StrVec solenoid_attrib;
01512 solenoid_attrib << "l" << "ks" << "rel_tol" << "bs_field";
01513 map_element_to_attribs["solenoid"] << pitch_attrib;
01514 map_element_to_attribs["solenoid"] << kick_attrib;
01515 map_element_to_attribs["solenoid"] << offset_attrib;
01516 map_element_to_attribs["solenoid"] << method_attrib;
01517 map_element_to_attribs["solenoid"] << track_attrib;
01518 map_element_to_attribs["solenoid"] << descrip_attrib;
01519 map_element_to_attribs["solenoid"] << scaled_mul_attrib;
01520 map_element_to_attribs["solenoid"] << superimpose_attrib;
01521 map_element_to_attribs["solenoid"] << solenoid_attrib;
01522
01523 StrVec patch_attrib;
01524 patch_attrib << "l" << "tilt" << "z_offset" << "pz_offset";
01525 map_element_to_attribs["patch"] << pitch_attrib;
01526 map_element_to_attribs["patch"] << offset_attrib;
01527 map_element_to_attribs["patch"] << method_attrib;
01528 map_element_to_attribs["patch"] << descrip_attrib;
01529 map_element_to_attribs["patch"] << patch_attrib;
01530
01531 StrVec lcavity_attrib;
01532 lcavity_attrib << "l" << "tilt" << "gradient_err" << "coupler_angle"
01533 << "phi0_err" << "lrad" << "dphi0" << "rf_frequency" << "e_loss"
01534 << "gradient" << "phi0" << "delta_e" << "freq_spread"
01535 << "rel_tol" << "coupler_strength" << "coupler_phase"
01536 << "sr_wake_file" << "lr_wake_file" << "coupler_at";
01537 map_element_to_attribs["lcavity"] << pitch_attrib;
01538 map_element_to_attribs["lcavity"] << kick_attrib;
01539 map_element_to_attribs["lcavity"] << offset_attrib;
01540 map_element_to_attribs["lcavity"] << method_attrib;
01541 map_element_to_attribs["lcavity"] << track_attrib;
01542 map_element_to_attribs["lcavity"] << descrip_attrib;
01543 map_element_to_attribs["lcavity"] << lcavity_attrib;
01544
01545 StrVec parameter_attrib;
01546 parameter_attrib << "n_part" << "taylor_order" << "lattice_type"
01547 << "ran_seed" << "lattice";
01548 map_element_to_attribs["parameter"] << parameter_attrib;
01549
01550 StrVec match_attrib;
01551 match_attrib << "l" << "beta_a0" << "alpha_a0" << "beta_b0"
01552 << "alpha_b0" << "beta_a1" << "alpha_a1" << "beta_b1"
01553 << "alpha_b1" << "dphi_a" << "dphi_b" << "eta_a0"
01554 << "etap_a0" << "eta_b0" << "etap_b0" << "eta_a1"
01555 << "etap_a1" << "eta_b1" << "etap_b1";
01556 map_element_to_attribs["match"] << method_attrib;
01557 map_element_to_attribs["match"] << descrip_attrib;
01558 map_element_to_attribs["match"] << match_attrib;
01559
01560 StrVec monitor_attrib;
01561 monitor_attrib << "l" << "tilt" << "rel_tol";
01562 map_element_to_attribs["monitor"] << pitch_attrib;
01563 map_element_to_attribs["monitor"] << kick_attrib;
01564 map_element_to_attribs["monitor"] << offset_attrib;
01565 map_element_to_attribs["monitor"] << method_attrib;
01566 map_element_to_attribs["monitor"] << track_attrib;
01567 map_element_to_attribs["monitor"] << descrip_attrib;
01568 map_element_to_attribs["monitor"] << monitor_attrib;
01569
01570 StrVec instrument_attrib;
01571 instrument_attrib << "l" << "tilt" << "rel_tol";
01572 map_element_to_attribs["instrument"] << pitch_attrib;
01573 map_element_to_attribs["instrument"] << kick_attrib;
01574 map_element_to_attribs["instrument"] << offset_attrib;
01575 map_element_to_attribs["instrument"] << method_attrib;
01576 map_element_to_attribs["instrument"] << track_attrib;
01577 map_element_to_attribs["instrument"] << descrip_attrib;
01578 map_element_to_attribs["instrument"] << instrument_attrib;
01579
01580 StrVec hvkicker_attrib;
01581 hvkicker_attrib << "l" << "tilt" << "kick" << "rel_tol" << "bl_kick";
01582 map_element_to_attribs["hvkicker"] << method_attrib;
01583 map_element_to_attribs["hvkicker"] << track_attrib;
01584 map_element_to_attribs["hvkicker"] << descrip_attrib;
01585 map_element_to_attribs["hvkicker"] << scaled_mul_attrib;
01586 map_element_to_attribs["hvkicker"] << superimpose_attrib;
01587 map_element_to_attribs["hkicker"] << hvkicker_attrib;
01588 map_element_to_attribs["vkicker"] << hvkicker_attrib;
01589
01590 StrVec collimator_attrib;
01591 collimator_attrib << "l" << "rel_tol";
01592 collimator_attrib << kick_attrib;
01593 collimator_attrib << offset_attrib;
01594 collimator_attrib << method_attrib;
01595 collimator_attrib << track_attrib;
01596 collimator_attrib << descrip_attrib;
01597 map_element_to_attribs["rcollimator"] << collimator_attrib;
01598 map_element_to_attribs["ecollimator"] << collimator_attrib;
01599
01600 StrVec girder_attrib;
01601 girder_attrib << "tilt" << "s_center";
01602 map_element_to_attribs["girder"] << pitch_attrib;
01603 map_element_to_attribs["girder"] << offset_attrib;
01604 map_element_to_attribs["girder"] << descrip_attrib;
01605 map_element_to_attribs["girder"] << girder_attrib;
01606
01607 map_element_to_attribs["bend_sol_quad"] << pitch_attrib;
01608 map_element_to_attribs["bend_sol_quad"] << kick_attrib;
01609 map_element_to_attribs["bend_sol_quad"] << offset_attrib;
01610 map_element_to_attribs["bend_sol_quad"] << method_attrib;
01611 map_element_to_attribs["bend_sol_quad"] << track_attrib;
01612 map_element_to_attribs["bend_sol_quad"] << descrip_attrib;
01613 map_element_to_attribs["bend_sol_quad"] << scaled_mul_attrib;
01614 map_element_to_attribs["bend_sol_quad"] << superimpose_attrib;
01615 map_element_to_attribs["bend_sol_quad"] << "l" << "tilt" << "angle" << "k1" << "g"
01616 << "dks_ds" << "ks" << "rho" << "quad_tilt" << "bend_tilt"
01617 << "y_quad" << "rel_tol" << "x_quad";
01618 ;
01619
01620
01621 map_element_to_attribs["beam_start"] << "x" << "p_x" << "y" << "p_y" << "z" << "p_z";
01622
01623
01624
01625 int n_fact = 1;
01626 n_factorial.resize(N_MULTIPOLE);
01627
01628 for (int i = 0; i < 20; i++) {
01629 string order = int_to_string(i), n_f;
01630
01631 string a = "a" + order;
01632 string b = "b" + order;
01633 string n = "(n=" + order + ")";
01634 string x_to_aml, aml_to_x;
01635 if (i == 0 || i == 1) {
01636 x_to_aml = "";
01637 aml_to_x = "";
01638 } else {
01639 n_fact = n_fact * i;
01640 n_f = int_to_string(n_fact);
01641 n_factorial[i] = n_f;
01642 x_to_aml = "# * " + n_f;
01643 aml_to_x = "# / " + n_f;
01644 }
01645
01646 register_attribute("ab_multipole:" + a, "multipole:ksl" + n, x_to_aml, "", false, true);
01647 register_attribute("ab_multipole:" + b, "multipole:kl" + n, x_to_aml, "", false, true);
01648 register_attribute("sbend:" + a, "bend:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01649 register_attribute("sbend:" + b, "bend:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01650 register_attribute("rbend:" + a, "bend:scaled_multipole:ks_coef" + n, "", "", false, true);
01651 register_attribute("rbend:" + b, "bend:scaled_multipole:k_coef" + n, "", "", false, true);
01652 register_attribute("kicker:" + a, "kicker:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01653 register_attribute("kicker:" + b, "kicker:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01654 register_attribute("hkicker:" + a, "kicker:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01655 register_attribute("hkicker:" + b, "kicker:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01656 register_attribute("vkicker:" + a, "kicker:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01657 register_attribute("vkicker:" + b, "kicker:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01658 register_attribute("octupole:" + a, "octupole:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01659 register_attribute("octupole:" + b, "octupole:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01660 register_attribute("quadrupole:" + a, "quadrupole:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01661 register_attribute("quadrupole:" + b, "quadrupole:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01662 register_attribute("sextupole:" + a, "sextupole:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01663 register_attribute("sextupole:" + b, "sextupole:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01664 register_attribute("solenoid:" + a, "solenoid:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01665 register_attribute("solenoid:" + b, "solenoid:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01666 register_attribute("elseparator:" + a, "electric_kicker:scaled_multipole:ks_coef" + n, x_to_aml, aml_to_x);
01667 register_attribute("elseparator:" + b, "electric_kicker:scaled_multipole:k_coef" + n, x_to_aml, aml_to_x);
01668 }
01669
01670 register_attribute("sbend:radius", "bend:scaled_multipole:radius");
01671 register_attribute("rbend:radius", "bend:scaled_multipole:radius", "", "", false, true);
01672 register_attribute("kicker:radius", "kicker:scaled_multipole:radius");
01673 register_attribute("hkicker:radius", "kicker:scaled_multipole:radius");
01674 register_attribute("vkicker:radius", "kicker:scaled_multipole:radius");
01675 register_attribute("octupole:radius", "octupole:scaled_multipole:radius");
01676 register_attribute("quadrupole:radius", "quadrupole:scaled_multipole:radius");
01677 register_attribute("sextupole:radius", "sextupole:scaled_multipole:radius");
01678 register_attribute("solenoid:radius", "solenoid:scaled_multipole:radius");
01679 register_attribute("elseparator:radius", "electric_kicker:scaled_multipole:radius");
01680
01681
01682
01683 register_attribute("parameter:lattice", "lattice[label@string]");
01684 register_attribute("parameter:lattice_type", "lattice[geometry@type]");
01685 register_attribute("parameter:e_tot", "beam[total_energy]");
01686 register_attribute("parameter:particle", "beam[particle@type]");
01687 register_attribute("parameter:n_part", "beam[n_particles]");
01688 register_attribute("parameter:taylor_order", "parameter[taylor_order@value]");
01689 register_attribute("parameter:ran_seed", "parameter[ran_seed@value]");
01690
01691
01692
01693 register_attribute("beam_start:x", "beam[position:x]");
01694 register_attribute("beam_start:p_x", "beam[position:p_x]");
01695 register_attribute("beam_start:y", "beam[position:y]");
01696 register_attribute("beam_start:p_y", "beam[position:p_y]");
01697 register_attribute("beam_start:z", "beam[position:z]");
01698 register_attribute("beam_start:p_z", "beam[position:p_z]");
01699 register_attribute("beam_start:emittance_a", "beam[emittance_a]");
01700 register_attribute("beam_start:emittance_b", "beam[emittance_b]");
01701 register_attribute("beam_start:emittance_z", "beam[emittance_z]");
01702
01703
01704
01705 register_attribute("beginning:beta_a", "lattice[twiss:beta_a]");
01706 register_attribute("beginning:beta_b", "lattice[twiss:beta_b]");
01707 register_attribute("beginning:alpha_a", "lattice[twiss:alpha_a]");
01708 register_attribute("beginning:alpha_b", "lattice[twiss:alpha_b]");
01709 register_attribute("beginning:phi_a", "lattice[twiss:phase_a]");
01710 register_attribute("beginning:phi_b", "lattice[twiss:phase_b]");
01711 register_attribute("beginning:eta_a", "lattice[twiss:eta_a]");
01712 register_attribute("beginning:eta_b", "lattice[twiss:eta_b]");
01713 register_attribute("beginning:etap_a", "lattice[twiss:etap_a]");
01714 register_attribute("beginning:etap_b", "lattice[twiss:etap_b]");
01715 register_attribute("beginning:eta_x", "lattice[twiss:eta_x]");
01716 register_attribute("beginning:eta_y", "lattice[twiss:eta_y]");
01717 register_attribute("beginning:etap_x", "lattice[twiss:etap_x]");
01718 register_attribute("beginning:etap_y", "lattice[twiss:etap_y]");
01719 register_attribute("beginning:c11", "lattice[twiss:c11]");
01720 register_attribute("beginning:c12", "lattice[twiss:c12]");
01721 register_attribute("beginning:c21", "lattice[twiss:c21]");
01722 register_attribute("beginning:c22", "lattice[twiss:c22]");
01723 register_attribute("beginning:x_position", "lattice[floor:x]");
01724 register_attribute("beginning:y_position", "lattice[floor:y]");
01725 register_attribute("beginning:z_position", "lattice[floor:z]");
01726 register_attribute("beginning:theta_position", "lattice[floor:theta]");
01727 register_attribute("beginning:phi_position", "lattice[floor:phi]");
01728 register_attribute("beginning:psi_position", "lattice[floor:psi]");
01729 register_attribute("beginning:e_tot", "beam[total_energy]");
01730
01731
01732
01733 register_attribute("beam:n_part", "beam[n_particles]", "", "", false, true);
01734 register_attribute("beam:particle", "beam[particle@type]", "", "", false, true);
01735 register_attribute("beam:energy", "beam[total_energy]", "# * 1e9", "# * 1e-9", false, true);
01736
01737
01738
01739 register_attribute("alias", "description:alias@string");
01740 register_attribute("descrip", "description:descrip@string");
01741
01742 register_attribute("x_offset", "orientation:x_offset");
01743 register_attribute("y_offset", "orientation:y_offset");
01744 register_attribute("s_offset", "orientation:s_offset");
01745 register_attribute("x_pitch", "orientation:x_pitch");
01746 register_attribute("y_pitch", "orientation:y_pitch");
01747 register_attribute("roll", "orientation:roll");
01748
01749 register_attribute("beta_a0", "match:twiss(at=ENTRANCE):beta_a");
01750 register_attribute("alpha_a0", "match:twiss(at=ENTRANCE):alpha_a");
01751 register_attribute("eta_a0", "match:twiss(at=ENTRANCE):eta_a");
01752 register_attribute("etap_a0", "match:twiss(at=ENTRANCE):etap_a");
01753 register_attribute("beta_b0", "match:twiss(at=ENTRANCE):beta_b");
01754 register_attribute("alpha_b0", "match:twiss(at=ENTRANCE):alpha_b");
01755 register_attribute("eta_b0", "match:twiss(at=ENTRANCE):eta_b");
01756 register_attribute("etap_b0", "match:twiss(at=ENTRANCE):etap_b");
01757
01758 register_attribute("beta_a1", "match:twiss(at=EXIT):beta_a");
01759 register_attribute("alpha_a1", "match:twiss(at=EXIT):alpha_a");
01760 register_attribute("eta_a1", "match:twiss(at=EXIT):eta_a");
01761 register_attribute("etap_a1", "match:twiss(at=EXIT):etap_a");
01762 register_attribute("beta_b1", "match:twiss(at=EXIT):beta_b");
01763 register_attribute("alpha_b1", "match:twiss(at=EXIT):alpha_b");
01764 register_attribute("eta_b1", "match:twiss(at=EXIT):eta_b");
01765 register_attribute("etap_b1", "match:twiss(at=EXIT):etap_b");
01766
01767 register_attribute("dphi_a", "match:twiss(at=EXIT):phi_a");
01768 register_attribute("dphi_b", "match:twiss(at=EXIT):phi_b");
01769
01770 register_attribute("superimpose", "", "", "", true, false);
01771 register_attribute("ref_beginning", "", "", "", true, false);
01772 register_attribute("ref_center", "", "", "", true, false);
01773 register_attribute("ref_end", "", "", "", true, false);
01774 register_attribute("ele_beginning", "", "", "", true, false);
01775 register_attribute("ele_center", "", "", "", true, false);
01776 register_attribute("ele_end", "", "", "", true, false);
01777 register_attribute("reference", "", "", "", true, false);
01778 register_attribute("offset", "", "", "", true, false);
01779 register_attribute("ref", "", "", "", true, false);
01780
01781 register_attribute("group:command", "", "", "", true, false);
01782 register_attribute("group:old_command", "", "", "", true, false);
01783 register_attribute("group:value", "@design");
01784 register_attribute("overlay:value", "@design");
01785
01786 register_attribute("tracking_method", "methods:tracking_method@string");
01787 register_attribute("mat6_calc_method", "methods:map_creation_method@string");
01788 register_attribute("symplectify", "methods:symplectify@logical");
01789 register_attribute("integrator_order", "methods:itegrator_order@value");
01790 register_attribute("num_steps", "methods:num_steps");
01791 register_attribute("ds_step", "methods:ds_step");
01792 register_attribute("rel_tol", "methods:relative_tollerance");
01793 register_attribute("abs_tol", "methods:absolute_tollerance");
01794
01795 register_attribute("polarity", "wiggler:polarity");
01796
01797 register_attribute("patch:pz_offset", "orientation:pz_offset");
01798
01799 register_attribute("lcavity:gradient", "rf_cavity:gradient");
01800 register_attribute("lcavity:gradient_err", "rf_cavity:gradient@err");
01801 register_attribute("eloss", "rf_cavity:e_loss");
01802 register_attribute("rfcavity:voltage", "rf_cavity:gradient", "# / ![length]", "# * ![l]");
01803 register_attribute("rf_frequency", "rf_cavity:rf_freq");
01804 register_attribute("eloss", "rf_cavity:e_loss");
01805 register_attribute("phi0", "rf_cavity:phase0");
01806 register_attribute("phi0_err", "rf_cavity:phase0@err");
01807 register_attribute("dphi0", "rf_cavity:phase0_offset");
01808
01809 register_attribute("b_max", "wiggler:wiggler_params:b_max");
01810 register_attribute("l_pole", "wiggler:wiggler_params:length_pole");
01811 register_attribute("n_pole", "wiggler:wiggler_params:length_pole",
01812 "![length] / #", "# / ![l]", false, true);
01813
01814 register_attribute("is_on", "state@is_on");
01815
01816 register_attribute("hkick", "kicker:x_kick");
01817 register_attribute("vkick", "kicker:y_kick");
01818 register_attribute("bl_hkick", "kicker:x_kick_u");
01819 register_attribute("bl_vkick", "kicker:y_kick_u");
01820
01821 register_attribute("elseparator:hkick", "electric_kicker:x_kick");
01822 register_attribute("elseparator:vkick", "electric_kicker:y_kick");
01823 register_attribute("elseparator:bl_hkick", "electric_kicker:x_kick_u");
01824 register_attribute("elseparator:bl_vkick", "electric_kicker:y_kick_u");
01825 register_attribute("elseparator:gap", "electric_kicker:gap");
01826
01827 register_attribute("hkicker:bl_kick", "kicker:x_kick_u");
01828 register_attribute("vkicker:bl_kick", "kicker:y_kick_u");
01829
01830 register_attribute("bend_sol_quad:bend_tilt", "bend:orientation:tilt");
01831 register_attribute("bend_sol_quad:x_quad", "quadrupole:orientation:x_offset");
01832 register_attribute("bend_sol_quad:y_quad", "quadrupole:orientation:y_offset");
01833 register_attribute("bend_sol_quad:quad_tilt", "quadrupole:orientation:tilt");
01834 register_attribute("bend_sol_quad:dks_ds", "solenoid:dks");
01835
01836 register_attribute("g", "bend:g");
01837 register_attribute("g_err", "bend:g@err");
01838 register_attribute("rho", "bend:rho");
01839 register_attribute("sbend:angle", "bend:angle");
01840
01841 register_attribute("b1_gradient", "quadrupole:k_u");
01842 register_attribute("b2_gradient", "sextupole:k_u");
01843 register_attribute("b3_gradient", "octupole:k_u");
01844 register_attribute("b_field", "bend:g_u");
01845 register_attribute("b_field_err", "bend:g_u@err");
01846 register_attribute("bs_field", "solenoid:ks_u");
01847
01848 register_attribute("beambeam:sig_x", "beambeam:sig_x");
01849 register_attribute("beambeam:sig_y", "beambeam:sig_y");
01850 register_attribute("beambeam:sig_z", "beambeam:sig_z");
01851 register_attribute("beambeam:n_slice", "beambeam:n_slice");
01852 register_attribute("beambeam:charge", "beambeam:rel_charge");
01853
01854 register_attribute("aperture", "aperture:xy_limit");
01855 register_attribute("x1_limit", "aperture:x_limit(side=-)");
01856 register_attribute("y1_limit", "aperture:y_limit(side=-)");
01857 register_attribute("x2_limit", "aperture:x_limit(side=+)");
01858 register_attribute("y2_limit", "aperture:y_limit(side=+)");
01859 register_attribute("x_limit", "aperture:x_limit");
01860 register_attribute("y_limit", "aperture:y_limit");
01861 register_attribute("aperture_at", "aperture@at");
01862 register_attribute("", "aperture@shape", "", "", true, true);
01863 register_attribute("", "aperture@shape", "", "", true, true);
01864
01865
01866
01867 register_attribute("", "beam[mass]", "", "", false, true);
01868 register_attribute("", "beam[charge]", "", "", false, true);
01869 register_attribute("", "beam[pc]", "", "", false, true);
01870 register_attribute("", "beam[gamma]", "", "", false, true);
01871 register_attribute("", "beam[emittance_a]", "", "", false, true);
01872 register_attribute("", "beam[norm_emittance_a]", "", "", false, true);
01873 register_attribute("", "beam[emittance_b]", "", "", false, true);
01874 register_attribute("", "beam[norm_emittance_b]", "", "", false, true);
01875 register_attribute("", "beam[emittance_z]", "", "", false, true);
01876 register_attribute("", "beam[sig_t]", "", "", false, true);
01877 register_attribute("", "beam[sig_e]", "", "", false, true);
01878 register_attribute("", "beam[n_bunches]", "", "", false, true);
01879 register_attribute("", "beam[n_particles]", "", "", false, true);
01880 register_attribute("", "beam[bunch_current]", "", "", false, true);
01881 register_attribute("", "beam[bunched@logical]", "", "", false, true);
01882 register_attribute("", "beam[radiate@logical]", "", "", false, true);
01883
01884
01885
01886 register_param_value_conversion ("LINEAR_LATTICE", "LINEAR");
01887 register_param_value_conversion ("CIRCULAR_LATTICE", "CIRCULAR");
01888 register_param_value_conversion ("ENTRANCE_END", "ENTRANCE");
01889 register_param_value_conversion ("BOTH_ENDS", "BOTH");
01890 register_param_value_conversion ("EXIT_END", "EXIT");
01891 register_param_value_conversion ("f", "false");
01892 register_param_value_conversion ("t", "true");
01893
01894 x_attribs_that_can_have_default << "tilt" << "fint"
01895 << "fintx" << "charge" << "radiate" << "bunched"
01896 << "superimpose" << "ref_beginning" << "ref_center" << "ref_end"
01897 << "ele_beginning" << "ele_center" << "ele_end";
01898
01899
01900
01901 register_constant("degrad", "pi", "pi / 180", "", false, true);
01902 register_constant("raddeg", "degrees", "", "", false, true);
01903 register_constant("emass", "m_electron", "m_electron * 1e-6", "", false, true);
01904 register_constant("pmass", "m_proton", "m_proton * 1e-6", "", false, true);
01905 register_constant("clight", "c_light", "", "", false, true);
01906
01907 }