def test_ForceDirectionCheck(): 
    """
    Check that forcedirection is only switched if particle 
    moves in the negative direction along a given axis.
    """
    assert ForceDirectionCheck(1,1) == 1
    assert ForceDirectionCheck(-1,1) == -1
    def CosmicRayUpdate(self, deltaT, PositionList, VelocityList, AccelerationList, ListofDirections):
        beta = self.beta()
        for i in range(len(self.velocity)):
                PositionList[i].append(self.position[i])
                VelocityList[i].append(self.velocity[i])
                if np.abs(self.velocity[i]) <= 2.74E6: # minimum speed before bethe stopping power eqn breaks due to -ve ln.
                    AccelerationList[i].append(self.acceleration[i])

                else:
                    if np.abs(self.velocity[i]) >= 1E7:
                        Force = StoppingForce(5.3E25,self.charge,beta[i],1.36E-17) # using stratosphere eDensity for now.                 
                    else:
                        Force = NonRelativisticStoppingForce(5.3E25,self.charge,self.velocity[i],1.36E-17) # using stratosphere eDensity for now.                    

                    AccelerationCalc = (Force/self.mass)
                    self.acceleration[i] = ForceDirectionCheck(ListofDirections[i],AccelerationCalc)                
                    AccelerationList[i].append(self.acceleration[i])
                    self.Velocityupdate(i,deltaT)
                    
                    if ListofDirections[i] == 1 and self.velocity[i] < 0:
                        self.velocity[i] = 0
                        self.acceleration[i] = 0 
                        self.Positionupdate(i,deltaT)
                    elif ListofDirections[i] == -1 and self.velocity[i] > 0:
                        self.velocity[i] = 0
                        self.acceleration[i] = 0 
                        self.Positionupdate(i,deltaT)
                    else:
                        self.Positionupdate(i,deltaT)
    def CosmicRayUpdate(self, deltaT, PositionList, VelocityList,
                        AccelerationList, ListofDirections):
        Beta = self.beta(
        )  # Initialise beta, required in the stopping force functions.
        for i in range(
                len(self.velocity)
        ):  # Run the update function in each of the x, y and z directions.
            if self.interact >= 50:  # Runs if particle has interacted. Here the particle is stopped.
                self.velocity[i] = 0
                self.acceleration[i] = 0
                PositionList[i].append(self.position[i])
                VelocityList[i].append(self.velocity[i])
                AccelerationList[i].append(self.acceleration[i])
            else:  # Particle is moves through the atmosphere and experiences electronic stopping force.
                PositionList[i].append(self.position[i])
                VelocityList[i].append(self.velocity[i])
                if np.abs(
                        self.velocity[i]
                ) <= 2.74E6:  # minimum speed before bethe stopping power equation breaks due to negative natural log. We must stop the cosmic ray at this point.
                    AccelerationList[i].append(self.acceleration[i])
                    self.velocity[i] = 0
                    self.acceleration[i] = 0

                else:
                    if np.abs(
                            self.velocity[i]
                    ) >= 1E7:  # Runs if particle moves at relativistic speeds in a given direction.
                        Force = StoppingForce(
                            1.67E25, self.charge, Beta[i], 1.36E-17
                        )  # Using mesosphere electron density, Using mean excitation potential of air.
                    else:  # Runs if particle moves at non-relativistic speeds in a given direction.
                        Force = NonRelativisticStoppingForce(
                            1.67E25, self.charge, self.velocity[i], 1.36E-17
                        )  # Using mesosphere electron density, Using mean excitation potential of air.

                    AccelerationCalc = (
                        Force / self.mass
                    )  # Calculate the decceleration of the particle due to the stopping force.
                    self.acceleration[i] = ForceDirectionCheck(
                        ListofDirections[i], AccelerationCalc)
                    AccelerationList[i].append(self.acceleration[i])
                    self.Velocityupdate(i, deltaT)

                    if ListofDirections[i] == 1 and self.velocity[
                            i] < 0:  # Check if the particle has changed direction due to stopping force, if so stop it in that direction.
                        self.velocity[i] = 0
                        self.acceleration[i] = 0
                        self.Positionupdate(i, deltaT)
                    elif ListofDirections[i] == -1 and self.velocity[
                            i] > 0:  # Check if the particle has changed direction due to stopping force, if so stop it in that direction.
                        self.velocity[i] = 0
                        self.acceleration[i] = 0
                        self.Positionupdate(i, deltaT)
                    else:
                        self.Positionupdate(
                            i, deltaT
                        )  # This runs if particle has not been stopped yet.
    def CosmicRayInteractionUpdate(self, deltaT, PositionList, VelocityList, AccelerationList, ListofDirections):
        beta = self.beta()
        
        

        if self.interact >= 50:
            
            for i in range(len(self.velocity)):
                PositionList[i].append(self.position[i])
                VelocityList[i].append(self.velocity[i])
                AccelerationList[i].append(self.acceleration[i])
                
                
        else:    
            for i in range(len(self.velocity)):
                self.interact = round(random.randint(0,100)*np.abs(self.velocity[i]))/(2E8)

                if self.interact >= 50:
                    print('Interaction!')
                    for j in range(3-i):
                        # self.velocity = np.array([0,0,0], dtype=float)
                        # self.acceleration = np.array([0,0,0], dtype=float)
                        PositionList[2-j].append(self.position[2-j])
                        VelocityList[2-j].append(self.velocity[2-j])
                        AccelerationList[2-j].append(self.acceleration[2-j])
                    break
                else:
                    PositionList[i].append(self.position[i])
                    VelocityList[i].append(self.velocity[i])

                    if np.abs(self.velocity[i]) <= 2.74E6: # minimum speed before bethe stopping power eqn breaks due to -ve ln.
                        AccelerationList[i].append(self.acceleration[i])
                        self.velocity[i] = 0
                        self.acceleration[i] = 0
                
                    else:
                        if np.abs(self.velocity[i]) >= 1E7:
                            Force = StoppingForce(1.67E25,self.charge,beta[i],1.36E-17) # using mesosphere eDensity for now.                 
                        else:
                            Force = NonRelativisticStoppingForce(1.67E25,self.charge,self.velocity[i],1.36E-17) # using mesosphere eDensity for now.                    

                        AccelerationCalc = (Force/self.mass)
                        self.acceleration[i] = ForceDirectionCheck(ListofDirections[i],AccelerationCalc)                
                        AccelerationList[i].append(self.acceleration[i])
                        self.Velocityupdate(i,deltaT)
                        
                        if ListofDirections[i] == 1 and self.velocity[i] < 0:
                            self.velocity[i] = 0
                            self.acceleration[i] = 0 
                            self.Positionupdate(i,deltaT)
                        elif ListofDirections[i] == -1 and self.velocity[i] > 0:
                            self.velocity[i] = 0
                            self.acceleration[i] = 0 
                            self.Positionupdate(i,deltaT)
                        else:
                            self.Positionupdate(i,deltaT)


    # def InteracionCheck(self,...)
    #     for i in range(len(self.velocity)):
    #         self.interact = round(random.randint(0,100)*np.abs(self.velocity[i]))/(2E8)

    #         if self.interact >= 50:
    #             print('Interaction!')
    #             for j in range(3-i):
    #                 # self.velocity = np.array([0,0,0], dtype=float)
    #                 # self.acceleration = np.array([0,0,0], dtype=float)
    #                 PositionList[2-j].append(self.position[2-j])
    #                 VelocityList[2-j].append(self.velocity[2-j])
    #                 AccelerationList[2-j].append(self.acceleration[2-j])
    #             break
    # SOMETHING LIKE THIS!!!!