In this paper the magnetic nanoparticle aggregation procedure in a microchannel in the presence of external magnetic field is investigated. The main goal of the work was to establish a numerical model, capable of predicting the shape of the nanoparticle aggregate in a magnetic field without extreme computational demands. To that end, a specialized two-phase CFD model and solver has been created with the open source CFD software OpenFOAM. The model relies on the supposed microstucture of the aggregate consisting of particle chains parallel to the magnetic field. First, the microstructure was investigated with a micro-domain model. Based on the theoretical model of the particle chain and the results of the micro-domain model, a two-phase CFD model and solver were created. After this, the nanoparticle aggregation in a microchannel in the field of a magnet was modeled with the solver at different flow rates. Measurements with a microfluidic device were performed to verify the simulation results. The impact of the aggregate on the channel heat transfer was also investigated.