Page 1 of 1

SetOverallProp fails on material object

Posted: 30 November 2017, 16:22
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

Re: SetOverallProp fails on material object

Posted: 06 July 2018, 19:14
by DanW
Can you check/test if this is fixed on the most recent DWSIM versions?

Re: SetOverallProp fails on material object

Posted: 07 August 2018, 12:22
by greTol
DWSIM 5.2 Update 10: Same error message as before (see attached screenshot).
[edit: screenshot updated]

Re: SetOverallProp fails on material object

Posted: 10 October 2018, 17:25
by DanW
Can you try debugging your UO with OATS and attach the output log file?