COFE functions in Excel

Discusses use of COCO, the process simulation and modelling software suite from AmsterCHEM, downloadable from http://www.cocosimulator.org

Moderator: jasper

COFE functions in Excel

Postby HenkF » 06 December 2014, 12:33

Hi all, and foremost Jasper!
I wonder if there is a function available which gives me the vapor/liquid fractions when using the COFE.xlt template in Excel.
Temperature, pressure, composition, all is available from a the loaded flowsheet. (and works fabulous for me!)

Thanks!
regards, Henk
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: COFE functions in Excel

Postby jasper » 06 December 2014, 13:22

You could use COFE_CalculateEquilibrium, using the stream's overall composition and temperature and pressure, but this will not work for a pure compound stream in the two phase region. I agree that such functionality would be useful. Do you need it for a pure compound stream?
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE functions in Excel

Postby HenkF » 06 December 2014, 15:59

Hi Jasper,
You are right, I would like to report the phase fractions (V/L) for a pure compound, the water/steam system. (evaporator tubes and turbine run off)
I would like to use it to generate stream reports using Excel. I've indeed tried COFE_CalculateEquilibrium, and that works pretty well. But unfortunately not for a pure compound system. Any workaround? I tried PH instead of a TP flash, but there's no stream enthalpy available. For the critical streams (there are only a few spots where both phases exist) I could add the unit enthalpy change to the stream enthalphy and do a PH flash. But making the VL fraction and/or stream enthalpy available would make life even sweeter!
Thanks for your swift reaction!
Regards, Henk
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: COFE functions in Excel

Postby jasper » 07 December 2014, 08:31

I added support for these functions:

Public Function COFE_GetStreamPresentPhases(streamID, Optional growArray As Integer = 0)
Public Function COFE_GetStreamPhaseFraction(streamID, phase As String, basis As String)
Public Function COFE_GetStreamPhaseComposition(streamID, phase As String, basis As String, Optional growArray As Integer = 0)

You will have to base your document on a new COFE.xlt however (or open a new document based on COFE.xlt, and copy these three functions into the VBA of your existing document using the VBA editor in Excel).

The new functions are documented in the help:

http://cocosimulator.org/index_help.php ... stream.htm

The update is available via CUP.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE functions in Excel

Postby HenkF » 07 December 2014, 08:53

:D
Thanks!
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: COFE functions in Excel

Postby jasper » 07 December 2014, 10:48

You are welcome. Thanks for pointing out the shortcoming.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE functions in Excel

Postby HenkF » 08 December 2014, 11:14

I wouldn't say it's a shortcoming, more a step towards an even more mature environment! I'm perfectly happpy with how all evolves. :-)
Another question on Excel functions: they quite well support reporting simulation results, and follow-up calculations.

Is it possible to change and pass e.g. pressure, temperature and composition values from within Excel?

best regards, Henk
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: COFE functions in Excel

Postby jasper » 08 December 2014, 12:15

Well - yes, you can, however:

Generally if COFE makes changes, it knows what it is changed. If you make changes, it does not. Particularly, it is not a good idea to make structural changes, such as disconnecting or connecting streams. If you change data (stream values, unit operation parameter values) COFE will now know that the solution state may be affected and may not mark the appropriate units and streams as unsolved. Changes that are done via the stream dialog are additionally marked as initial guesses; also this mechanism you will bypass.

Hence, care must be taken that there may be unexpected side effects. The Excel interface is meant to read data, not to write data.

This is also explained here: http://cocosimulator.org/index_help.php ... mation.htm
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: COFE functions in Excel

Postby HenkF » 08 December 2014, 13:24

OK, thanks! I will give it a try.
Could you please have a look at a save/restore issue, when saving a copy from Excel? From the add-in menu COFE/Save a copy..., I did save one, and opened it (version 2.7.0.15).
It will open, but on selecting to show the flowsheet recovery stops. I've attached both xls and fsd files.
Attachments
COFE.1.fsd
Saved from COFE.1.xlsm
(383.51 KiB) Downloaded 722 times
COFE.1.xlsm
(173.77 KiB) Downloaded 712 times
HenkF
 
Posts: 87
Joined: 24 February 2013, 14:50
Location: Hengelo,NL

Re: COFE functions in Excel

Postby jasper » 09 December 2014, 14:43

(I moved your additional question into a new thread).

I find that the flowsheet inside the Excel file is empty. Is that intended? I imported the fsd file. Saved and reloaded. This seems to work.

What problem are you seeing exactly and how do I reproduce it?
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Next

Return to COCO (AmsterCHEM)

Who is online

Users browsing this forum: No registered users and 16 guests