CoolProp / CoolProp

Thermophysical properties for the masses
http://coolprop.org/
MIT License
790 stars 308 forks source link

Add derivatives of vr and Tr with respect to beta and gamma #1179

Closed ibell closed 8 years ago

ibell commented 8 years ago

Testing code:

#if 0
    std::vector<std::string> names; names.push_back("n-Butane"); names.push_back("Ethane");
    shared_ptr<CoolProp::AbstractState> AS(CoolProp::AbstractState::factory("HEOS", names));

    std::vector<double> z(2, 0.5);
    AS->set_mole_fractions(z);

    HelmholtzEOSMixtureBackend *HEOS = static_cast<HelmholtzEOSMixtureBackend*>(AS.get());
    GERG2008ReducingFunction *GERG = static_cast<GERG2008ReducingFunction*>(HEOS->Reducing.get());
    double dTrdgT = GERG->dTr_dgammaT(z);
    double gT = AS->get_binary_interaction_double(0, 1, "gammaT");
    AS->set_binary_interaction_double(0, 1, "gammaT", gT+0.0001); double Trp = AS->T_reducing();
    AS->set_binary_interaction_double(0, 1, "gammaT", gT-0.0001); double Trm = AS->T_reducing();
    double deriv = (Trp-Trm)/0.0002;
#endif

#if 1
    std::vector<std::string> names; names.push_back("n-Butane"); names.push_back("Ethane");
    shared_ptr<CoolProp::AbstractState> AS(CoolProp::AbstractState::factory("HEOS", names));

    std::vector<double> z(2, 0.5);
    AS->set_mole_fractions(z);

    HelmholtzEOSMixtureBackend *HEOS = static_cast<HelmholtzEOSMixtureBackend*>(AS.get());
    GERG2008ReducingFunction *GERG = static_cast<GERG2008ReducingFunction*>(HEOS->Reducing.get());
    double dTrdgT = GERG->drhormolar_dgammaV(z);
    double gT = AS->get_binary_interaction_double(0, 1, "gammaV");
    AS->set_binary_interaction_double(0, 1, "gammaV", gT+0.0001); double Trp = AS->rhomolar_reducing();
    AS->set_binary_interaction_double(0, 1, "gammaV", gT-0.0001); double Trm = AS->rhomolar_reducing();
    double deriv = (Trp-Trm)/0.0002;
    int rrr =0;
#endif
ibell commented 8 years ago

Closed by dfb89141e66f1674e4c9d96e3159e874ef574849