Jump to content



Featured Articles

Check out the latest featured articles.

File Library

Check out the latest downloads available in the File Library.

New Article

Product Viscosity vs. Shear

Featured File

Vertical Tank Selection

New Blog Entry

Low Flow in Pipes- posted in Ankur's blog

Exporting Heat Exchanger Curve Using Vba In Unisim/hysys


This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic
Share this topic:
| More

#1

  • guestGuests
  • 0 posts

Posted 09 June 2011 - 01:10 PM

I'm having trouble exporting the data from a Heat Exchanger Curve created in Unisim. I'm using VBA to connect to excel. If anyone has done this before, could I see some of your code, as it would help me with mine.

Thnaks a lot.

Sub Import_CE()
    Set hyAPP = CreateObject("UniSimdesign.Application")
    Set hyCase = GetObject(Range("file")) 'Pulls file path of unisim case from Excel
    
    Dim StrAir As String
    Dim StrWst As String
    Dim RHX_WE As String
    Dim RHX_CE As String
    
    RHX_CE = Range("RHX_CE").Text 'Pulls Name of Cold End HX from Excel
    
    StrAirIn = Range("CE_AIN").Text 'Pulls Name of warm end air stream into hx from Excel
    StrAirOut = Range("CE_AOUT").Text 'Pulls Name of cold end air out of hx from Excel
    StrWstIn = Range("CE_WIN").Text 'Pulls Name of CE Waste Stream into hx from Excel
    StrWstOut = Range("CEWSOUT").Text 'Pulls name of WE waste stream out of HX from Excel
        
    Set AirStr = hyCase.Flowsheet.Streams(StrAirIn)
    Set WasteStr = hyCase.Flowsheet.Streams(StrWstIn)
    Set sids = hyCase.Flowsheet.Operations
    
    'Saves varous values to Excel
    Cells(23, 2).Value = WasteStr.Temperature.GetValue("K")
    Cells(24, 2).Value = WasteStr.Pressure.GetValue("bar")
    Cells(25, 2).Value = WasteStr.MolarFlow.GetValue("lbmole/h")
    Dim fooair As Variant
    fooair = WasteStr.ComponentMolarFractionValue
    Cells(26, 2).Value = fooair(0)
    Cells(27, 2).Value = fooair(2)
    Cells(28, 2).Value = fooair(1)
    
    Cells(23, 5).Value = AirStr.Temperature.GetValue("K")
    Cells(24, 5).Value = AirStr.Pressure.GetValue("bar")
    Cells(25, 5).Value = AirStr.MolarFlow.GetValue("lbmole/h")

    fooair = AirStr.ComponentMolarFractionValue
    Cells(26, 5).Value = fooair(0)
    Cells(27, 5).Value = fooair(2)
    Cells(28, 5).Value = fooair(1)
    
    Dim CEAirSrt As String
    
    CEAirStr = StrAirIn + "-" + StrAirOut
    CEWstStr = StrWstIn + "-" + StrWstOut
    
 
    foo = sids.Item(RHX_CE).Curves.Names
    For i = 0 To 4
    MsgBox (foo(i))
    Next i
    
    'Start of problem area. I've been playing with it to get any values, hence all the pop up widows
    For i = 0 To 4
    For j = 0 To 10
    foo1 = sids.Item(RHX_CE).Curve(CEAirStr).Point(j).Temperature.Value
    MsgBox (foo1)
    Next j
    Next i

    
    


End Sub



#2 Chellani

Chellani

    Gold Member

  • Members
  • 78 posts

Posted 14 June 2011 - 03:14 AM

Hi,
If you've found solution by now; please post is for others. If not, I can give a try. I am really not good at this but if you can post the case; it would be helpful for me and I can give it a shot.
I hope you are not using end point method as it doesn't generate curve in simulator itself (correct me if I am wrong). Why are you trying to get points? I can see HeatExchangerCurve in the object browser; shouldn't that import whole curve itself?

#3 hshethna

hshethna

    Junior Member

  • Members
  • 17 posts

Posted 02 September 2011 - 01:18 PM

In the latest version of HYSYS V7.3 - it is really easy to export heat curves to Excel without writing any VB code.

Or you can do it using Aspen Simulation Workbook very easily.

Let me know if you need more help.

#4 lugoman

lugoman

    Brand New Member

  • Members
  • 3 posts

Posted 05 September 2011 - 04:36 PM

HYSYS heat release curve macro attached

Attached Files



#5 hshethna

hshethna

    Junior Member

  • Members
  • 17 posts

Posted 24 November 2011 - 06:13 AM

Please use V7.3 HYSYS, very easy - no need for any VB code




Similar Topics