From 9872f694f264c1deea2cce057713b560a883d89f Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 20 Apr 2011 11:02:36 +0000 Subject: Reparation du quadrupole. --- src/gui/Main.cc | 8 ++++---- src/main/Quadrupole.cc | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/gui/Main.cc b/src/gui/Main.cc index 6b60310..03ba472 100644 --- a/src/gui/Main.cc +++ b/src/gui/Main.cc @@ -21,7 +21,7 @@ using namespace vhc; -std::vector< Particle > createParticles(const Vector3D& position, int n, double mass = constants::ELECTRON_MASS, double charge = constants::E, double energy = 0, Vector3D direction = Vector3D::Null) { +std::vector< Particle > createParticles(const Vector3D& position, int n, double mass = constants::ELECTRON_MASS, double charge = constants::E, double energy = 0, Vector3D direction = Vector3D::i) { std::vector< Particle > v; double r = 0.1; @@ -29,7 +29,7 @@ std::vector< Particle > createParticles(const Vector3D& position, int n, double for (int i = 0; i < n; ++i) { double x = (rand() % 1000) / 1000.0 * r; double y = (rand() % 1000) / 1000.0 * sqrt(r * r - x * x); - double z = (rand() % 1000) / 1000.0 * sqrt(r * r - y * y - x * x);; + double z = (rand() % 1000) / 1000.0 * sqrt(r * r - y * y - x * x); v.push_back(Particle(position + Vector3D(x, y, z), mass, charge, energy, direction)); } @@ -66,7 +66,7 @@ Accelerator* standardAccelerator() { } Accelerator* linear() { - FODO element = FODO(Vector3D(0, 0, 0), Vector3D(4, 0, 0), 0.2, 1.2, 0.1); + FODO element = FODO(Vector3D(0, 0, 0), Vector3D(4, 0, 0), 0.2, 0.2, 120); Accelerator* acc = new Accelerator(); Element* celement = acc->add(element); Particle e(Vector3D(0, 0.15, 0.01), constants::ELECTRON_MASS, constants::E, 14E9 * constants::E, Vector3D::i); @@ -115,7 +115,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); vhc::Stage window; - Accelerator* acc = linear(); + Accelerator* acc = singleDipole(); window.accelerator = acc; window.showFullScreen(); diff --git a/src/main/Quadrupole.cc b/src/main/Quadrupole.cc index 9b1c3e9..911ae18 100644 --- a/src/main/Quadrupole.cc +++ b/src/main/Quadrupole.cc @@ -23,7 +23,10 @@ Vector3D Quadrupole::magneticFieldAt(const Vector3D& position) const { Vector3D d = getDiagonal().unit(); Vector3D y = x - x.dot(d) * d; Vector3D u = Vector3D::k.cross(d); - return focalizingCoefficient * (y.dot(u) * Vector3D::k + position.getZ() * u); + if ((x.dot(d) >= 0) && ((position - getExitPosition()).dot(-d) >= 0)) + return focalizingCoefficient * (y.dot(u) * Vector3D::k + position.getZ() * u); + else + return Vector3D::Null; } double Quadrupole::getFocalizingCoefficient() const { -- cgit v1.2.3