MATLAB CAPE OPEN unit operation in HYSYS

Moderator: jasper

Motadi
Posts: 5
Joined: 13 June 2018, 09:59

MATLAB CAPE OPEN unit operation in HYSYS

Post by Motadi »

Hello,
I am using MATLAB unit operation with CAPE-OPEN V1.0 in Aspen HYSYS V9.0. MATLAB CAPE OPEN unit operation works fine except for the time that I make a “parameter” in the unit operation (see Figure 1). After making a “parameter”, I always get an error as in Figure 2. This error appears each time the model runs. What can be the cause of this problem?

Thank you very much,
Figure 1
Figure 1
Figure 1.png (21.64 KiB) Viewed 34797 times
Figure 2
Figure 2
Figure 2.png (3.32 KiB) Viewed 34797 times
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by jasper »

It is very hard to say, from an error message like this. I will ask around to see if I can find anything, but I suppose the way to go to resolve this one is to contact AspenTech support.
Motadi
Posts: 5
Joined: 13 June 2018, 09:59

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by Motadi »

Thank you for the reply.
I contacted AspenTech and this is their response:
"Unfortunately, this query relates to a third party extension which we are not responsible for. As such, we will not be able to support you on this item.
AspenTech Support will be able to assist with integration issues between CAPE-OPEN and Aspen HYSYS, but with regards to the code within the unit operation itself, we suggest you contact CAPE-OPEN directly."
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by jasper »

The error code 0x80040501 is the generic CAPE-OPEN error code, and comes with a textual error description, which HYSYS should display.

AspenTech surely knows well that CAPE-OPEN is a standard set, and not a person or company - I am not impressed by their efforts to help you.

What you can do is use a logger (either COLTT, by CO-LaN, or OATS/COULIS, by COCOSimulator) to log the interaction, and get the error description from the log. Would you be so kind?
Motadi
Posts: 5
Joined: 13 June 2018, 09:59

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by Motadi »

Thank you very much for the answer.
I made a log with COLTT which is attached here:
aspenhysys_081418_215119.zip
(5.38 KiB) Downloaded 1538 times
The name of the parameter is "testPar".
Motadi
Posts: 5
Joined: 13 June 2018, 09:59

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by Motadi »

Hello,
By analyzing the log, the error code was related to the fact that a "Default" value was not defined for the defined "parameter". This was confusing, because I did not get any error while using cape open v1.1.
This was the error description in the log: "Error returned from get_DefaultValue - 0x80040501".

So this problem is solved, however I have another problem: I want to get singlephase property "activity" for the liquid phase, however I get error. Here is the error description in the log generated by COLTT:

Property Phase Basis Calc Value returned
activity Liquid (null) mixture
COLTT <duplicate of 1> : Windows error code returned is: 0x80131500 - not known
COLTT <duplicate of 1> : Getting error details from IErrorInfo interface:
COLTT <duplicate of 1> : Call to GetSource
GetSource returns:
Interface : ICapeThermoMaterialObject
COLTT <duplicate of 1> : Return from GetSource - Succeeded
COLTT <duplicate of 1> : Call to GetDescription
GetDescription returns:
Description : Cannot calculate property {activity,Liquid,,,Mixture} because the phase fraction has not been set


I am using this command: value=getSinglePhaseProperty('activity','Liquid',T,P,moleFraction)
The error log says "the phase fraction has not been set", but "phase fraction" is not an input to this command.

I appreciate your help,

Best regards,
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by jasper »

Apologies, I missed your post.

That is certainly an interesting message that you flag there. You are correct about the default value.

The other message is rather interesting. Why would Aspen HYSYS possibly require a phase fraction to be set to calculate an activity? Can you calculate other properties under the same conditions?
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by jasper »

Note that CAPE-OPEN specifies that single-phase properties depend on T, P and X, and can be calculated under single phase (non-equilibrium) conditions. So phase fraction should not be required for calculation of activity for a given phase.
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by jasper »

Can you get logFugacityCoefficient? In that case you can work around the problem.
Motadi
Posts: 5
Joined: 13 June 2018, 09:59

Re: MATLAB CAPE OPEN unit operation in HYSYS

Post by Motadi »

jasper wrote:Apologies, I missed your post.

That is certainly an interesting message that you flag there. You are correct about the default value.

The other message is rather interesting. Why would Aspen HYSYS possibly require a phase fraction to be set to calculate an activity? Can you calculate other properties under the same conditions?
Yes, I can calculate some other properties such as "logFugacityCoefficient, Compressibility, compressibilityFactor, fugacity, ..." but NOT these properties "activity, activityCoefficient, diffusionCoefficient, gibbsEnergy, heatCapacityCp, etc. ". I will discuss this with AspenTech support.
jasper wrote:Can you get logFugacityCoefficient? In that case you can work around the problem.
Yes, I can get it. So, this can be a work around the problem.

Thank you for your help,
Post Reply

Return to “MATLAB Unit Operation (AmsterCHEM)”