summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Vazquez <christian.vazquez@epfl.ch>2011-05-13 14:26:30 +0000
committerChristian Vazquez <christian.vazquez@epfl.ch>2011-05-13 14:26:30 +0000
commitff6d73ea2d4bd30d11892e6262f426ca25929dc1 (patch)
tree8bf7c47a0587c4cec642d5af8aaf0ca4d64b0ae7
parent64d6cd8a7ed46be4a34b4818705186f8e0998ab1 (diff)
downloadvhc-ff6d73ea2d4bd30d11892e6262f426ca25929dc1.tar.gz
vhc-ff6d73ea2d4bd30d11892e6262f426ca25929dc1.tar.bz2
vhc-ff6d73ea2d4bd30d11892e6262f426ca25929dc1.zip
Créé:
exerciceP13 Parser (.cc et .h) exerciceP11test Mis é jour: elementsimulationtest
-rw-r--r--src/gui/exerciceP13Test.cc51
-rw-r--r--src/main/Parser.cc22
-rw-r--r--src/main/Parser.h20
-rw-r--r--src/test/ElementsSimulationTest.cc10
-rw-r--r--src/test/exerciceP11Test.cc118
5 files changed, 216 insertions, 5 deletions
diff --git a/src/gui/exerciceP13Test.cc b/src/gui/exerciceP13Test.cc
new file mode 100644
index 0000000..5998744
--- /dev/null
+++ b/src/gui/exerciceP13Test.cc
@@ -0,0 +1,51 @@
+/*
+ * exerciceP13Test.cc
+ *
+ * Created on: 11 mai 2011
+ * Author: christian
+ */
+
+
+#include <iostream>
+#include <QApplication>
+#include <QWidget>
+#include <cmath>
+#include "exceptions.h"
+#include "Stage.h"
+#include "Accelerator.h"
+#include "StraightElement.h"
+#include "Dipole.h"
+#include "Particle.h"
+#include "FODO.h"
+#include "Vector3D.h"
+#include "constants.h"
+#include "exerciceP11Test.cc"
+#include <vector>
+
+using namespace std;
+using namespace vhc;
+
+int main(int argc, char *argv[])
+{
+ try {
+
+ QApplication app(argc, argv);
+
+ vhc::Stage window;
+ Accelerator* acc = creatAccChap();
+ window.accelerator = acc;
+
+ window.setWindowTitle("Virtual Hadron Collider");
+ window.resize(QSize(500, 500));
+ window.show();
+
+
+ //window.showFullScreen();
+
+ //app.setActiveWindow(&window);
+ return app.exec();
+
+ } catch (Exception& ex){
+ std::cerr << ex.toString() << "\n";
+ }
+}
diff --git a/src/main/Parser.cc b/src/main/Parser.cc
new file mode 100644
index 0000000..e10f182
--- /dev/null
+++ b/src/main/Parser.cc
@@ -0,0 +1,22 @@
+/*
+ * Parser.cc
+ *
+ * Created on: 11 mai 2011
+ * Author: christian
+ */
+
+#include "Parser.h"
+
+Parser::Parser(string file) {
+ // TODO Auto-generated constructor stub
+
+}
+
+Parser::~Parser() {
+ // TODO Auto-generated destructor stub
+}
+
+Parser::extract(string file) {
+
+
+}
diff --git a/src/main/Parser.h b/src/main/Parser.h
new file mode 100644
index 0000000..311ddd1
--- /dev/null
+++ b/src/main/Parser.h
@@ -0,0 +1,20 @@
+/*
+ * Parser.h
+ *
+ * Created on: 11 mai 2011
+ * Author: christian
+ */
+
+#include <string>
+
+#ifndef PARSER_H_
+#define PARSER_H_
+
+class Parser {
+public:
+ Parser(string file);
+ virtual ~Parser();
+ void extract(string file);
+};
+
+#endif /* PARSER_H_ */
diff --git a/src/test/ElementsSimulationTest.cc b/src/test/ElementsSimulationTest.cc
index 6c121ca..2406171 100644
--- a/src/test/ElementsSimulationTest.cc
+++ b/src/test/ElementsSimulationTest.cc
@@ -19,12 +19,10 @@
using namespace std;
using namespace vhc;
-//TODO ne marche pas.....=(
-
Particle* standpart(Accelerator* acc){
Particle* sp = new Particle(
- acc->getElements().front()->getEntryPosition(),//position
+ acc->getElements().front()->getExitPosition(),//position, on le met à la fin des éléments
constants::PROTON_MASS,//mass
constants::E,//charge
2*constants::GeV,//energy
@@ -66,7 +64,7 @@ int main() {
va[i]->close();
//nbr d'iterations de la simulation
- int it(100);
+ int it(14);
//etat initial
cout<<*va[i]<<endl;
@@ -74,7 +72,9 @@ int main() {
//test de simulation
for(unsigned int j(0); j<it; ++j){
va[i]->step(10E-11);
- cout<<"after "<<j+1<<" step :"<<endl << (va[i]->getParticles().size())<<endl;
+ if(!(va[i]->getParticles().empty())){
+ cout<<"after "<<j+1<<" step :"<<endl << (va[i]->getParticles().front()->toString())<<endl;
+ }
}
}
diff --git a/src/test/exerciceP11Test.cc b/src/test/exerciceP11Test.cc
new file mode 100644
index 0000000..8bb1cd0
--- /dev/null
+++ b/src/test/exerciceP11Test.cc
@@ -0,0 +1,118 @@
+/*
+ * exerciceP11Test.cc
+ *
+ * Created on: 5 mai 2011
+ * Author: christian
+ */
+
+
+#include <iostream>
+#include "exceptions.h"
+#include "Dipole.h"
+#include "FODO.h"
+#include "Accelerator.h"
+#include "Particle.h"
+
+using namespace std;
+using namespace vhc;
+
+
+// A bannir car ne garantit pas que les entrées-sorties de séléments soient cohérents.
+// De plus il n'extise aucune moyen d'initaliser ces attributs automatiquement.
+Accelerator* creatAcc() {
+
+
+ Accelerator* acc = new Accelerator();
+
+ for(unsigned int i(0); i<4; ++i){
+
+ FODO* fodo = new FODO(Vector3D(0,0,0),Vector3D(1, 0,0), 0.2 , 1. , 1.2);
+// entry exit Re l b
+ acc->add( *fodo );
+
+ Dipole* d = new Dipole(Vector3D(0,0,0),Vector3D(1,2,0), 0.1, 1, Vector3D(0,0,5.89158));
+// entry exit Re Rc B
+ acc->add( *d );
+ }
+ acc->close();
+
+ return acc;
+}
+
+Accelerator* creatAccChap() {
+
+ Accelerator* acc = new Accelerator();
+
+ FODO* fodo1 = new FODO(Vector3D(3,2,0),Vector3D(3,-2,0), 0.2 , 1. , 1.2);
+// entry exit Re l b
+ Dipole* d1 = new Dipole(Vector3D(3,-2,0),Vector3D(2,-3,0), 0.1, 1, Vector3D(0,0,5.89158));
+// entry exit Re Rc B
+ FODO* fodo2 = new FODO(Vector3D(2,-3,0),Vector3D(-2,-3,0), 0.2 , 1. , 1.2);
+// entry exit Re l b
+ Dipole* d2 = new Dipole(Vector3D(-2,-3,0),Vector3D(-3,-2,0), 0.1, 1, Vector3D(0,0,5.89158));
+// entry exit Re Rc B
+ FODO* fodo3 = new FODO(Vector3D(-3,-2,0),Vector3D(-3,2,0), 0.2 , 1. , 1.2);
+// entry exit Re l b
+ Dipole* d3 = new Dipole(Vector3D(-3,2,0),Vector3D(-2,3,0), 0.1, 1, Vector3D(0,0,5.89158));
+// entry exit Re Rc B
+ FODO* fodo4 = new FODO(Vector3D(-2,3,0),Vector3D(2,3,0), 0.2 , 1. , 1.2);
+// entry exit Re l b
+ Dipole* d4 = new Dipole(Vector3D(2,3,0),Vector3D(3,2,0), 0.1, 1, Vector3D(0,0,5.89158));
+// entry exit Re Rc B
+
+ acc->add(*fodo1); acc->add(*d1); acc->add(*fodo2); acc->add(*d2);
+ acc->add(*fodo3); acc->add(*d3); acc->add(*fodo4); acc->add(*d4);
+
+ acc->close();
+
+ return acc;
+}
+
+void fillWithParts(Accelerator* acc){
+
+ Particle* p1 = new Particle(
+ Vector3D(3.01,0,0),//position
+ constants::PROTON_MASS,//mass
+ constants::E,//charge
+ 2*constants::GeV,//energy
+ Vector3D(0,-1,0));//direction
+
+ Particle* p2 = new Particle(
+ Vector3D(2.99,0,0),//position
+ constants::PROTON_MASS,//mass
+ constants::E,//charge
+ 2*constants::GeV,//energy
+ Vector3D(0,-1,0));//direction
+
+ acc->add(*p1); acc->add(*p2);
+
+ acc->close();
+
+}
+
+void makeTest(){
+
+ Accelerator* a = creatAccChap();
+
+ fillWithParts(a);
+
+
+ cout<< *a << "\n";
+
+ int it(4);
+
+ cout<<"Beginning simulation...\n";
+
+ for(unsigned int j(0); j<it; ++j){
+ a->step(10E-11);
+ cout<<"after "<<j+1<<" step :"<<endl<<"part 1 :"<< (a->getParticles().front()->toString()) <<endl;
+ cout<<"after "<<j+1<<" step :"<<endl<<"part 2 :"<< (a->getParticles().back()->toString()) <<endl;
+ }
+}
+
+int main() {
+
+ makeTest();
+
+ return 0;
+}