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

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

SetOverallProp fails on material object

Post by greTol »

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
DanW
Posts: 17
Joined: 01 November 2012, 03:01

Re: SetOverallProp fails on material object

Post by DanW »

Can you check/test if this is fixed on the most recent DWSIM versions?
greTol
Posts: 20
Joined: 26 August 2013, 14:45

Re: SetOverallProp fails on material object

Post by greTol »

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 36031 times
DanW
Posts: 17
Joined: 01 November 2012, 03:01

Re: SetOverallProp fails on material object

Post by DanW »

Can you try debugging your UO with OATS and attach the output log file?
Post Reply

Return to “DWSIM”