Getting the Oil/Gas Mixture Out from the Ground
First we make a few mass balances:
Total Hydrocarbon Balance:

Species Hydrocarbon Balance:

Water Balance:

Then we handle the restrictions on system:
Saturations add up to 1
Saturation is the fraction of the V/L space that is a particular phase
Using:
Sl+Sw+Sv=1
And:
L=Total moles of liquid/pore volume
V=Total moles of vapor/pore volume
V=Sv*rhov
L=Sw*rhow
The restriction is:

Use the perfect gas law and the compressiblity factor.
In equilibrium, each phase has the same temperature and pressure

|