Changeset 333 in PSPA for Interface_Web
- Timestamp:
- Feb 20, 2013, 11:21:23 AM (11 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/include/softwareTest.h
r316 r333 12 12 13 13 softwareTest(); 14 15 bool beamToParin(string workingDir, particleBeam* beam ); 16 bool beamFromParin(string workingDir, vector<bareParticle>& particles ); 14 17 15 18 public : -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareParmela.cc
r316 r333 121 121 bool softwareParmela::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) { 122 122 bool result = true; 123 unsigned k; 124 125 for ( k= numeroDeb; k <= numeroFin; k++) 126 { 127 beams.push_back(particleBeam()); 128 vector<double> centroid; 129 bareParticle refPart; 130 vector<bareParticle> particles; 131 if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles )) 132 { 133 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 134 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 135 int avantDernier = beams.size() -2; 136 beams.back() = beams.at(avantDernier); 137 } else { 138 // sortie << " reading parmdesz failed " << endl; 139 dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz failed " ); 140 result = false; 141 break; 142 } 143 } 144 else { 145 beams.back().setWithParticles(centroid, refPart,particles); 146 } 123 unsigned k; 124 125 for ( k= numeroDeb; k <= numeroFin; k++) 126 { 127 beams.push_back(particleBeam()); 128 vector<double> centroid; 129 bareParticle refPart; 130 vector<bareParticle> particles; 131 if (!beamFromParmela(workingDir,k - offsetNumElem_ , globParamPtr_->getFrequency(), centroid, refPart,particles )) 132 { 133 abstractElement* elem = dataManager_->getElementPointerFromNumero(k); 134 if ( elem->is_accepted_by_software(nomDeLogiciel::parmela) == warning) { 135 int avantDernier = beams.size() -2; 136 beams.back() = beams.at(avantDernier); 137 } else { 138 // sortie << " reading parmdesz failed " << endl; 139 dataManager_->consoleMessage(" softwareParmela::buildBeamAfterElements : reading parmdesz failed " ); 140 result = false; 141 break; 147 142 } 148 return result; 143 } 144 else { 145 beams.back().setWithParticles(centroid, refPart,particles); 146 } 147 } 148 return result; 149 149 } 150 150 … … 274 274 unsigned k; 275 275 double weight = 1.0; 276 cout << " ICI sortie des particules " << endl;277 276 double xx,yy,zz; 278 277 double begamx, begamy, begamz; -
Interface_Web/trunk/pspaWT/sources/controler/src/softwareTest.cc
r316 r333 22 22 { 23 23 dataManager_->consoleMessage(" softwareTest::createInputFile " ); 24 25 beamToParin(workingDir, beamBefore ); 26 27 28 24 29 return true; 25 30 } … … 31 36 32 37 bool softwareTest::buildBeamAfterElements(unsigned int numeroDeb,unsigned int numeroFin, vector<particleBeam>& beams, string workingDir) { 33 dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements " ); 38 dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements " ); 39 bool result = true; 40 unsigned k; 41 for ( k= numeroDeb; k <= numeroFin; k++) 42 { 43 beams.push_back(particleBeam()); 44 vector<double> centroid = vector<double>(6,0.0); 45 bareParticle refPart; 46 vector<bareParticle> particles; 47 48 49 if (!beamFromParin(workingDir,particles ) ) 50 { 51 dataManager_->consoleMessage(" softwareTest::buildBeamAfterElements : reading parin failed " ); 52 result = false; 53 break; 54 } 55 else { 56 bareParticle refPart (particles.at(0)); 57 beams.back().setWithParticles(centroid, refPart,particles); 58 } 59 } 60 return result; 61 } 62 63 // sauvegarde d'un 'particleBeam' sur un fichier parmela, en guise d'INPUT 64 // pour l'instant de nom standard 'parin.input0' 65 bool softwareTest::beamToParin(string workingDir, particleBeam* beam ) { 66 if ( !beam->particleRepresentationOk() ) { 67 dataManager_->consoleMessage("softwareParmela::beamToParmela : beam not in particles form : not yet programmed"); 68 cout << " softwareParmela::beamToParmela : beam not in particles form : not yet programmed " << endl; 69 return false; 70 } 71 ofstream outfile; 72 string name = workingDir + "parin.input0"; 73 outfile.open(name.c_str(), ios::out); 74 if (!outfile) { 75 dataManager_->consoleMessage(" softwareTest::beamToParin : error opening in stream "); 76 cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl; 77 return false; 78 } 79 80 const vector<bareParticle>& partic = beam->getParticleVector(); 81 unsigned k; 82 double weight = 1.0; 83 double xx,yy,zz; 84 double begamx, begamy, begamz; 85 for ( k=0; k < partic.size(); k++) { 86 partic.at(k).getPosition().getComponents(xx,yy,zz); 87 partic.at(k).getBetaGamma().getComponents(begamx, begamy, begamz); 88 outfile << xx << " " << begamx << " " << yy << " " << begamy << " " << zz << " " << begamz << " " << weight << endl; 89 } 90 outfile.close(); 34 91 return true; 35 92 } 93 94 bool softwareTest::beamFromParin(string workingDir, vector<bareParticle>& particles ) { 95 ifstream infile; 96 string name = workingDir + "parin.input0"; 97 infile.open(name.c_str(), ios::in); 98 if (!infile) { 99 dataManager_->consoleMessage(" softwareParmela::beamToParmela : error opening output stream "); 100 cerr << " softwareParmela::beamToParmela : error opening output stream " << name << endl; 101 return false; 102 } 103 104 particles.clear(); 105 double weight; 106 double xx,yy,zz; 107 double begamx, begamy, begamz; 108 TRIDVECTOR pos; 109 TRIDVECTOR betagamma; 110 while ( infile >> xx >> begamx >> yy >> begamy >> zz >> begamz >> weight) { 111 pos.setComponents(xx,yy,zz); 112 betagamma.setComponents(begamx, begamy, begamz); 113 particles.push_back(bareParticle(pos,betagamma)); 114 } 115 infile.close(); 116 return true; 117 } -
Interface_Web/trunk/pspaWT/sources/userInterface/include/GWt_pspaApplication.h
r324 r333 50 50 WComboBox* choixElementDessin_; 51 51 WComboBox* choixTypeDessinFaisceau_; 52 WComboBox* choixAbsPhase_; 53 WComboBox* choixOrdPhase_; 52 54 WComboBox* choixEnveloppeDessin_; 53 55 WComboBox* choixHistoDessin_; … … 77 79 78 80 void dialogOnGraphics(); 79 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam);81 void faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd ); 80 82 void faireDessinTransport(WContainerWidget* toto, particleBeam* beam); 81 83 void faireDessinEnveloppe(WContainerWidget* toto, string type); … … 89 91 void dessinerHistogramme(); 90 92 93 94 95 96 91 97 public : 92 98 93 99 PspaApplication(const WEnvironment& env); 100 94 101 95 102 string getSelection(); -
Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_pspaApplication.cc
r324 r333 240 240 choixTypeDessinFaisceau_->addItem("macroparticles"); 241 241 Wt::WRadioButton *button2= new WRadioButton(" phase space after element"); 242 243 choixAbsPhase_ = new WComboBox(); 244 choixAbsPhase_->addItem("x"); 245 choixAbsPhase_->addItem("y"); 246 choixAbsPhase_->addItem("z"); 247 choixAbsPhase_->addItem("xp"); 248 choixAbsPhase_->addItem("yp"); 249 choixAbsPhase_->addItem("dE/E"); 250 251 choixOrdPhase_ = new WComboBox(); 252 choixOrdPhase_->addItem("x"); 253 choixOrdPhase_->addItem("y"); 254 choixOrdPhase_->addItem("z"); 255 choixOrdPhase_->addItem("xp"); 256 choixOrdPhase_->addItem("yp"); 257 choixOrdPhase_->addItem("dE/E"); 258 259 260 242 261 group_->addButton(button2,2); 243 262 glayout->addWidget(button2,1,1); 244 263 glayout->addWidget(choixElementDessin_,1,2); 245 264 glayout->addWidget(choixTypeDessinFaisceau_,1,3); 265 266 glayout->addWidget(choixAbsPhase_,1,4); 267 glayout->addWidget(choixOrdPhase_,1,5); 246 268 ///////////////////////////////////////////////////////////////////// 247 269 … … 455 477 toto_->clear(); 456 478 457 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 479 int typeFaisceau = choixTypeDessinFaisceau_->currentIndex(); 458 480 int index = choixElementDessin_->currentIndex(); 481 unsigned xabs = choixAbsPhase_->currentIndex(); 482 unsigned yord = choixOrdPhase_->currentIndex(); 483 459 484 particleBeam* beam = dtmanage_->getDiagnosticBeam(index); 460 485 … … 464 489 return; 465 490 } 466 491 492 467 493 if ( typeFaisceau == 0 ) 468 494 { … … 472 498 else if ( typeFaisceau == 1 ) 473 499 { 474 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam );500 if ( beam->particleRepresentationOk() ) faireDessinParmela(toto_, beam, xabs, yord); 475 501 else { 476 502 GWt_dialog warningBeamState(" graphical analysis", "the beam state does not allow providing a drawing with macroparticles !", GWt_dialog::Error, false,true); … … 515 541 } 516 542 517 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam) 518 { 519 543 544 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam, unsigned indexAbs, unsigned indexOrd ) 545 { 546 cout << " faireDessinParmela " << endl; 520 547 GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false); 521 548 pointsDialog->setMinimumSize(400,400); … … 527 554 vector<bareParticle>& partic = beam->getParticleVector(); 528 555 new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents()); 529 WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents());556 WStandardItemModel *model = new WStandardItemModel(partic.size(), 2, pointsDialog->contents()); 530 557 // model->setHeaderData(0, WString("X")); 531 558 // model->setHeaderData(1, WString("Y = sin(X)")); 532 559 533 560 if ( indexAbs > 5 || indexOrd > 5 ) return; 561 534 562 for (unsigned i = 0; i < partic.size(); ++i) { 535 double x= partic.at(i).getPosition().getComponent(0); 536 double begamz = partic.at(i).getBetaGamma().getComponent(2); 537 double xp; 538 if ( begamz != 0.0) { 539 xp = partic.at(i).getBetaGamma().getComponent(0)/begamz; 563 double valAbs, valOrd; 564 double begamz = partic.at(i).getBetaGamma().getComponent(2); 565 if ( indexAbs <= 2 ) { 566 valAbs = partic.at(i).getPosition().getComponent(indexAbs); 567 cout << " i= " << i << " valabs = " << valAbs << endl; 568 } else { 569 if ( indexAbs == 5 ) { 570 cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl; 571 return; 540 572 } else { 541 xp = 0.0; 573 if ( begamz != 0.0) { 574 valAbs = 1.e3*partic.at(i).getBetaGamma().getComponent(indexAbs-3)/begamz; 575 } else { 576 valAbs = 0.0; 577 } 542 578 } 543 // cout << "x = " << x << " xp= " << xp << endl; 544 model->setData(i, 0, x); 545 model->setData(i, 1,1.e3*xp); 546 model->setData(i, 2,2.e3*xp); 547 } 548 579 } 580 581 if ( indexOrd <= 2 ) { 582 valOrd = partic.at(i).getPosition().getComponent(indexOrd); 583 } else { 584 if ( indexOrd == 5 ) { 585 cout << " PspaApplication::faireDessinParmela : deltap non programme " << endl; 586 return; 587 } else { 588 589 590 if ( begamz != 0.0) { 591 valOrd = 1.e3*partic.at(i).getBetaGamma().getComponent(indexOrd-3)/begamz; 592 } else { 593 valOrd = 0.0; 594 } 595 cout << " i= " << i << " valord = " << valOrd << endl; 596 } 597 } 598 599 600 // double x= partic.at(i).getPosition().getComponent(0); 601 // double begamz = partic.at(i).getBetaGamma().getComponent(2); 602 // double xp; 603 // if ( begamz != 0.0) { 604 // xp = partic.at(i).getBetaGamma().getComponent(0)/begamz; 605 // } else { 606 // xp = 0.0; 607 // } 608 // // cout << "x = " << x << " xp= " << xp << endl; 609 // model->setData(i, 0, x); 610 // model->setData(i, 1,1.e3*xp); 611 // model->setData(i, 2,2.e3*xp); 612 model->setData(i, 0, valAbs); 613 model->setData(i, 1, valOrd); 614 } 615 cout << " faireDessinParmela : FAISCEAU VU " << endl; 616 549 617 WCartesianChart *chart = new WCartesianChart(pointsDialog->contents()); 550 618 chart->setModel(model); // set the model -
Interface_Web/trunk/pspaWT/workingArea/pmbfield
r54 r333 1 1 z(cm) b(gauss) 2 -20.530 32.19 0.00 32.18 -0.002 -20.530 0.00 0.00 0.00 0.00
Note: See TracChangeset
for help on using the changeset viewer.