Available with Zymplectic v.0.1.2

The quadrupole mass spectrometer or quadrupole mass analyzer (hereafter QMS) is an instrument that generates an alternating electric field, which can be utilized for trapping or guiding charged particles with specific mass-to-charge ratios.

- the forces on the charged particle in the longitudinal direction (z-direction) are always zero.
- charged particles can be trapped in the xy-direction (stable motion) if u, v and the alternating current frequency ω are correctly chosen.
- charged particles of different masses are guided or trapped in the QMS for different values of u and v, allowing mass identification by detection of the charged particle throughput.

```
//Copy-paste into Zymplectic or load as file to run the simulation
#include "math.h"
const double r0 = 0.01; //QMS inscribed radius [meter]
const double w = 8e+006; //QMS oscillation frequency [per second]
const double e = -1.0; //electric charge [electron charges]
const double mass_chlorine = 3.624266025057571e-007; //mass of the Cl-35 isotope [eV], calculated as 34.96885268*931494061/c^2
const double a_stability = 0.1; //Dimensionless constants which determine the system stability (See Mathieu stability diagram)
const double q_stability = 0.5;
double u,v,m; //set in initialization
double _q_init[] = {-0.008,0.004}; //Initial conditions do not influence the trajectory stability
double _p_init[] = {0.0,0.0};
double energy_V(Arg) {
return (q1*q1 - q2*q2)*(u + v*cos(w*tau))/(r0*r0)*e; //depends explicitly on time (tau)
}
void dVdq(Arg) {
d1 = q1*2.0*e/(r0*r0)*(u + v*cos(w*tau));
d2 =-q2*2.0*e/(r0*r0)*(u + v*cos(w*tau));
}
double energy_T(Arg) {
return 0.5*(p1*p1 + p2*p2)/m;
}
void dTdp(Arg) {
d1 = p1/m;
d2 = p2/m;
}
void main() { //this function is launched when executing script (Must be last function in file and not closed)
Z.benchmark_time = 1e-5;
Z.time_per_evaluation = 1e-9;
Z.delay = 10;
Z.energy_surface = 1;
Z.V(energy_V,dVdq,0);
Z.T(energy_T,dTdp,0);
m = 1.0*mass_chlorine;
u = a_stability*(mass_chlorine*r0*r0*w*w)/(-8.0*e);
v = q_stability*(mass_chlorine*r0*r0*w*w)/(4.0*e);
}
```

Non-symplectic integrators introduce an energy drift of the system that wrongly resemble the motion of a particle in the unstable region. Symplectic integrators preserve the phase space exactly and therefore also the qualitative physical behavior and motion of the particle even when the energy is not preserved.
Consider the following graphs which display the integrated trajectory of the particle inside the QMS over different time spans, where the green lines display the trajectory integrated by the Ruth's 3-stage 4th order symplectic integrator and the black lines the trajectory integrated by the classical 4th order Runge-Kutta method:

The trajectory integrated by the symplectic integrator reveals that the particle remains trapped within a small region while the trajectory integrated by RK4 yields an unstable motion that diverges in the first axis. The single step accuracy of q and p are comparable for both integrators, but the symplectic integrator conserves the volume in phase space in spite of the limited accuracy of the chosen integrator. This is evidently not the case for the non-symplectic method.