Changeset 7 in ZHANGProjects
- Timestamp:
- Mar 25, 2014, 11:22:11 AM (10 years ago)
- Location:
- ICOSIM/CPP/trunk
- Files:
-
- 2 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
ICOSIM/CPP/trunk
-
Property
svn:ignore
set to
outputs
-
Property
svn:ignore
set to
-
ICOSIM/CPP/trunk/sample
-
Property
svn:ignore
set to
crossSectionInfos
-
Property
svn:ignore
set to
-
ICOSIM/CPP/trunk/source
-
Property
svn:ignore
set to
icosim++
twiss_optics
testCollimator
debug
testElement
testParticle
source.kdev4
testLattice
readme
-
Property
svn:ignore
set to
-
ICOSIM/CPP/trunk/source/.kdev4/source.kdev4
r5 r7 1 1 [Buildset] 2 BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x10\x00I\x00C\x00O\x00S\x00Y\x00M\x00+\x00+) 2 BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) 3 4 [Launch] 5 Launch Configurations=Launch Configuration 0 6 7 [Launch][Launch Configuration 0] 8 Configured Launch Modes=execute 9 Configured Launchers=nativeAppLauncher 10 Name=New Native Application Configuration 11 Type=Native Application 12 13 [Launch][Launch Configuration 0][Data] 14 Arguments=../sample/collimatorfile_standard_ions_nominal.csv ../outputs 15 Dependencies=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00) 16 Dependency Action=Nothing 17 EnvironmentGroup=default 18 Executable=icosim++ 19 External Terminal=konsole --noclose --workdir %workdir -e %exe 20 Project Target= 21 Use External Terminal=false 22 Working Directory=file:///home/jfz/codes/ICOSIMPP/CPP/source 23 isExecutable=true 24 25 [Project] 26 VersionControlSupport=kdevsubversion -
ICOSIM/CPP/trunk/source/Particle.cc
r5 r7 9 9 //==================================Constructors, destructor==================================== 10 10 11 /* 12 Initialize the 6-D particle coordinates. 13 */ 11 14 Particle::Particle(double x, double dx, double y, double dy, double deltaE, double t, double mass, double charge, double moment) 12 15 : Ap0(mass), Zp0(charge), dpoporiginal(moment) … … 123 126 } 124 127 125 128 /* 129 set the ID of the registed particle ID. 130 */ 126 131 void Particle::setidentification(int id) 127 132 { -
ICOSIM/CPP/trunk/source/StandardCollimator.cc
r5 r7 25 25 { 26 26 27 long double ca , sa;27 long double ca=0.0, sa=0.0; 28 28 29 29 sa = sin(this->tcang); … … 34 34 p1.coordonnees[0][2] = p1.coordonnees[0][2] - scaleorbit * this->YC; 35 35 36 long double xl , xsl, alf, lcolleff;36 long double xl=0.0, xsl=0.0, alf=0.0, lcolleff=0.0; 37 37 38 38 … … 109 109 110 110 //Apply thin collimator at impact position 111 111 /* Initialize the 6-D particle coordinates*/ 112 112 Particle ptemp(xint, xsint, yint, ysint, p1.coordonnees[0][4], 0, p1.Ap0, p1.Zp0, p1.coordonnees[0][4]); 113 113 -
ICOSIM/CPP/trunk/source/lattice.cc
r5 r7 269 269 270 270 271 271 /* 272 * 273 */ 272 274 void Lattice::trackensemblelinearnew(vector <Particle>& bunch, vector <Particle>& bunchhit, const int& nrev, const double& blowup2, const int& blowupperiod) 273 275 { 274 276 275 int nip, niph, nrevhitp; 277 /*nip: number of primary collimators in the accelerator; niph: number of primary collimators hit by the particles; nrevhitp: number of turns when the particle hit the primary collimators */ 278 int nip=0, niph=0, nrevhitp=0; 276 279 vector <int> iph; 277 double blowup ;280 double blowup=0.0; /* sqrt(blowup2), beam blow up strength*/ 278 281 279 282 //we only take the primary collimators into account here, as well as the first and the last elements of the lattice … … 331 334 if (bunch[p].in == 1) { //to assure the particle is still remainding in the accelerator 332 335 333 long double pdepth , pdepth2;336 long double pdepth=0.0, pdepth2=0.0; 334 337 335 338 bunch[p].coordonnees[1][0] = R11X[i] * bunch[p].coordonnees[0][0] + R12X[i] * bunch[p].coordonnees[0][1] + (reseau[iph[i + 1]]->DX - R11X[i] * reseau[iph[i]]->DX - R12X[i] * reseau[iph[i]]->DPX) * bunch[p].coordonnees[0][4]; … … 339 342 340 343 if (i < niph - 1) { 341 long double lcoll , sa, ca;344 long double lcoll=0.0, sa=0.0, ca=0.0; 342 345 343 346 sa = sin(resColli[ipcoll[i]]->tcang);//sinus of the collimator's angle … … 416 419 if ((k + 1) % blowupperiod == 0) { //blowup/diffusion 417 420 if (bunch[p].in == 1) { 418 //cout << "Blow-up!!" << k+1 << endl;421 // cout << "Blow-up!!" << k+1 << endl; 419 422 int im; 420 423 im = reseau.size() - 1; -
ICOSIM/CPP/trunk/source/simulation.cc
r5 r7 35 35 36 36 for (int l(0); l < sizeBunch; ++l) { 37 37 /* generate the particle distributions */ 38 38 p1.genpartdist(1, 1, genere, 1.00095, 1.2e-8, 1.2e-8, 0.00011, bx, ax, dx, dpx, by, ay, dy, dpy, 6); 39 39 p1.afficheFirstCoordonnees(); … … 67 67 68 68 69 /* 70 void Simulation::readParticle(const double& Apr, const double& Zpr, string inputfile) 71 72 */ 69 73 void Simulation::readParticle(const double& Apr, const double& Zpr, string inputfile) 70 74 { … … 536 540 537 541 538 double Apr, Zpr, mass, energyPerIon, emix, emiy, sigdpp, r1r2skin, blowup2, thicknessmagneticfield, Bmax, deltaGap, gamma, betgam, W, PlossPb, freqrf, rfvoltage, rfharmonic, wecolli, nsigi, momentum; 539 int npart, kbunch, taubeam, nparti, nrev1, nrev2, blowupperiod, scaleorbit, beamflag, stopLinearTrackingNo, RunWithFluka, RunWithCrystal, RunningFlag, outcoord, idpart, idelt, RFflag; 540 string partdistr, stoplineartracking, crosssectionspath, opticsFile, plotflag, inputpath; 542 double Apr=0.0, Zpr=0.0, mass=0.0, energyPerIon=0.0, emix=0.0, emiy=0.0, sigdpp=0.0, 543 r1r2skin=0.0, blowup2=0.0, thicknessmagneticfield=0.0, Bmax=0.0, deltaGap=0.0, 544 gamma=0.0, betgam=0.0, W, PlossPb, freqrf=0.0, rfvoltage=0.0, rfharmonic=0.0, 545 wecolli=0.0, nsigi=0.0, momentum=0.0; 546 int npart=0, kbunch=0, taubeam=0, nparti=0, nrev1=0, nrev2=0, blowupperiod=0, scaleorbit=0, 547 beamflag=1, stopLinearTrackingNo=0, RunWithFluka=0, RunWithCrystal=0, RunningFlag=1, 548 outcoord=0, idpart=0, idelt=0, RFflag=0; 549 string partdistr="", stoplineartracking="", crosssectionspath="", opticsFile="", plotflag="", inputpath=""; 541 550 542 551 int indication(1); … … 1173 1182 { 1174 1183 1175 1176 int JohnJaperFlag ;1184 //for the moment, ICOSIM++ cannot run without aperture parameters, so JohnJaperflag is fixed to 1; the variable is still here to facilitate further developpment 1185 int JohnJaperFlag=1; 1177 1186 1178 1187 defineParameters(opticsFile, beamflag, JohnJaperFlag); 1179 1188 1180 1189 bool apertureIsZero(false); 1181 int temp1(0); 1182 int temp2(0); 1183 int temp3; 1184 1190 int temp1 = 0; 1191 int temp2 = 0; 1192 int temp3 = 0; 1193 1194 1185 1195 if (JohnJaperFlag == 1) { //JohnJaperflag=1 if we have information about the aperture 1186 1196 1187 1197 for (int w(0); w < nbre_elts; ++w) { 1188 1198 if (lat.reseau[w]->APERTYPE == "RECTELLIPSE") { 1189 ++temp1;1199 temp1 = temp1 + 1; 1190 1200 if ((lat.reseau[w]->APER_1 == 0) && (lat.reseau[w]->APER_2 == 0) && (lat.reseau[w]->APER_3 == 0) && (lat.reseau[w]->APER_4 == 0)) { 1191 ++temp2; 1192 } else { 1193 break; 1194 } 1195 } else { 1196 break; 1197 } 1201 temp2 = temp2 + 1; 1202 } 1203 // else { 1204 // break; 1205 // } 1206 } 1207 // else { 1208 // break; 1209 // } 1198 1210 } 1199 1211 1200 1212 //If all apertures are RECTELLIPSES: 1201 //If an apeture variable is 0, it takes the value of the preceeding aperture variable.1202 // If all the apertures are 0, we define them to be 1 instead.1213 //If all the aperture variables of all lattice elements are 0, we define them to be 1 instead. 1214 // If an apeture variable is 0, it takes the value of the preceeding aperture variable. 1203 1215 1204 1216 if (temp1 == nbre_elts) { … … 1214 1226 if (lat.reseau[0]->APER_1 == 0) { 1215 1227 apertureIsZero = true; 1216 temp3 = nbre_elts ;1217 while(lat.reseau[temp3]->APER_1 == 0) {1228 temp3 = nbre_elts -1; 1229 if (lat.reseau[temp3]->APER_1 == 0) { 1218 1230 temp3 = temp3 - 1; 1219 1231 } … … 1222 1234 if (lat.reseau[0]->APER_2 == 0) { 1223 1235 apertureIsZero = true; 1224 temp3 = nbre_elts ;1225 while(lat.reseau[temp3]->APER_2 == 0) {1236 temp3 = nbre_elts -1; 1237 if (lat.reseau[temp3]->APER_2 == 0) { 1226 1238 temp3 = temp3 - 1; 1227 1239 } … … 1230 1242 if (lat.reseau[0]->APER_3 == 0) { 1231 1243 apertureIsZero = true; 1232 temp3 = nbre_elts ;1233 while(lat.reseau[temp3]->APER_3 == 0) {1244 temp3 = nbre_elts -1; 1245 if (lat.reseau[temp3]->APER_3 == 0) { 1234 1246 temp3 = temp3 - 1; 1235 1247 } … … 1238 1250 if (lat.reseau[0]->APER_4 == 0) { 1239 1251 apertureIsZero = true; 1240 temp3 = nbre_elts ;1241 while(lat.reseau[temp3]->APER_4 == 0) {1252 temp3 = nbre_elts - 1; 1253 if (lat.reseau[temp3]->APER_4 == 0) { 1242 1254 temp3 = temp3 - 1; 1243 1255 } … … 1279 1291 } 1280 1292 } else if (lat.reseau[r]->APERTYPE == "NONE") { 1293 1294 if(r==0){ 1295 lat.reseau[r]->APER_1 = lat.reseau[nbre_elts]->APER_1; 1296 lat.reseau[r]->APER_2 = lat.reseau[nbre_elts]->APER_2; 1297 lat.reseau[r]->APER_3 = lat.reseau[nbre_elts]->APER_3; 1298 lat.reseau[r]->APER_4 = lat.reseau[nbre_elts]->APER_4; 1299 lat.reseau[r]->APERTYPE = lat.reseau[nbre_elts]->APERTYPE; 1300 }else{ 1281 1301 lat.reseau[r]->APER_1 = lat.reseau[r - 1]->APER_1; 1282 1302 lat.reseau[r]->APER_2 = lat.reseau[r - 1]->APER_2; … … 1284 1304 lat.reseau[r]->APER_4 = lat.reseau[r - 1]->APER_4; 1285 1305 lat.reseau[r]->APERTYPE = lat.reseau[r - 1]->APERTYPE; 1306 } 1286 1307 } 1287 1308 } … … 1291 1312 } 1292 1313 1293 //we compute the final apertures 1314 //we compute the final apertures; different aperture type 1294 1315 for (int i(0); i < lat.reseau.size(); ++i) { 1295 1316 if (lat.reseau[i]->APERTYPE == "CIRCLE") { … … 1504 1525 } 1505 1526 1506 double hk ;1527 double hk=0.0; 1507 1528 1508 1529 for (int k(0); k < indice.size(); ++k) { … … 1529 1550 } 1530 1551 1531 double vk ;1552 double vk=0.0; 1532 1553 1533 1554 for (int k(0); k < indice.size(); ++k) { … … 1541 1562 1542 1563 } 1543 1564 /*************************************************************************** 1565 * 1566 * Read the lattice elements parameters 1567 * 1568 * 1569 * 1570 * 1571 * Jianfeng Zhang @ LAL, 21/03/2014 1572 * Fix the bug to read the lattice element parameters. 1573 * 1574 ***************************************************************************/ 1544 1575 void Simulation::defineParameters(string opticsFile, const int& beamflag, int& JohnJaperFlag) 1545 1576 { 1546 1577 1547 1578 ifstream entree; 1548 string APERTYPE , name, KEYWORD, PARENT;1579 string APERTYPE="", name="", KEYWORD="", PARENT=""; 1549 1580 entree.open(opticsFile.c_str()); 1550 1581 … … 1553 1584 } else { 1554 1585 1555 string name , temp;1556 string strtemp , strtemp1;1557 1586 string name="", temp=""; 1587 string strtemp="", strtemp1=""; 1588 /* read the parameters at the beginning of the MADX twiss file*/ 1558 1589 getline(entree, strtemp, ','); 1559 1590 while ((strtemp != "NAME") && (strtemp != "ALFX") && (strtemp != "S") && (strtemp != "L") && (strtemp != "K0L") && (strtemp != "K0SL") && (strtemp != "K1L") && (strtemp != "K1SL") && (strtemp != "K2L") && (strtemp != "K2SL") && (strtemp != "XC") && (strtemp != "PXC") && (strtemp != "KEYWORD") && (strtemp != "PARENT") && (strtemp != "YC") && (strtemp != "PYC") && (strtemp != "TC") && (strtemp != "PTC") && (strtemp != "BETX") && (strtemp != "MUX") && (strtemp != "DX") && (strtemp != "DPX") && (strtemp != "BETY") && (strtemp != "ALFY") && (strtemp != "MUY") && (strtemp != "DY") && (strtemp != "DPY") && (strtemp != "APERTYPE") && (strtemp != "APER_1") && (strtemp != "APER_2") && (strtemp != "APER_3") && (strtemp != "APER_4")) { … … 1561 1592 getline(entree, strtemp, ','); 1562 1593 } 1563 1564 double S, L, K0L, K0SL, K1L, K1SL, K2L, K2SL, XC, PXC, YC, PYC, TC, PTC, BETX, ALFX, MUX, DX, DPX, BETY, ALFY, MUY, DY, DPY, APER_1, APER_2, APER_3, APER_4; 1594 /* read the parameters of the lattice elements*/ 1595 double S=0.0, L=0.0, K0L=0.0, K0SL=0.0, K1L=0.0, K1SL=0.0, K2L=0.0, K2SL=0.0, XC=0.0, PXC=0.0, YC=0.0, PYC=0.0, TC=0.0, PTC=0.0, 1596 BETX=0.0, ALFX=0.0, MUX=0.0, DX=0.0, DPX=0.0, BETY=0.0, ALFY=0.0, MUY=0.0, DY=0.0, DPY=0.0, APER_1=0.0, APER_2=0.0, APER_3=0.0, APER_4=0.0; 1565 1597 1566 1598 int taille(0); … … 1612 1644 } 1613 1645 getline(entree, strtemp); 1646 /* remove the "\r" symbol from the last variable in the "*.csv file", 1647 maybe this is a potential bug for other file format... By jianfeng Zhang @ LAL, 21/03/2014*/ 1648 strtemp = strtemp.substr(0,strtemp.size()-1); 1614 1649 header.push_back(strtemp); 1615 1650 … … 1623 1658 } 1624 1659 1660 /*start read the lattice elements parameters*/ 1625 1661 while (!entree.eof()) { 1626 ++taille; 1662 1663 1664 ++taille; 1665 /* lattice elment*/ 1627 1666 for (int n(0); n < 31; ++n) { 1628 1667 getline(entree, strtemp, ','); 1629 1668 vectemp.push_back(strtemp); 1630 1669 } 1670 /* last variable of the lattice element */ 1631 1671 getline(entree, strtemp); 1672 /* remove the "\r" symbol from the last variable in the "*.csv file", 1673 maybe this is a potential bug for other file format... By jianfeng Zhang @ LAL, 21/03/2014*/ 1674 strtemp = strtemp.substr(0,strtemp.size()-1); 1632 1675 vectemp.push_back(strtemp); 1633 1676 1677 1634 1678 for (int h(0); h < order.size(); ++h) { 1635 1679 … … 1701 1745 } 1702 1746 1747 /*to fix the bug that: the c++ code can't stop when the end of fine is reached in the *.csv files 1748 by Jianfeng zhang @ LAL, 21/03/2014 1749 */ 1750 if(name.substr(0, 1) =="\r" || name.substr(0, 1) =="\n") 1751 { 1752 vectemp.clear(); 1753 taille = taille - 1; 1754 break; 1755 } 1756 1757 1758 1703 1759 Element elt(ALFX, ALFY, APER_1, APER_2, APER_3, APER_4, APERTYPE, BETX, BETY, DPX, DPY, DX, DY, KEYWORD, L, MUX, MUY, name, PTC, PXC, PYC, S, TC, XC, YC, K0L, K0SL, K1L, K1SL, K2L, K2SL, PARENT); 1704 1760 … … 1707 1763 vectemp.clear(); 1708 1764 1709 if ((name.substr(0, 3) == "END") || (name.substr(name.size() - 3, 3) == "END")) { 1710 break; 1711 } 1712 1713 } 1765 if (name == "LHCB1$END") { 1766 cout << name << " "<<taille<<endl; 1767 } 1768 1769 } 1770 1771 /*number of lattice elements*/ 1714 1772 this ->nbre_elts = taille; 1715 1773 }
Note: See TracChangeset
for help on using the changeset viewer.