ChemCAD 5 services to visual basic applications: User Manual, страница 13

The calling sequence of the above methods are arbitrary. As soon as liquid-vapor data are defined, the k-values are calculated. User can call the following methods to get the results

Method             GetKValues / GetIonRates

            Returns                        number of data items returned in the argument array

Argument

Type

Description

kValues

ionFlowLbmol_Hr

float[]

float[]

calculated k-values [out]

ion rates in liquid phase [out]

If the activity coefficients or the fugacity coefficients are required, the next two functions can be used

Method             GetActivityCoefficients / GetFugacityCoefficients

            Returns                        number of data items returned in the argument array

Argument

Type

Description

actCoef

fugCoef

float[]

float[]

Activity coefficients [out]

Fugacity coefficients [out]

Example          Here we show the use of IKValues interface.

Sub KValues(ByVal ChemCADEntry As Object)

On Error Resume Next

Dim curUnitOp As Object

Dim strInfo As Object

Dim kValues As Object

Set curUnitOp = ChemCADEntry.GetCurUnitOp

Set strInfo = ChemCADEntry.GetStreamInfo

Set kValues = ChemCADEntry.GetKValues

Dim check As Integer

 ' inlets

Dim nInlets As Integer

nInlets = curUnitOp.GetNoOfInlets

Dim inletIDs(1 To SIZE_STREAM_ARRAY) As Integer

check = curUnitOp.GetInletIDs(inletIDs)

' outlets

Dim nOutlets As Integer

nOutlets = curUnitOp.GetNoOfOutlets

Dim outletIDs(1 To SIZE_STREAM_ARRAY) As Integer

check = curUnitOp.GetOutletIDs(outletIDs)

Dim nStream As Integer

Dim iStream As Integer

If nInlets > nOutlets Then

    nStream = nOutlets

Else

    nStream = nInlets

End If

' first simply pass the inlet to outlet

Dim temperature As Single

Dim pressure As Single

Dim mvf As Single

Dim enthalpy As Single

Dim component(1 To SIZE_COMP_ARRAY) As Single

Dim vaporstream As Integer

Dim liqstream As Integer

vaporstream = inletIDs(1)

liqstream = inletIDs(2)

Dim result(1 To SIZE_COMP_ARRAY) As Single

Dim dummy As Single

Dim iComp As Integer

Dim nComp As Integer

If vaporstream > 0 And liqstream > 0 Then

    Dim liqID As Integer

    Dim vapID As Integer

    liqID = liqstream

    vapID = vaporstream

    check = 0

    check = strInfo.GetStreamByID(liqID, temperature, pressure, mvf,  enthalpy, component)

    check = kValues.DefineLiquidStream(temperature, pressure, component)

    check = 0

    check = strInfo.GetStreamByID(vapID, temperature, pressure, mvf, enthalpy, component)

    check = kValues.DefineVaporStreamComponentRates(component)

    check = kValues.GetKValues(result)

    nComp = kValues.GetNoOfComponents

End If

End Sub

ENGINEERING UNIT CONVERSIONS

The interfaces described in this section are used for engineering unit conversions. Beyond the interfaces in this section, only quantities in CHEMCAD 5 internal units can be used as arguments. Sometime the same quantities are needed in current user units. Therefore three interfaces are defined for engineering unit conversions.

Description      IStreamUnitConversion interface offers the engineering unit conversion for stream data between CHEMCAD 5 internal units and current user units. It also gives the engineering unit strings for table formatting in Excel.

Definition           dispinterface IStreamUnitConversion

        {      

        methods:

short DefineStreamInCurUserUnit(float temp, float pres, float enth, float flow, short flowOption, VARIANT compFlow);

short GetStreamInInternalUnit(float* tempR, float* presPsia, float* enthBtu_Hr, float* rateLbmol_Hr, VARIANT compFlowLbmol_Hr);

short GetStreamInCurUserUnit(float* temp, float* pres, float* enth, float* tMoleRate, float* tMassRate, float* tStdLVolRate, float* tStdVVolRate, VARIANT compFlow);

short DefineStreamInInternalUnit(float tempR, float presPsia, float enthBtu_Hr, VARIANT compFlowLbmol_Hr);

void GetCurUserUnitString(BSTR* tempUnit, BSTR* presUnit, BSTR* enthUnit, BSTR* tMoleRateUnit, BSTR* tMassRateUnit, BSTR* tStdLVolRateUnit, BSTR* tStdVVolRateUnit, BSTR* compUnit, BSTR* compCate);