Problem(s) with Thermo Import Function

Moderator: jasper

Problem(s) with Thermo Import Function

Postby nrgeng » 23 January 2018, 13:20

{capeOpenEquilibrium function}

Hope you can help with a problem with a Thermo Import function from SciLabCapeOpenThermo.DLL version: 2.0.0.6.

    1) The 'capeOpenEquilibrium' function presents an error message when called for "gibbsEnergy" but not for "enthalpyF". Both are listed as valid by 'capeOpenFlashPropList'.
    2) The documentation for 'capeOpenEquilibriumProp' shows a '0' as the input for the 'type' parameter but an error message is generated unless "Unspecified" is used.
    3) The other functions that were used worked well as documented--Thank you.

//@@@@@@@@@@@No Error@@@@@@@@@@@@
//This code ran without error

//return EnthalpyF for specified conditions
HF = capeOpenEquilibriumProp..
(handle, "enthalpyF", X, "pressure", p, "temperature", T, "Unspecified");

//return Temperature given HF = EnthalpyF as a check to obtain previously given T condition
[phases,phaseFractions,phaseCompositions,Te,Pe]=capeOpenEquilibrium..
(handle, X,"enthalpyF", HF, "pressure", p, "Unspecified");
disp(Te)
//@@@@@@@@@@@No Error@@@@@@@@@@@@

//@@@@@@@@@@@Error@@@@@@@@@@@
//This code presented the Error Message:

//"capeOpenEquilibrium: CalcEquilibrium failed: CalcEquilibrium failed: Invalid flash specification: Unsupported flash specification 1"
//Note: list=capeOpenFlashPropList(handle) returns both 'enthalpyF' and 'gibbsEnergy' as valid properties

//return Gibbs Energy for specified conditions
GE = capeOpenEquilibriumProp..
(handle, "gibbsEnergy", X, "pressure", p, "temperature", T, "Unspecified");

//return Temperature given GE = Gibbs Energy as a check to obtain previously given T condition
//Error occurs at next instruction
[phases,phaseFractions,phaseCompositions,Te,Pe]=capeOpenEquilibrium..
(handle, X,"gibbsEnergy", GE, "pressure", p, "Unspecified");
disp(Te)
//@@@@@@@@@@@Error@@@@@@@@@@@

Thanks for any advice.
nrgeng
 
Posts: 239
Joined: 16 February 2013, 12:45
Location: USA

Re: Problem(s) with Thermo Import Function

Postby jasper » 23 January 2018, 16:47

1) The flash property list is a list of all possible properties that might be available as flash condition. This includes temperature, pressure, vapor fraction, and all extensive properties. This does not mean that the thermo package (which thermo are you using?) does indeed support all of these properties as flash conditions. CAPE-OPEN property packages do not expose a list of supported flash conditions. However, version 1.1 packages do allow for checking whether a combination of flash conditions is supported.

2) For CAPE-OPEN equilibrium the documentation states

type: string value indicating the desired solution type. Optional. Valid values are "Unspecified" (default), and if vapor fraction is part of the flash constraints, additional valid values are "Normal" or "Retrograde".


Where do you see 0 is valid for Solution Type?
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Problem(s) with Thermo Import Function {002}

Postby nrgeng » 23 January 2018, 22:09

{capeOpenEquilibrium function}

1) TEA (CAPE-OPEN 1.1) is configured as the Property Package Manager. The capeOpenFlashPropList function lists the extensive properties of "enthalpyF" and "gibbsEnergy" for the property package used.

In the code with the error,The first function successfully used gibbsEnergy, a valid propNames argument, with the capeOpenEquilibriumProp function. The second function fails to use propNames as prop1 for the capeOpenEquilibrium function. The problem as defined is that the functions work for enthalpyF, code section with No error, but not for gibbsEnergy, code section with Error.

If gibbsEnergy is not supported, then why is it listed for TEA (CAPE-OPEN 1.1)? Question: How does one check version 1.1 packages for supported extensive properties?

Since the capeOpenFlashPropList function calls the handle of the property package used, why is the returned list of properties not specific to that package? Why not call an empty function parameter list, e.g., functionList(), instead if the list is not relevant to the specified package handle? Then what use is the returned list?

2) The Example for capeOpenEquilibriumProp shows '0' in the parameter list for type. This statement is not true. The type parameter is optional so it was omitted from the parameter list of the example. The '0' appeared as the value of prop2, val2,--"vaporFraction",0), not as the value of type. The example is correct as written.
nrgeng
 
Posts: 239
Joined: 16 February 2013, 12:45
Location: USA

