summaryrefslogtreecommitdiff
path: root/src/gui/Main.cc
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2011-05-11 14:59:00 +0000
committerJakob Odersky <jodersky@gmail.com>2011-05-11 14:59:00 +0000
commit64d6cd8a7ed46be4a34b4818705186f8e0998ab1 (patch)
tree0a889a5ff9bdb7a010bb9e028a5dc2ca0d05be65 /src/gui/Main.cc
parentff64cec5fdf5b18e6aee31e8b3148a0305e1d1de (diff)
downloadvhc-64d6cd8a7ed46be4a34b4818705186f8e0998ab1.tar.gz
vhc-64d6cd8a7ed46be4a34b4818705186f8e0998ab1.tar.bz2
vhc-64d6cd8a7ed46be4a34b4818705186f8e0998ab1.zip
Rajoute getHorizontalAt() pour tous les elements, en vue des faisceaux
Diffstat (limited to 'src/gui/Main.cc')
-rw-r--r--src/gui/Main.cc134
1 files changed, 40 insertions, 94 deletions
diff --git a/src/gui/Main.cc b/src/gui/Main.cc
index 6ae9c67..28ba09f 100644
--- a/src/gui/Main.cc
+++ b/src/gui/Main.cc
@@ -15,7 +15,9 @@
#include "StraightElement.h"
#include "Dipole.h"
#include "Particle.h"
-#include "FODO.h"
+//#include "FODO.h"
+#include "Quadrupole.h"
+#include "Element.h"
#include "Vector3D.h"
#include "constants.h"
#include <vector>
@@ -38,6 +40,21 @@ std::vector< Particle > createParticles(const Vector3D& position, int n, double
return v;
}
+Element** FODO(Vector3D entry, Vector3D exit, double Rs, double L, double b) {
+ double l = (entry - exit).norm() / 2.0 - 1;
+ Vector3D d = (exit - entry).unit();
+ Quadrupole* fq = new Quadrupole(entry, entry + d * l, Rs, b);
+ StraightElement* s1 = new StraightElement(fq->getExitPosition(), fq->getExitPosition() + d * L, Rs);
+ Quadrupole* dq = new Quadrupole(s1->getExitPosition(), s1->getExitPosition() + d * l, Rs, -b);
+ StraightElement* s2 = new StraightElement(dq->getExitPosition(), exit, Rs);
+ Element** fodo = new Element*[4];
+ (fodo)[0] = fq;
+ (fodo)[1] = s1;
+ (fodo)[2] = dq;
+ (fodo)[3] = s2;
+
+ return fodo;
+}
Accelerator* standard() {
/*
@@ -87,34 +104,41 @@ Une particule :
double B = 5.8915820038873;
double b = 1.2;
- FODO e1 = FODO(Vector3D(3, 2, 0), Vector3D(3, -2, 0), 0.1, 1.0, b);
- Dipole e2 = Dipole(e1.getExitPosition(), Vector3D(2, -3, 0), 0.1, 1, Vector3D(0, 0, B));
- FODO e3 = FODO(e2.getExitPosition(), Vector3D(-2, -3, 0), 0.1, 1, b);
- Dipole e4 = Dipole(e3.getExitPosition(), Vector3D(-3, -2, 0), 0.1, 1, Vector3D(0, 0, B));
- FODO e5 = FODO(e4.getExitPosition(), Vector3D(-3, 2, 0), 0.1, 1.0, b);
- Dipole e6 = Dipole(e5.getExitPosition(), Vector3D(-2, 3, 0), 0.1, 1, Vector3D(0, 0, B));
- FODO e7 = FODO(e6.getExitPosition(), Vector3D(2, 3, 0), 0.1, 1.0, b);
- Dipole e8 = Dipole(e7.getExitPosition(), e1.getEntryPosition(), 0.1, 1, Vector3D(0, 0, B));
+ Element** e1 = FODO(Vector3D(3, 2, 0), Vector3D(3, -2, 0), 0.1, 1.0, b);
+
+ //FODO e1 = FODO(Vector3D(3, 2, 0), Vector3D(3, -2, 0), 0.1, 1.0, b);
+ Dipole e2 = Dipole(Vector3D(3, -2, 0), Vector3D(2, -3, 0), 0.1, 1, Vector3D(0, 0, B));
+
+ Element** e3 = FODO(e2.getExitPosition(), Vector3D(-2, -3, 0), 0.1, 1, b);
+ Dipole e4 = Dipole(Vector3D(-2, -3, 0), Vector3D(-3, -2, 0), 0.1, 1, Vector3D(0, 0, B));
+ Element** e5 = FODO(e4.getExitPosition(), Vector3D(-3, 2, 0), 0.1, 1.0, b);
+ Dipole e6 = Dipole(Vector3D(-3, 2, 0), Vector3D(-2, 3, 0), 0.1, 1, Vector3D(0, 0, B));
+ Element** e7 = FODO(e6.getExitPosition(), Vector3D(2, 3, 0), 0.1, 1.0, b);
+ Dipole e8 = Dipole(Vector3D(2, 3, 0), Vector3D(3, 2, 0), 0.1, 1, Vector3D(0, 0, B));
Accelerator* acc = new Accelerator();
- acc->add(e1);
+ //acc->add(e1);
+ for (int i = 0; i < 4; ++i) acc->add(e1[i][0]);
acc->add(e2);
- acc->add(e3);
+ for (int i = 0; i < 4; ++i) acc->add(e3[i][0]);
+ //acc->add(e3);
acc->add(e4);
- acc->add(e5);
+ for (int i = 0; i < 4; ++i) acc->add(e5[i][0]);
+ //acc->add(e5);
acc->add(e6);
- acc->add(e7);
+ for (int i = 0; i < 4; ++i) acc->add(e7[i][0]);
+ //acc->add(e7);
acc->add(e8);
acc->close();
//proton
- Particle p1 = Particle(Vector3D(3.00, 0, 0), constants::PROTON_MASS, constants::E, 2 * constants::GeV, -Vector3D::j);
+ Particle p1 = Particle(Vector3D(3.01, 0, 0), constants::PROTON_MASS, constants::E, 2 * constants::GeV, -Vector3D::j);
Particle p2 = Particle(Vector3D(2.99, 0, 0), constants::PROTON_MASS, constants::E, 2 * constants::GeV, -Vector3D::j);
acc->add(p1);
acc->add(p2);
//anti-proton
- Particle ap1 = Particle(Vector3D(3.00, 0, 0), constants::PROTON_MASS, -constants::E, 2 * constants::GeV, Vector3D::j);
+ Particle ap1 = Particle(Vector3D(3.01, 0, 0), constants::PROTON_MASS, -constants::E, 2 * constants::GeV, Vector3D::j);
Particle ap2 = Particle(Vector3D(2.99, 0, 0), constants::PROTON_MASS, -constants::E, 2 * constants::GeV, Vector3D::j);
acc->add(ap1);
acc->add(ap2);
@@ -131,84 +155,6 @@ Une particule :
return acc;
}
-Accelerator* standardAccelerator() {
- FODO e1 = FODO(Vector3D(3, 2, 0), Vector3D(3, -2, 0), 0.2, 1.0, 5.0);
- Dipole e2 = Dipole(e1.getExitPosition(), Vector3D(2, -3, 0), 0.2, 1);
- FODO e3 = FODO(e2.getExitPosition(), Vector3D(-2, -3, 0), 0.2, 1, 5.0);
- Dipole e4 = Dipole(e3.getExitPosition(), Vector3D(-3, -2, 0), 0.2, 1);
- FODO e5 = FODO(e4.getExitPosition(), Vector3D(-3, 2, 0), 0.2, 1.0, 5.0);
- Dipole e6 = Dipole(e5.getExitPosition(), Vector3D(-2, 3, 0), 0.2, 1);
- FODO e7 = FODO(e6.getExitPosition(), Vector3D(2, 3, 0), 0.2, 1.0, 5.0);
- Dipole e8 = Dipole(e7.getExitPosition(), e1.getEntryPosition(), 0.2, 1);
- Accelerator* acc = new Accelerator();
- acc->add(e1);
- acc->add(e2);
- acc->add(e3);
- acc->add(e4);
- acc->add(e5);
- acc->add(e6);
- acc->add(e7);
- acc->add(e8);
-
- std::vector< Particle > ps = createParticles(e1.getEntryPosition(), 100000);
-
- for (int i = 0; i < ps.size(); ++i) {
- acc->add(ps[i]);
- }
-
- acc->close();
-
- return acc;
-}
-
-Accelerator* linear() {
- Accelerator* acc = new Accelerator();
-
- for(int i = 0; i < 10; ++i) {
- FODO e = FODO(Vector3D(4, 0, 0) * i, Vector3D(4, 0, 0) * (i + 1), 0.1, 1, 1.2);
- acc->add(e);
- }
-
- Particle e(Vector3D(0, 0.05, 0.01), constants::PROTON_MASS, constants::E, 2 * constants::GeV, Vector3D::i);
- acc->add(e);
- acc->close();
-
- return acc;
-}
-/*
-Accelerator* singleDipole() {
- Vector3D entry = Vector3D(0, 2, 0);
- Vector3D exit = Vector3D(2, 0, 0);
- double sectionRadius = 0.2;
- double curvature = 0.5;
- Vector3D direction = entry.cross(Vector3D::k);
-
- double mass = constants::ELECTRON_MASS;
- double charge = constants::E;
- double energy = 1 * 1E9 * constants::E;
-
-
- Particle particle = Particle(entry, mass, charge, energy, direction);
- double Bz = particle.getGamma() * particle.getMass() * curvature * particle.getVelocity().norm() / particle.getCharge();
- std::cout << "|B:|" << Bz << std::endl;
- Dipole element = Dipole(entry, exit, sectionRadius, curvature, Vector3D::k * Bz);
-
- Accelerator* acc = new Accelerator();
-
- Element*\ celement = acc->add(element);
-
- std::vector< Particle > ps = createParticles(element.getEntryPosition(), 10, constants::ELECTRON_MASS, constants::E, energy, direction);
-
- for (int i = 0; i < ps.size(); ++i) {
- Particle* cparticle = acc->add(ps[i]);
- cparticle->setElement(celement);
- }
-
- Particle* cparticle = acc->add(particle);
- cparticle->setElement(celement);
- return acc;
-}*/
-
int main(int argc, char *argv[])
{
@@ -225,7 +171,7 @@ int main(int argc, char *argv[])
window.show();
- //window.showFullScreen();
+ window.showFullScreen();
//app.setActiveWindow(&window);
return app.exec();