Error getting single phase heatCapacityCp

Post Reply
ahmedsabriz
Posts: 20
Joined: 07 June 2021, 13:54

Error getting single phase heatCapacityCp

Post 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.
User avatar
jasper
Posts: 1129
Joined: 24 October 2012, 15:33
Location: Spain
Contact:

Re: Error getting single phase heatCapacityCp

Post 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.
ahmedsabriz
Posts: 20
Joined: 07 June 2021, 13:54

Re: Error getting single phase heatCapacityCp

Post by ahmedsabriz »

Turns out I overlooked this step indeed. Thanks as usual for great support and tips. Working as intended now.
Post Reply

Return to “Unit Operations”