Correct vector size in the cubic backend (#1129)

This commit is contained in:
JonWel
2016-06-21 16:23:31 +02:00
committed by Ian Bell
parent 5eba323c09
commit 4d679c05f1
3 changed files with 8 additions and 8 deletions

View File

@@ -28,8 +28,10 @@ void CoolProp::AbstractCubicBackend::setup(bool generate_SatL_and_SatV){
bool SatLSatV = false;
SatL.reset(this->get_copy(SatLSatV));
SatL->specify_phase(iphase_liquid);
linked_states.push_back(SatL);
SatV.reset(this->get_copy(SatLSatV));
SatV->specify_phase(iphase_gas);
linked_states.push_back(SatV);
}
}

View File

@@ -43,11 +43,6 @@ public:
bool using_mass_fractions(void){return false;};
bool using_volu_fractions(void){return false;};
void set_mole_fractions(const std::vector<CoolPropDbl> &mole_fractions){
resize(mole_fractions.size());
this->mole_fractions = mole_fractions;
this->mole_fractions_double = std::vector<double>(mole_fractions.begin(), mole_fractions.end());
};
void set_mass_fractions(const std::vector<CoolPropDbl> &mass_fractions){throw NotImplementedError("Mass composition has not been implemented.");};
void set_volu_fractions(const std::vector<CoolPropDbl> &volu_fractions){throw NotImplementedError("Volume composition has not been implemented.");};
const std::vector<CoolPropDbl> & get_mole_fractions(void){ return this->mole_fractions; };
@@ -204,6 +199,7 @@ public:
const double R_u,
bool generate_SatL_and_SatV = true){
std::vector<double> Tc, pc, acentric;
N = fluid_identifiers.size();
for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
CubicLibrary::CubicsValues val = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(val.Tc);
@@ -244,6 +240,7 @@ public:
const double R_u,
bool generate_SatL_and_SatV = true){
std::vector<double> Tc, pc, acentric;
N = fluid_identifiers.size();
for (std::size_t i = 0; i < fluid_identifiers.size(); ++i){
CubicLibrary::CubicsValues val = CubicLibrary::get_cubic_values(fluid_identifiers[i]);
Tc.push_back(val.Tc);

View File

@@ -113,9 +113,6 @@ void HelmholtzEOSMixtureBackend::set_mole_fractions(const std::vector<CoolPropDb
// Copy values without reallocating memory
this->mole_fractions = mole_fractions; // Most effective copy
this->resize(N); // No reallocation of this->mole_fractions happens
// Resize the vectors for the liquid and vapor, but only if they are in use
if (this->SatL) this->SatL->resize(N);
if (this->SatV) this->SatV->resize(N);
// Also store the mole fractions as doubles
this->mole_fractions_double = std::vector<double>(mole_fractions.begin(), mole_fractions.end());
};
@@ -146,6 +143,10 @@ void HelmholtzEOSMixtureBackend::resize(std::size_t N)
this->mole_fractions.resize(N);
this->K.resize(N);
this->lnK.resize(N);
for (std::vector<shared_ptr<HelmholtzEOSMixtureBackend> >::iterator it = linked_states.begin(); it != linked_states.end(); ++it) {
it->get()->N = N;
it->get()->resize(N);
}
}
void HelmholtzEOSMixtureBackend::recalculate_singlephase_phase()
{