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;
}
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();
}
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
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
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