How to deal with compound which composition is very very bit

Post Reply
bcbooo
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

How to deal with compound which composition is very very bit

Post 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!
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

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

Post 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.
bcbooo
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

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

Post 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?
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

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

Post 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.
bcbooo
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

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

Post by bcbooo »

Ohhh Jasper you are so erudite, thank you very much!
Post Reply

Return to “Unit Operations”