summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2011-04-25 10:23:20 +0000
committerJakob Odersky <jodersky@gmail.com>2011-04-25 10:23:20 +0000
commit0398843f48f15028c537a1dc1aefaa9cf5141896 (patch)
treec4291da9854be22b63d884df27e3c0189e0f75a4
parentea66778658c5a6daa9d6710462beaf090d46e501 (diff)
downloadvhc-0398843f48f15028c537a1dc1aefaa9cf5141896.tar.gz
vhc-0398843f48f15028c537a1dc1aefaa9cf5141896.tar.bz2
vhc-0398843f48f15028c537a1dc1aefaa9cf5141896.zip
Resolu quelques warinings, ajout de l'accelerateur donne en exemple.
-rw-r--r--src/gui/Main.cc4
-rw-r--r--src/main/Accelerator.h2
-rw-r--r--src/main/Element.cc6
-rw-r--r--src/main/Element.h4
-rw-r--r--src/main/Makefile3
-rw-r--r--src/main/Particle.cc4
-rw-r--r--src/test/ParticleTest.cc81
7 files changed, 12 insertions, 92 deletions
diff --git a/src/gui/Main.cc b/src/gui/Main.cc
index 0684883..e966a18 100644
--- a/src/gui/Main.cc
+++ b/src/gui/Main.cc
@@ -201,9 +201,9 @@ int main(int argc, char *argv[])
- //window.showFullScreen();
+ window.showFullScreen();
- window.resize(QSize(500, 500));
+ //window.resize(QSize(500, 500));
window.setWindowTitle("Virtual Hadron Collider");
window.show();
diff --git a/src/main/Accelerator.h b/src/main/Accelerator.h
index aad0f24..2fe0b1a 100644
--- a/src/main/Accelerator.h
+++ b/src/main/Accelerator.h
@@ -151,7 +151,7 @@ public:
particle.setPosition(particle.getPosition() + particle.getVelocity() * dt);
particle.setForce(Vector3D::Null);
- //if (particle.getElement()->isBeside(particle)) std::cout << "Particle hit wall!" << std::endl;
+ if (particle.getElement()->isBeside(particle)) std::cout << "Particle hit wall!" << std::endl;
if (particle.getElement()->isAfter(particle)) { // si la particule est passee, qui sait si elle est dans l'element suivant?
if (!particle.getElement()->isConnected()) throw Exception("Element in accelerator not connected.");
else particle.setElement(particle.getElement()->getNext());
diff --git a/src/main/Element.cc b/src/main/Element.cc
index b4bc9b1..70ccfd6 100644
--- a/src/main/Element.cc
+++ b/src/main/Element.cc
@@ -50,15 +50,15 @@ Vector3D Element::getExitPosition() const {return exitPosition;}
double Element::getSectionRadius() const {return sectionRadius;}
-Element* const Element::getPrevious() const {return previous;}
+Element* Element::getPrevious() const {return previous;}
void Element::setPrevious(Element* p) {previous = p;}
-Element* const Element::getNext() const {return next;}
+Element* Element::getNext() const {return next;}
void Element::setNext(Element* n) {next = n;}
-bool Element::isConnected() const {return next != NULL;}
+bool Element::isConnected() const {return previous != NULL && next != NULL;}
string Element::getType() const {return "Element";}
diff --git a/src/main/Element.h b/src/main/Element.h
index 28fc9ed..1f0afd2 100644
--- a/src/main/Element.h
+++ b/src/main/Element.h
@@ -103,13 +103,13 @@ public:
//void setSectionRadius(double r) {sectionRadius = r;}
/** Retourne un pointeur l'element suivant. NULL s'il n'existe pas. */
- Element* const getPrevious() const;
+ Element* getPrevious() const;
/** Assigne un pointeur sur l'element suivant. */
void setPrevious(Element* p);
/** Retourne un pointeur sur l'element suivant. NULL s'il n'existe pas. */
- Element* const getNext() const;
+ Element* getNext() const;
/** Assigne un pointeur sur l'element suivant. */
void setNext(Element* n);
diff --git a/src/main/Makefile b/src/main/Makefile
index 90e7ac7..236a85f 100644
--- a/src/main/Makefile
+++ b/src/main/Makefile
@@ -14,7 +14,8 @@ LOCALDIR = main
# Si un objet nécessite une compilation non-standard (i.e. pas de règle du style Foo.o : Foo.cc Foo.h), rajouter
# cette règle.
LOCALOBJS = Vector3D.o Particle.o Printable.o Element.o CurvedElement.o StraightElement.o \
- CompositeElement.o Dipole.o Quadrupole.o FODO.o ElementVisitor.o Cloneable.o Accelerator.o exceptions.o
+ CompositeElement.o Dipole.o Quadrupole.o FODO.o ElementVisitor.o Cloneable.o Accelerator.o exceptions.o \
+ Stepper.o
OBJS=$(addprefix $(BINDIR)/$(LOCALDIR)/,$(LOCALOBJS))
.PHONY = all checkdirs lib
diff --git a/src/main/Particle.cc b/src/main/Particle.cc
index 5407013..405b6b5 100644
--- a/src/main/Particle.cc
+++ b/src/main/Particle.cc
@@ -66,9 +66,9 @@ std::string Particle::toString() const {
std::stringstream s;
s << "Particle:" << "\n";
s << "\tposition: " << position << "\n";
- s << "\tvelocity: " << velocity << "\n";
- s << "\tforce: " << force;
+ s << "\tvelocity: " << velocity;
s << "\tnorm: " << velocity.norm() << "\n";
+ s << "\tforce: " << force << "\n";
s << "\tgamma: " << gamma << "\n";
s << "\tmass: " << mass << "\n";
s << "\tcharge: " << charge << "\n";
diff --git a/src/test/ParticleTest.cc b/src/test/ParticleTest.cc
deleted file mode 100644
index a9c20b8..0000000
--- a/src/test/ParticleTest.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * ParticleTest.cc
- *
- * Created on: Mar 16, 2011
- * Author: jakob
- */
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include "constants.h"
-#include "StraightElement.h"
-#include "Dipole.h"
-#include "Quadrupole.h"
-#include "Particle.h"
-#include "Vector3D.h"
-
-using namespace vhc;
-using namespace std;
-
-Element* element = NULL;
-Particle* particle = NULL;
-
-
-void step(double h);
-
-double toKg(double mGeV) {
- return constants::E / constants::C2 * 1E9 * mGeV;
-}
-
-int main() {
- Vector3D entry = Vector3D(0, 10, 0);
- Vector3D exit = Vector3D(10, 0, 0);
- double sectionRadius = 0.2;
- double curvature = 0.1;
- Vector3D direction = entry.cross(Vector3D::k);
-
- double mass = 9.11E-31;
- double charge = constants::E;
- double energy = 1 * 1E9 * constants::E;
-
-
- particle = new Particle(entry, mass, charge, energy, direction);
- double Bz = particle->getGamma() * particle->getMass() * curvature * particle->getVelocity().norm() / particle->getCharge();
- cout << Bz << endl;
- element = new Dipole(entry, exit, sectionRadius, curvature, Vector3D::k * Bz);
-
- cout << *element << endl;
- double t = 0;
- double h = 1E-12;
- char c('0');
- bool hit = false;
- do {
- if (element->hasHit(*particle)) hit = true;
- cout << "t = " << t << endl;
- step(h);
- t += h;
- //cin.get(c);
- } while (false);
-
- if (hit) {
- cout << "Particle hit the wall!!!" << endl;
- }
-
-
-
- delete particle;
- delete element;
- return 0;
-}
-
-void step(double h) {
- cout << *particle << endl;
- particle->applyMagneticForce(element->magneticFieldAt(particle->getPosition()), h);
-
- Vector3D a = particle->getForce() / (particle->getGamma() * particle->getMass());
- particle->setVelocity(particle->getVelocity() + a * h);
- particle->setPosition(particle->getPosition() + particle->getVelocity() * h);
- particle->setForce(Vector3D::Null);
-}
-