DanWBR / DTL

DWSIM Thermodynamics Library (legacy version - 3.x)
http://dwsim.inforside.com.br/wiki/index.php?title=DTL
GNU Lesser General Public License v3.0
19 stars 7 forks source link

Adding custom component #2

Open AntonBaluev opened 8 years ago

AntonBaluev commented 8 years ago

Hi Daniel, First of all its a great library and many thanks for your efforts.

I have looked at the example provided and api, and as I understand the feed and mixtures you can create only from PropertyPackage.AvailableCompounds property.

Is there any way to add custom component? I come from petroleum engineering and fluid pvt characterization deals a lot with not pure but "pseudo" components and fractions. Here where I am at the moment.

var calc = new Calculator();
calc.Initialize();

double T = 283; //K
double P = 101325; //Pa

var pr = calc.GetPropPackList()[0];
PropertyPackage pp = calc.GetPropPackInstance(pr);

var ethane = calc.GetCompoundList()[50];

 /// trying to add new compound
var c7PlusName = "c7Plus"
var c7PlusProp = new ConstantProperties();
c7PlusProp.Molar_Weight = 96;
pp.AvailableCompounds.Add( c7PlusName , c7PlusProp);

object[,] result = calc.PTFlash(pp, 0, P, T, new[] { ethane, c7PlusName }, new[] { 0.5, 0.5 }); 

Its obviously fails, because more properties should be defined for the compound. But ConstantProperties() has way too many fields and many of them is not used in this flash.

What should I define for this hydrocarbon like compound to make PTFlash work?

For pseudo component we usually have molecular weight, specific gravity, and boiling point. Critical temperature, Tc; critical pressure, pc; and acentric factor of each component in a mixture are required by EOS and estimated from correlations. I am a bit lost with ConstantProperties class. Any advice would be much appreciated.

Anton.

DanWBR commented 8 years ago

Hi Anton,

I may add a custom compound framework to DTL in the future. In the meantime you can use DWSIM to create a database of custom compounds and load it in DTL. Use the Initialize overload that takes an array of string as argument. This array of strings must contain the paths for user compound databases.

https://github.com/DanWBR/DTL/blob/master/DWSIM/Interfaces/Thermodynamics.vb, Line 63

http://dwsim.inforside.com.br/wiki/index.php?title=Using_the_Compound_Creator_Utility