Chemical reaction modeling in a subsurface flow simulator with application to in-situ upgrading and CO2 mineralization