|Abstract:|| This thesis, carried out in collaboration with Eni S.p.A., aims at understanding how the porosity of the source rock, where hydrocarbons are generated, changes as generation and expulsion of hydrocarbons take place. In particular, the mechanical compaction, due to the effective stress, and the extra pore space generated by the consumption of the solid organic matter (i.e. kerogen) have a deep impact on the porosity of the rocks, as well as on the variations of pressure due to the breakdown of kerogen into fluid hydrocarbons and to the expulsion of these products. An original feature of this work is that the equations are formulated and numerically solved on a fixed domain, obtained from the physical one as its completely compacted configuration, having removed all the degradable part of the rock. The advantage is that the mesh can be built once and for all at the beginning of the simulation, as well as the basis functions of the finite element methods. Simulations are carried out in a two dimensional section of a sedimentary basin with a simplified model of source rock - which consists of rock with no hydrocarbon potential, pure kerogen, and a void part initially filled with water - and a simplified chemical kinetic, in which kerogen generates only oil. The temperature and the overburden due to the overlying sedimentary layers are given fields and may account for the burial history of the source rock, while the pressure of the fluids in place is modeled with the Darcy law.