**Parameters:**

volume_wine (in liters)

rho_i_wine (initial g/l sugar)

rho_port (desired g/l in port)

ABV_port (desired ABV of port)

ABV_brandy (I am using "brandy" as my spirit!)

(derived quantity: ABV_wine=(rho_i_wine - rho_f_wine)/20, as per Seth)

**Unknowns**

volume_brandy

rho_f_wine (final g/l sugar in wine)

**2 independent equations**

(1, the sugar equation) rho_port = rho_f_wine*volume_wine/(volume_wine + volume_brandy)

(2, the alcohol equation)

ABV_port= (volume_wine*ABV_wine + volume_brandy*ABV_brandy) / (volume_wine + volume_brandy)

I solved Eqn 1 for rho_f_wine to find:

rho_f_wine = rho_port*(volume_wine + volume_brandy)/volume_wine ,

then I shoved that into Eqn. 2 (after substituting your derived quantity for ABV_wine). You can easily, i.e., algebraically solve for volume_brandy.

The result is:

volume_brandy = {ABV_port - (rho_i_wine - rho_port)/20} / (ABV_brandy - ABV_port - rho_port/20)

This is the desired volume of brandy in liters.

You then substitute that value into Eqn. 1 to find rho_f_wine.

The result is:

rho_f_wine = (ABV_brandy - rho_i_wine/20) / (ABV_brandy - ABV_port - rho_port/20)

Remember, this is the residual sugar that you want (in g/l) at the time you should fortify to stop fermentation.

You can either use ABV as a number between 0 and 100 and use rho in g/l, or you can use ABV as a fraction (number between 0 and 1) and use rho (in g/l)/100; this comes from the fermentation conversion of rho/20, which provides the ABV as a percentage, so you have to divide by another 100 to get ABV to a fraction instead of percentage. I think most people would be best served to use ABV as a number from 0 to 100, and sugar in g/l.

For all you people who would prefer to use SG rather than g/l of sugar, the conversion is close to:

SG = 1 + rho/2644 where rho is in g/l,

Or, of course, rho = (SG-1)*2644.