Page 1 of 1

Error getting single phase heatCapacityCp

Posted: 31 October 2021, 12:23
by ahmedsabriz
Greetings, I am trying to get heatCapacityCp for calculation method in COBIA unit operation but getting the following error:
CAPE-OPEN error, caused by: in ICapeThermoMaterial::GetSinglePhaseProp of 'feed': no values set for heatCapacityCp, phase Vapor, CalcType mixture (2x)
Here is a sample code:

Code: Select all

CAPEOPEN_1_2::CapeThermoMaterial foo;
foo = feed->getMaterial()

CapeArrayStringImpl phaseLabels;
CapeArrayEnumerationImpl<CAPEOPEN_1_2::CapePhaseStatus> phaseStatus;
foo.GetPresentPhases(phaseLabels, phaseStatus);

CapeArrayRealImpl Cp;
Cp.resize(phaseLabels.size());

for (ConstCapeString phaseLabel : phaseLabels) {
	CapeArrayRealImpl phaseCp;
	foo.GetSinglePhaseProp(ConstCapeString(COBIATEXT("heatCapacityCp")),
		phaseLabel, ConstCapeString(COBIATEXT("mole")), phaseCp);
	Cp.emplace_back(phaseCp[0]);
}
I can clearly see the phase heatCapacityCp value for the mixture in COFE. So, I'm a bit confused about the error. Hope to get your help on it.

Re: Error getting single phase heatCapacityCp

Posted: 01 November 2021, 08:01
by jasper
before you can get a property from a material object (short of the properties that are available at phase equilibrium, which are flow rate, composition, pressure, temperature and phase fraction), you must first calculate the property using CalcSinglePhaseProp.

Note that CAPE-OPEN unit operations may not have side effects on material objects connected to feeds, so this CalcSinglePhaseProp may not be performed on the feed material object itself. But you can duplicate the feed material object, and perform the calculation on the temporary material object that results from that. Or copy the feed to the product first, then perform the calculation.

Re: Error getting single phase heatCapacityCp

Posted: 01 November 2021, 13:41
by ahmedsabriz
Turns out I overlooked this step indeed. Thanks as usual for great support and tips. Working as intended now.