SetOverallProp fails on material object

Discusses use of CAPE-OPEN interfaces in DWSIM, an open-source piece of sofware developed by Daniel WAGNER.

Moderator: DanW

SetOverallProp fails on material object

Postby greTol » 30 November 2017, 16:22

Hi,

I try to solve my unit operation in DWSIM and get an error message when calling 'SetOverallProp' on the material object.
My problem is that the particular code in the unit operation is generated by AmsterCHEM's COM CAPE-OPEN Wizard (C++) and the socket is part of DWSIM (vb).
The same unit operation solves without error message in COFE.

[ERROR] [29.11.2017 14:06:55] COUO-004: CAPE-OPEN Exception 0 at ICapeUnit:ScaledMixerSplitter::Calculate. Reason: Failed to set enthalpy at material object: Ungültiger Zeiger
(invalid pointer)

Unit Operation (C++, custom code):
Code: Select all
static double fun_51528(Material mat, double std_h, double std_p, vector<double> *composition, int nCompounds){
   double std_T = 300.0;
   mat->PHFlash(std_p, std_h,nCompounds,composition->data(),&std_T);
   return std_T;
}

Unit Operation (C++, excerpt, generated by wizard):
Code: Select all
   void PHFlash(const double P,const double H,const int nComp,const double *Z,double *T) override {
      //P-H flash
      vscalar.SetDoubleAt(0,H);
      HRESULT hr=mat->SetOverallProp(enthalpy,mole,vscalar.Value());
      if (FAILED(hr)) throw COException(L"Failed to set enthalpy at material object: "+CO_Error(mat,hr));
      //get temperature
      if (T) *T=GetTemperature();
   }


DWSIM Material Object (vb, delegate/adapter):
Code: Select all
Public Sub SetOverallProp(ByVal [property] As String, ByVal basis As String, ByVal values As Object) Implements ICapeThermoMaterial.SetOverallProp
            Me.SetSinglePhaseProp([property], "Overall", basis, values)
End Sub


DWSIM Material Object (vb, just the function signature):
Code: Select all
Public Sub SetSinglePhaseProp(ByVal [property] As String, ByVal phaseLabel As String, ByVal basis As String, ByVal values As Object) Implements ICapeThermoMaterial.SetSinglePhaseProp
    ...
End Sub


DWSIM is free software, so one can take a look at the source code:

Public Sub SetOverallProp:
https://github.com/DanWBR/dwsim5/blob/m ... m.vb#L4633

Public Sub SetSinglePhaseProp:
https://github.com/DanWBR/dwsim5/blob/m ... m.vb#L4720

Unfortunately I'm not familiar enough with both C++ and vb to see what's going wrong.

Anyone any ideas?

With best regards,

greTol
greTol
 
Posts: 20
Joined: 26 August 2013, 14:45

Re: SetOverallProp fails on material object

Postby DanW » 06 July 2018, 19:14

Can you check/test if this is fixed on the most recent DWSIM versions?
DanW
 
Posts: 17
Joined: 01 November 2012, 03:01

Re: SetOverallProp fails on material object

Postby greTol » 07 August 2018, 12:22

DWSIM 5.2 Update 10: Same error message as before (see attached screenshot).
[edit: screenshot updated]
Attachments
screenshot_dwsim_COunit_invalidPointer.png
screenshot_dwsim_COunit_invalidPointer.png (138.4 KiB) Viewed 24808 times
greTol
 
Posts: 20
Joined: 26 August 2013, 14:45

Re: SetOverallProp fails on material object

Postby DanW » 10 October 2018, 17:25

Can you try debugging your UO with OATS and attach the output log file?
DanW
 
Posts: 17
Joined: 01 November 2012, 03:01


Return to DWSIM

Who is online

Users browsing this forum: No registered users and 1 guest

cron