Beispiel #1
0
    def update_state_vector(self, state, dt):
        """Find the next state vector.

        This implements the f(x) prediction function for the Kalman filter.

        The state vector is of the form (x, y, z, px, py, pz).

        Parameters
        ----------
        state : array-like
            The current state
        dt : float
            The time step to the next state

        Returns
        -------
        ndarray
            The next state
        """
        pos0 = state[0:3]
        mom0 = state[3:6]

        self.particle.position = pos0
        self.particle.momentum = mom0

        # tstep = pos_step / (self.particle.beta * c_lgt)

        new_state = sim.find_next_state(self.particle, self.gas, self.efield, self.bfield, dt)
        self.particle.state_vector = new_state
        return np.hstack([self.particle.position, self.particle.momentum])
Beispiel #2
0
 def test_zero_energy(self):
     """If the energy is 0, the particle should stay still"""
     self.p.energy = 0
     old_sv = self.p.state_vector
     new_sv = sim.find_next_state(*self.args)
     self.assertTrue(numpy.array_equal(old_sv, new_sv),
                     msg='state vector changed')