Calculation of the energy used for dehumidification

First calculate the vapour pressure of the outside air from the formula:
vp=610.78 × exp(t/(t+238.3) × 17.2694) × rh
When t is in degrees celsius and rh is expressed as a fraction, this formula gives the vapour pressure in pascal.

This air will leak in at a rate set by the air exchange rate, displacing some inside air, which has a vapour pressure calculated in the same way as outside.

The difference between the inside and outside vapour pressures is then converted into kg of excess water per cubic metre of interior space, assuming total displacement of air.
kg/m^3 = 0.002167 × vp_diff/(t+273.16)

This is the mass of water which has to be removed at each air change. So it is multiplied by the air changes per month.

[In principle, one should use the mixing ratio, in kg of water vapour per kg of dry air, to calculate the excess moisture to be removed. However, this prompts the question does the air exchange rate refer to air ingress, or to the escape of inside air with a different temperature and therefore a different density? The difference between the two calculations is negligible compared with the uncertainty in the exact value of the air exchange rate and its constancy in time.]

The latent heat of water is used to convert the excess water vapour quantity in kg into joules of energy needed to remove it during one month..
joules = conc_diff × latentheat × ach × hr_pr_mnth
Where ach is air changes per hour.
[latentheat = 2501 joules per gram to condense water. 1 joule = 2.78 × 10(-7) kilowatt hours].

If the outside vapour concentration is less than that required to keep the inside RH set point, the RH will fall below the set point to the value calculated as the outside vapour pressure transformed into the inside RH at the inside temperature.

However, if the air exchange rate is low and there is humidity buffer within the space, the starting inside vapour pressure will influence the result, and also the sorption or desorption by the buffer. This calculation is described with abundant comment lines in the javascript. It is not right, because the monthly calculation interval is far too long for a proper modelling of the buffering process. I welcome suggestions for how to make a better approximation, within the limits set by the monthly data.

Buffering by cellulose

During a period of a month, water vapour will penetrate approximately 20 mm depth from the exposed book edge or a bundle of papers. The exchangeable moisture per RH unit (meaning 0 to 1.0 as the full range) is about a tenth of this weight of dry paper. That is the formula used in the calculation.