Пример #1
0
void JSONFluidLibrary::set_fluid_enthalpy_entropy_offset(const std::string &fluid, double delta_a1, double delta_a2, const std::string &ref)
{
    // Try to find it
    std::map<std::string, std::size_t>::const_iterator it = string_to_index_map.find(fluid);
    if (it != string_to_index_map.end()){
        std::map<std::size_t, CoolPropFluid>::iterator it2 = fluid_map.find(it->second);
        // If it is found
        if (it2 != fluid_map.end()){
            if (!ValidNumber(delta_a1) || !ValidNumber(delta_a2) ){
                throw ValueError(format("Not possible to set reference state for fluid %s because offset values are NAN",fluid.c_str()));
            }
            it2->second.EOS().alpha0.EnthalpyEntropyOffset.set(delta_a1, delta_a2, ref);
            
            shared_ptr<CoolProp::HelmholtzEOSBackend> HEOS(new CoolProp::HelmholtzEOSBackend(it2->second));

            // Calculate the new enthalpy and entropy values
            HEOS->update(DmolarT_INPUTS, it2->second.EOS().hs_anchor.rhomolar, it2->second.EOS().hs_anchor.T);
            it2->second.EOS().hs_anchor.hmolar = HEOS->hmolar();
            it2->second.EOS().hs_anchor.smolar = HEOS->smolar();
            
            // Calculate the new enthalpy and entropy values at the reducing stat
            HEOS->update(DmolarT_INPUTS, it2->second.EOS().reduce.rhomolar, it2->second.EOS().reduce.T);
            it2->second.EOS().reduce.hmolar = HEOS->hmolar();
            it2->second.EOS().reduce.smolar = HEOS->smolar();
        }
        else{
            throw ValueError(format("fluid [%s] was not found in JSONFluidLibrary",fluid.c_str()));
        }
    }
}
Пример #2
0
std::string get_BibTeXKey(std::string Ref, std::string key)
{
    std::vector<std::string> names(1, Ref);
    HelmholtzEOSMixtureBackend HEOS(names);

    if (!key.compare("EOS")){ return HEOS.get_components()[0]->pEOS->BibTeX_EOS; }
	else if (!key.compare("CP0")){ return HEOS.get_components()[0]->pEOS->BibTeX_CP0; }
    else if (!key.compare("VISCOSITY")){ return HEOS.get_components()[0]->transport.BibTeX_viscosity; }
	else if (!key.compare("CONDUCTIVITY")){ return HEOS.get_components()[0]->transport.BibTeX_conductivity; }
	else if (!key.compare("ECS_LENNARD_JONES")){ throw NotImplementedError(); }
	else if (!key.compare("ECS_VISCOSITY_FITS")){ throw NotImplementedError(); }
    else if (!key.compare("ECS_CONDUCTIVITY_FITS")){ throw NotImplementedError(); }
    else if (!key.compare("SURFACE_TENSION")){ return HEOS.get_components()[0]->ancillaries.surface_tension.BibTeX;}
	else{ return "Bad key";}
}
Пример #3
0
std::string get_fluid_param_string(std::string FluidName, std::string ParamName)
{
	try{
        std::vector<std::string> comps(1,FluidName);
        shared_ptr<CoolProp::HelmholtzEOSMixtureBackend> HEOS(new CoolProp::HelmholtzEOSMixtureBackend(comps));

        CoolProp::CoolPropFluid *fluid = HEOS->get_components()[0];

		if (!ParamName.compare("aliases"))
		{
			return strjoin(fluid->aliases, ", ");
		}
		else if (!ParamName.compare("CAS") || !ParamName.compare("CAS_number"))
		{
            return fluid->CAS;
		}
		else if (!ParamName.compare("ASHRAE34"))
		{
            return fluid->environment.ASHRAE34;
		}
		else if (!ParamName.compare("REFPROPName") || !ParamName.compare("REFPROP_name") || !ParamName.compare("REFPROPname"))
		{
            return fluid->REFPROPname;
		}
        else if (ParamName.find("BibTeX") == 0) // Starts with "BibTeX"
        {
            std::vector<std::string> parts = strsplit(ParamName,'-');
            // 
            std::string item = parts[1];
            if (item == "EOS"){
                return fluid->pEOS->BibTeX_EOS;
            }
            else if (item == "CP0"){
                return fluid->pEOS->BibTeX_CP0;
            }
            else if (item == "SURFACE_TENSION"){
                return fluid->ancillaries.surface_tension.BibTeX;
            }
            else if (item == "MELTING_LINE"){
                return fluid->ancillaries.melting_line.BibTeX;
            }
            else if (item == "VISCOSITY"){
                return fluid->transport.BibTeX_viscosity;
            }
            else if (item == "CONDUCTIVITY"){
                return fluid->transport.BibTeX_conductivity;
            }
            else{
                return format("Could not match BibTeX item: %s", item.c_str());
            }
        }
		else
		{
			return format("Input value [%s] is invalid for Fluid [%s]",ParamName.c_str(),FluidName.c_str());
		}
	}
	catch(std::exception &e)
	{
		return(std::string("CoolProp error: ").append(e.what()));
	}
	catch(...){
		return(std::string("CoolProp error: Indeterminate error"));
	}
}