mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
Correct vector size in the cubic backend (#1129)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user