Using numerical method to investigate the micro property of unsaturated loess is helpful for the understanding of its physical mechanical behavior. However, some obvious differences were observed between the microstructure constructed by the existing numerical models and the real microstructure of loess, and it is very challenging for these existing models to take consideration of the change on the hydraulic property of the soil produced by deformation. Therefore, we try to establish a model to consider the microstructure of loess and the capillary force based on the discontinuous deformation analysis (DDA). In our model, four key steps are adopted in the construction process of the microstructure of loess. Firstly, a shape database was constructed based on the geometries of a large number of skeleton particles of loess. Secondly, some particles were selected from the shape database according the particle size distribution curve of loess. And then，these particles are dropped into a sample box. Finally, the capillary force at certain water content is calculated according to the Young-Laplace equation, and applied on the wetted surface of two adjacent particles based on extending DDA. This model was used to conduct confined compression numerical tests on loess with three different water contents, and the simulated result is compared with the experimentally measured compression curve to validate the method. Moreover, the model reflects the micro evolution of pore during the compression of unsaturated soil. The soil deformation at micro-scale is majorly generated by large pores; the deformation pattern is concerned with the moisture, namely, the pores are mainly shrunk at low water content while mainly disintegrate at high water content. This research proposed a new numerical model to explore the mechanism of deformation behavior of unsaturated loess.