Re: Problem(s) with Thermo Import Function

Postby jasper » 24 January 2018, 08:24

The list of extensive properties is obtained from GetSinglePropList (and filtering out the ones that are extensive). So the returns list contains pressure, temperature, vapor fraction (if a vapor phase is defined) and all properties in the single phase property list that are extensive. The SciLab CAPE-OPEN thermo implementation does not iterate over all combinations of possibly supported properties to see which ones are actually supported. I suppose it could do so, but (apart from the slightly longer start up time) it might be somewhat error prone.

In any case, the resulting list of properties is still not decisive. For example, as temperature appears in the list, it does not imply that a temperature-temperature flash is ok (it will surely not be). In general, you cannot depend on any combination of flash properties to work. I could provide a function that will test whether a particular combination will work however.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Problem(s) with Thermo Import Function {003}

Postby nrgeng » 24 January 2018, 13:57

{capeOpenEquilibrium function}

a) My understanding of your explanation of the 'capeOpenEquilibrium' function is that one tests the code for an error and then tries another combination of flash properties until hopefully, one finds something that works.
(T)rue or (F)alse?

b) This is an odd method of programming. How can one write code to perform a calculation which possibly cannot be computed? You seem to suggest a long string of If...Then statements.
(T)rue or (F)alse?

c) By calculating H from X, p and T using the 'capeOpenEquilibriumProp' function successfully, then using the 'capeOpenEquilibrium' function to calculate T from X, H, and p successfully; why was the calculation of T unsuccessful when substituting G for H in the script? Why is this not an error? After all, G was calculated successfully, as was H, from X, p and T using the 'capeOpenEquilibriumProp' function. Is this not evidence that G is supported?
Explain, please.

d) Relevant to my Scilab script, I want to calculate the Gibbs Free Energy, G, at equilibrium for a variable Mole Fraction at a specific Temperature and Pressure. I am searching for the particular Mole Fraction that yields a Gibbs Free Energy of zero. Since the 'capeOpenEquilibrium' function presents an error message for using G, do I have to calculate ∆G = ∆H -T∆S? Or does this method also have unknown success?
(T)rue or (F)alse? Explain, please.

e) Please provide any other useful information that could help to accomplish my task. Thank you.
nrgeng
 
Posts: 239
Joined: 16 February 2013, 12:45
Location: USA

Re: Problem(s) with Thermo Import Function

Postby jasper » 24 January 2018, 15:56

a) False. It will only try the combination you specify
b) False. See (a)
c) because TEA does not support Gibbs Free Energy as a flash condition
d) I suggest you use a root finder in Scilab, changing T so that G is obtained
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Problem(s) with Thermo Import Function {004}

Postby nrgeng » 25 January 2018, 12:39

{capeOpenEquilibriumProp function}

Having a problem with the capeOpenEquilibriumProp function. The function will not accept multiple properties as defined in the documentation.

// Example 1--space separated properties
[eaF , eoF , Te]=capeOpenEquilibriumProp..
(handle,"enthalpyF" "entropyF" "temperature",X,"pressure",p,"temperature",T,"Unspecified");
.......................^~~~~~~~~~^
Error: syntax error, unexpected string, expecting "," or )

// Example 2--string matrix
propNames = ["enthalpyF" , "entropyF" , "temperature"];
[eaF , eoF , Te]=capeOpenEquilibriumProp..
(handle,propNames,X,"pressure",p,"temperature",T,"Unspecified");

capeOpenEquilibriumProp: expected string for argument 2

Function
[values,...]=capeOpenEquilibriumProp(handle,propNames,X,prop1,val1,prop2,val2,type)

Arguments
propNames: string. Multiple properties can be specified; either separate
the properties by a space, or use a string matrix for multiple properties.


Hope you can help with this problem. Thanks.
nrgeng
 
Posts: 239
Joined: 16 February 2013, 12:45
Location: USA

Re: Problem(s) with Thermo Import Function

Postby jasper » 26 January 2018, 12:39

The help is incorrect - string matrix support was removed in an earlier version. Apologies. Try a single string and separate the properties by spaces:

[eaF , eoF , Te]=capeOpenEquilibriumProp(handle,"enthalpyF entropyF temperature",X,"pressure",p,"temperature",T,"Unspecified");
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: Problem(s) with Thermo Import Function

Postby jasper » 26 January 2018, 13:51

The help has been updated.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain


Return to Scilab Thermo import (AmsterCHEM)

Who is online

Users browsing this forum: No registered users and 2 guests

cron