void CapeOpenCalculator::setSubstanceConstants() { // Let the property package calc the constant props CVariant props; if(_socket->GetMaterialObject()->getLiquidPhasePossible()) props.MakeArray(COPropsConst::Count, VT_BSTR); else props.MakeArray(1, VT_BSTR); for (int i = 0; i < COPropsConst::Count; i++) { if(wcscmp(COPropsConst::At[i], COPropsConst::TCRIT) == 0 || wcscmp(COPropsConst::At[i], COPropsConst::PCRIT) == 0) { if(_socket->GetMaterialObject()->getLiquidPhasePossible()) { props.SetStringAt(i, COPropsConst::At[i]); } else { warningMessage("CapeOpenCalculator", "Fluid constant \"%S\" is unavailable for %s.", COPropsConst::At[i], _libraryName.c_str()); } } else { props.SetStringAt(i, COPropsConst::At[i]); } } CVariant results; results.MakeArray(COPropsConst::Count * _numCompounds, VT_VARIANT); _socket->GetConstants(props, results); // Get the results for(int i = 0; i < _numCompounds; ++i) { FluidConstants fc; fc.MM = V_R8(&results.GetVariantAt(COPropsConst::MMOL_ID * _numCompounds + i)); // result is expected in kg/mol (SI)! if(_socket->GetMaterialObject()->getLiquidPhasePossible()) { fc.Tc = V_R8(&results.GetVariantAt(COPropsConst::TCRIT_ID * _numCompounds + i)); fc.pc = V_R8(&results.GetVariantAt(COPropsConst::PCRIT_ID * _numCompounds + i)); } this->_fluidConstants.push_back(fc); } // set molar mass of material object (mixtures: temporarily set to molar mass of first compound, total/average is calculated in setSubstanceProperties()) _socket->GetMaterialObject()->setMM(_fluidConstants[0].MM); // TODO: Get the other constants using a flash /* this->doFlash(this->_fluidConstants.pc, this->_fluidConstants.Tc, COPropsOverall::PRESSURE, COPropsOverall::TEMPERATURE, COFlashTypes::TP); this->doCalcOverall(); this->getPropOverall(COPropsOverall::DENSITY, this->_fluidConstants.dc); this->getPropOverall(COPropsOverall::ENTHALPY, this->_fluidConstants.hc); this->getPropOverall(COPropsOverall::ENTROPY, this->_fluidConstants.sc); */ }