Author Topic: Clausius–Clapeyron relation  (Read 4379 times)

0 Members and 1 Guest are viewing this topic.

Offline TheMechWarrior

  • Posts: 4
Clausius–Clapeyron relation
« on: December 30, 2017, 12:55:06 PM »
Hi brains trust,

I'm hoping someone can simplify the code inside the file TtoVaporABV.h to the original formula used for each section?
I know it's all based on the Clausius–Clapeyron relation, however there's so many different formula referenced in the development of that I don't know where to start.

I want to have this all working in Excel and ultimately in a PLC rather than in Arduino.

While I can use the following code (in Excel) to achieve results that make sense I don't understand the origin of the following numbers in this section of code shown below:
  • -20330000
  • -19280000
I've played with the gas constant "R" of 8.3145 and the Heat of Vaporization for EtOH and H2O but I'm just not getting it.

Code: [Select]
float h2oBoilingPoint(float p) {
// calculate the the boiling temperature of water for the measured pressure in Celsius
float H2OInKelvin=-20330000*373.15/(4157* log(p/1013.25)*373.15-20330000);
return H2OInKelvin-273.15;
}

float azeotrope(float p) {
// Calculate the the azeotrope for the measured pressure in Celsius
float AzeotropeInKelvin=-19280000*351.324/(4157*log(p/1013.25)*351.324-19280000);
return AzeotropeInKelvin-273.15;

Next, the code goes on to solve for the TtoLiquidABV and TtoVapourABV solutions via inbuilt arrays and the help of a formula.
I'm lost at this point as I don't understand the array or how to use it in reference to the formula:

Code: [Select]
// Calculate the index for the table (1251 is the the azeotrope at 1013.25 hPa and the
// starting point of the table) in °DC
int16_t IndexABV = int16_t((T + 0.03125 + 100 - h2oBoilingPoint(P)) / 0.0625 ) - 1251;

if (IndexABV < 0) return float(IndexABV) * 0.0625; // Below azeotrope
if (IndexABV >= int16_t(sizeof ABV / sizeof *ABV)) return 0; // Above 100 °C
if (IndexABV < 29) return float(pgm_read_byte(&ABV[IndexABV]) + 768) / 10;
if (IndexABV < 74) return float(pgm_read_byte(&ABV[IndexABV]) + 512) / 10;
if (IndexABV < 138) return float(pgm_read_byte(&ABV[IndexABV]) + 256) / 10;
return float(pgm_read_byte(&ABV[IndexABV])) / 10;
};

Code: [Select]
// Calculate the index for the table (1251 is the the azeotrope at 1013.25 hPa and the
// starting point of the table) in °DC
int16_t IndexABV = int16_t((T + 0.03125 + 78.174 - azeotrope(P)) / 0.0625 ) - 1251;

if (IndexABV < 0) return float(IndexABV) * 0.0625; // Below azeotrope
if (IndexABV >= int16_t(sizeof ABV / sizeof *ABV)) return 0; // Above 100 °C
if (IndexABV < 114) return float(pgm_read_byte(&ABV[IndexABV]) + 768) / 10;
if (IndexABV < 256) return float(pgm_read_byte(&ABV[IndexABV]) + 512) / 10;
if (IndexABV < 314) return float(pgm_read_byte(&ABV[IndexABV]) + 256) / 10;
return float(pgm_read_byte(&ABV[IndexABV])) / 10;
};

Hoping someone can point me in the right direction.

PS, happy New Year to all!!

 /barman

Mech.

Offline TheMechWarrior

  • Posts: 4
Re: Clausius–Clapeyron relation
« Reply #1 on: December 30, 2017, 02:30:17 PM »
Sorry, I meant to ask what the reference is for the number 4157 in the top code.

Cheers,

Mech.

Offline Edwin Croissant

  • Global Moderator
  • Posts: 428
Re: Clausius–Clapeyron relation
« Reply #2 on: December 30, 2017, 09:04:29 PM »
To my embarrassment I forgot how I modified the Clausius–Clapeyron equation :-[ It's possible that I used a online solver to rework the equation. Will take some time to retrieve the steps I made.

The array is just a lookup table that is reduced in size. The table I use in the RGB LCD eParrot on Github for the SMT172 version is not reduced in size and is still in a human readable form.
   

Offline RippoZero

  • Posts: 3
Re: Clausius–Clapeyron relation
« Reply #3 on: April 07, 2019, 03:20:49 PM »
I rearranged the formula. This is what i ended up with: (1/((LN(1013/ATM)*8,1345)/39089,44+1/351,35))-273,15
Where ATM is the atmospheric pressure.

Alternatively : (1/((LN(P1/P2)*R)/HVAP+1/T2))-273,15
P1: Pressure at reference point.
P2: Atmospheric pressure.
R: Universal gas constant.
HVAP: Latent heat of evaporation of the mixture at azeotropic point. I found this number for both ethanol and water by    using temperature dependent HVAP values from perrys handbook.  HVAPe * x1 + HVAPw * x2 in binary mixture.

Offline ketel3

  • Admin
  • Posts: 1376
  • Eparrot.org
Re: Clausius–Clapeyron relation
« Reply #4 on: April 07, 2019, 10:45:50 PM »
Thanks for the modification RippoZero.

maybe Edwin can have  a look at it and we can all have benefit of it.

Question can you please post something into the introduce forum part eventualy with some info about your rig  and or build plans ,and what you make ?
Thanks in advance
K3
Better bad weather than no weather