Not trivial

The physics

There are three temperature coefficients you need to know to calculate the amount of energy needed to melt ice from ice to water.

- assume ice has temperature of -Y °C

- assume water has temperature of P °C (ist temperature)

- assume X °C is the temperature you want to have (soll temperature)

then the steps are

1) getting the ice from -Y°C to 0°C- => 2.108 J/gram (search for specific heat ice)

2) getting ice from 0°C to water 0°C => 334 J/gram (this one is often forgotten)

3) getting water from 0°C to X°C => 4.187 J/gram

In total to get 1 gram of ice from -Y to X costs Q1 = 2.108*Y + 334 + 4.187*X energy

This amount of energy should balance

4) getting water from P °C to X °C => 4.187 J/gram

In total to get 1 gram of water from P to X costs Q2 = (P - X) * 4.187 energy

Example

30Liter @25° --> 30L @ 20° ==> Q2 = 30000 gram * (25-20) * 4.187 = 628050 joule

Assume you have ice from -18°C then it would take

Q1 = 2.108*18 + 334 + 4.187*20 = 454.064 Joule per gram to heat to 20°C

The amount of ice would be 628050 / 454.064 = 1383.17 gram of ice of -18°C to end up at 20°C

in practice 1.4 Kg should work (depends on precission of parameters of course).

The code

Assuming my above physics is right we can derive the formula needs

1) amount of water in Kg (30.000)

2) IST temperature of the water in C (25.0)

3) SOLL temperature of the water in C (20.0)

4) temperature of the ice in C (-18.0)

float calculateIce(float water, float ist, float soll, float icetemp)

{

float Q2 = 1000 * water * (ist - soll) * 4.187;

float Q1pergram = -2.108 * icetemp + 334 + 4.187 * soll; // note the - sign

float gramsIce = Q2 / Q1pergram;

float kgIce = gramsIce * 0.001;

return KgIce;

}

You can modify the code to round the number to 100 grams or have the weight in grams etc

This formula does not take into account the environment temperature, which has effects too.

Furthermore the specific heat of water depends on the temperature but above formula should work well enough in practice. If not you need to extend the formula in a similar way.

Please do a number of testruns and let us know if it works.

Note: ° char == ALT 0176 on windows

updated the value for latent heat (ice2water) as Harlane spotted an error (see below)