It seems like you are trying to estimate the total number of particles leaving the computational domain by using the UDS approach and setting the boundary conditions. However, your second case where you are using a velocity inlet and pressure outlet is not giving you accurate results.

One of the reasons for the discrepancy in the total number of particles could be due to the assumption that the UDS field is uniformly distributed throughout the domain, which may not be true for non-uniform flows. Additionally, there could be numerical errors in the simulation that are causing the discrepancy.

To estimate the number of particles leaving the cube, you could try using a particle tracking approach. In this approach, you would inject a large number of particles at the inlet and track their trajectories as they move through the domain and exit through the outlet. You can then count the number of particles that exit the domain in a given time period to estimate the total number of particles leaving the cube. This approach can be computationally expensive, but it can give more accurate results.

Another approach you could try is to use a mass balance approach. In this approach, you would track the total mass of particles in the domain at each timestep and calculate the mass leaving the domain through the outlet. You can then convert the mass to the number of particles using the density of the particles. This approach may be easier to implement and less computationally expensive, but it assumes that the density of particles is constant throughout the domain.