how to get the ICapeThermoMaterialTemplate Interface

how to get the ICapeThermoMaterialTemplate Interface

Postby bcbooo » 31 May 2013, 15:20

In the CO Thermo Version 1.0, I have finished use ICapeThermoSystem's ResolvePropertyPackage() to get the ICapeThermoPackage. Then I find if I want to set the material's temperature, pressure, totalflow ,and so on, I need to get the ICapeThermoMaterialObject interface.But I can't make it, here I want to know use which function I could get the ICapeThermoMaterialTemplate interface? Could anyone show me the way to use a CO 1.0 Property Package ?

Thanks!
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby jasper » 31 May 2013, 20:25

If you want to use a property package, you should implement the material object.

Effectively you are writing a PME (Process Modeling Environment) that uses a PMC (Process Modeling Client) which is the Property Package. The Material Object is implemented by the PME.

To do so, create a new COM object and implement ICapeIdentification, the error common interfaces and ICapeThermoMaterialObject. Note that as you own the material object, you do not need to call SetProp on the material object to set T, P and X before a property calculation; the Property Package will call GetProp to get T, P and X, and will call SetProp to set the result. You do not need to call GetProp to get the result, as you can directly access whatever space you have stored the result in, in your SetProp implementation.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby bcbooo » 01 June 2013, 00:56

I'm puzzled, could you show me some code?

my code like this, the environment is visual studio 2005 MFC
Code: Select all
   wstring error;
   CLSID clsid;
   CLSIDFromProgID(OLESTR("COProperties.COPropertySystem.1"),&clsid);
 
   CComPtr<ICapeThermoSystem> pG;  //smart pointer
   HRESULT hr=pG.CoCreateInstance(clsid);
   //if(SUCCEEDED(hr)) AfxMessageBox(_T("success!"));
   VARIANT v;
   pG->GetPropertyPackages(&v);
   CVariant value(v,TRUE);
   value.CheckArray(VT_BSTR,error); //here I use your CVariant class
 
   CComPtr<IDispatch> pDispatch;
   pG->ResolvePropertyPackage(value.GetBSTRAt(0),(LPDISPATCH*)&pDispatch);
   CComPtr<ICapeThermoPropertyPackage> pPropertyPackage;
   hr= pDispatch->QueryInterface(__uuidof(ICapeThermoPropertyPackage),(LPVOID*)&pPropertyPackage);
  //if(SUCCEEDED(hr)) AfxMessageBox(_T("success!"));


Then I want to use it as my ThermoMaterialObject, how to do it?
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby jasper » 01 June 2013, 06:16

You cannot use a Property Package as a Material Object. Many functions of the Property Package take a Material Object as argument. So you pass a Material Object to the Property Package. This means that you will have to implement a Material Object.

A Material Object implements functionality to set and get property values, so it serves as a storage container. It has several tasks

- It defines which components are present in the mixture. This can be all components of the Property Package or a subset thereof (*)
- It gets passed to a Property Package for property or equilibrium calculations. It contains the calculation conditions, and the Property Package will set the results of the calculation on the Material Object (*)
- In flowsheet simulations it also represents a material stream, so it gets connected to material ports of Unit Operations.
- Therefore it serves as a means for the Unit Operation to perform property and equilibrium calculations
- The Property Package may set values in one basis (e.g. enthalpy in J/mol) and the Unit Operation may want to obtain it in another (e.g. J/kg). The Material Object has the responsibility to perform the basis conversions. For most properties this is rather straight forward using the compound molecular weights or the mixture molecular weight. However for composition derivatives you should take into account the effect of the composition change on the molecular weight as well, so the chain rule applies and conversion of, say, enthalpy.DmolFraction also requires to have the value of enthalpy.

If you are not making a flowsheet environment but if you are only interested in creating a property package to perform property and equilibrium calculations, only a subset of the functionality of a Material Object needs to be implemented. In particular, those with a (*) marked above.

I do not have a code example for a Material Object implementation at hand. It requires creation of a COM object that implements the appropriate interfaces (ICapeIdentification, error interfaces and ICapeThermoMaterialObject). You create the COM object from your own code, so it will not be created by other applications using CoCreateInstance. Hence, the COM object does not need to be registered in the Windows registry.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby bcbooo » 01 June 2013, 08:37

oh, thank you jasper, I have got it. Recently I tried to use Aspen Plus' physical property database,but I find the aspen plus only supply the CAPE-OPEN 1.0 property package. I find the CO 1.1 has a big difference with CO 1.0, CO 1.1 is easier for PME (Process Modeling Environment) to use.
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby jasper » 01 June 2013, 09:05

Yes, version 1.1 is much more pleasant in use. It also allows for more efficient implementations, in particular because checking which compounds are on the material object can be comparatively expensive with respect to property calculations (even more so for naive implementations that only use string comparisons to determine which compounds are present), and a version 1.0 PP needs to do this pretty much at every call whereas in version 1.1 you can do this at most once for each SetMaterial. So you can ask a version 1.1 PP to do multiple property or equilibrium calculations without re-obtaining the compound list.

Version 1.0 has a few other shortcomings that have been fixed in 1.1 such as poor support for multi-phase properties, multiple liquid phases, and the lack of ability to determine which flash calculations are supported.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby bcbooo » 27 June 2013, 03:31

jasper wrote:Yes, version 1.1 is much more pleasant in use. It also allows for more efficient implementations, in particular because checking which compounds are on ......


A good news is I have finished my ICapeThemoMaterialObject, and I test it with "IdealThermo_CPP_TS10.dll" supplied by colan. I called functions like "CalcEquilibrium", "CalcProp" and "GetProp", they are all well done with "IdealThermo_CPP_TS10.dll".

But when I use it to work with Aspen Plus' Thermo Property System, which accord with CAPE-OPEN 1.0 standard, It always return fail. For Aspen plus 2006.5, it can be used to "CalcEquilibrium",but when calculates property like "enthalpy", "density" and so on, it either return FAIL or a very unreasonable value. For Aspen plus V7.2, it even can't do "CalcEquilibrium" which always return FAIL!

So I speculate Aspen plus maybe fit CO 1.0 not very good. Do anyone else encounter this problem?
bcbooo
 
Posts: 66
Joined: 22 November 2012, 06:41
Location: China

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby jasper » 28 June 2013, 07:15

Best to not pass any properties on to the CalcEquilibrium call. What should be done with these is not entirely clear (not all arguments that are passed to CalcProp are passed to CalcEquilibrium, such as the CalcType argument). Better to ask for the phases, loop over the phases, and calculate the required property for all phases (or ask for an overall property calculation, if supported).

Without further information it is hard to say what the reason for the failure in AspenProps 7.2 is.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby colancto » 01 July 2013, 11:48

I am kind of puzzled. Aspen Plus v7.2 is not that recent but not such an old version either. I would however recommend switching to a more recent version of Aspen Plus.

From the discussion I understand that a simple CalcEquilibrium request on an Aspen Properties Property Package fails. I would need the bkp file used to export the Property Package out of Aspen Plus as well as the conditions of equilibrium. Having the log file obtained with COLTT would help too understand what is going on.
User avatar
colancto
Administrateur
 
Posts: 92
Joined: 23 October 2012, 11:46

Re: how to get the ICapeThermoMaterialTemplate Interface

Postby jasper » 02 July 2013, 13:02

Agreed, more information would help.
User avatar
jasper
 
Posts: 1128
Joined: 24 October 2012, 15:33
Location: Spain

Next

Return to Thermodynamic components

Who is online

Users browsing this forum: No registered users and 1 guest

cron