Page 1 of 1

How to deal with compound which composition is very very bit

PostPosted: 25 April 2016, 12:50
by bcbooo
Recently I am doing some simulation works in Aspen Plus environment, and the process involes my self Unit Operations. But the inlet material stream mixture is very special, one of the compounds is very very bit in the mixture, it's mole fraction is about 1E(-20).

As you know, my self Unit Operation needs to get the composition through CAPE-OPEN interfaces from the inlet material stream. The composition is passed from GetOverallProperty interface method as a double VARAINT format, but the double format in C++ does not support so many decimals, so is there some mechanism to deal with this problem? Any response will be appreciated, thank you!

Re: How to deal with compound which composition is very very

PostPosted: 25 April 2016, 13:30
by jasper
Can you elaborate on the issue? There are some 16 digits in the double precision number, but that should not be a problem to tell the difference between 1.00000000000001e-20 and 1.00000000000002e-20, which are both represented fine by a double precision number.

Re: How to deal with compound which composition is very very

PostPosted: 26 April 2016, 02:25
by bcbooo
Double format gives 15–17 significant decimal digits precision, so if the compound's composition is 0.00000 00000 00000 00003, so it's difficulat to represent it accurately by double format. So how to deal it?

Re: How to deal with compound which composition is very very

PostPosted: 26 April 2016, 05:56
by jasper
It is not a fixed point number. It is a floating point number. So it is not represented by 0.00000 00000 00000 00003 but it is represented by 3e-20 (well - the binary equivalent thereof). So 3.123456789e-20 is not a problem, this is a number with 10 (out of about 16 possible) digits.

On the other hand, 1.0 - 0.00000 00000 00000 00003 will not show the correct difference, as this would be 0.99999999999999999997, which has 20 digits. Instead, the answer would be (the nearest binary representation of) 1.0.

So as long as you are not adding or subtracting numbers that are 20 orders of magnitude apart, there should not be a problem with precision in this case.

Re: How to deal with compound which composition is very very

PostPosted: 26 April 2016, 06:24
by bcbooo
Ohhh Jasper you are so erudite, thank you very much!