Exemplo n.º 1
0
EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        return AS->keyed_output(static_cast<CoolProp::parameters>(param));
    }
    catch(CoolProp::HandleError &e){
        std::string errmsg = std::string("HandleError: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(CoolProp::CoolPropBaseError &e){
        std::string errmsg = std::string("Error: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(...){
        *errcode = 3;
    }
    return _HUGE;
}
Exemplo n.º 2
0
EXPORT_CODE void CONVENTION AbstractState_update_and_5_out(const long handle, const long input_pair, const double* value1, const double* value2, const long length, long* outputs, double* out1, double* out2, double* out3, double* out4, double* out5, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);

        for (int i = 0; i<length; i++){
            try{
                AS->update(static_cast<CoolProp::input_pairs>(input_pair), *(value1+i), *(value2+i));
                *(out1+i) = AS->keyed_output(static_cast<CoolProp::parameters>(outputs[0]));
                *(out2+i) = AS->keyed_output(static_cast<CoolProp::parameters>(outputs[1]));
                *(out3+i) = AS->keyed_output(static_cast<CoolProp::parameters>(outputs[2]));
                *(out4+i) = AS->keyed_output(static_cast<CoolProp::parameters>(outputs[3]));
                *(out5+i) = AS->keyed_output(static_cast<CoolProp::parameters>(outputs[4]));
            }
            catch (...){

            }
        };
    }
    catch (CoolProp::HandleError &e){
        std::string errmsg = std::string("HandleError: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch (...){
        *errcode = 3;
    }
}
Exemplo n.º 3
0
EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long input_pair, const double value1, const double value2, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->update(static_cast<CoolProp::input_pairs>(input_pair), value1, value2);
    }
    catch(CoolProp::HandleError &e){
        std::string errmsg = std::string("HandleError: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(CoolProp::CoolPropBaseError &e){
        std::string errmsg = std::string("Error: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(...){
        *errcode = 3;
    }
}
Exemplo n.º 4
0
EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handle, const long input_pair, const double* value1, const double* value2, const long length, double* T, double* p, double* rhomolar, double* hmolar, double* smolar, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);

        for (int i = 0; i<length; i++){
            try{
                AS->update(static_cast<CoolProp::input_pairs>(input_pair), *(value1+i), *(value2+i));
                *(T+i) = AS->T();
                *(p+i) = AS->p();
                *(rhomolar+i) = AS->rhomolar();
                *(hmolar+i) = AS->hmolar();
                *(smolar+i) = AS->smolar();
            }
            catch (...){
                
            }
        };
    }
    catch (CoolProp::HandleError &e){
        std::string errmsg = std::string("HandleError: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch (...){
        *errcode = 3;
    }
}
Exemplo n.º 5
0
EXPORT_CODE void CONVENTION  AbstractState_set_fluid_parameter_double(const long handle, const long i, const char* parameter, const double value , long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->set_fluid_parameter_double(static_cast<std::size_t>(i), parameter, value);
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}
Exemplo n.º 6
0
EXPORT_CODE void CONVENTION AbstractState_build_spinodal(const long handle, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->build_spinodal();
    }
    catch (...) {
        HandleException(errcode, message_buffer, buffer_length);
    }
}
Exemplo n.º 7
0
EXPORT_CODE void CONVENTION AbstractState_unspecify_phase(const long handle, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        return AS->unspecify_phase();
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}
Exemplo n.º 8
0
EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long input_pair, const double value1, const double value2, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        AS->update(static_cast<CoolProp::input_pairs>(input_pair), value1, value2);
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}
Exemplo n.º 9
0
EXPORT_CODE double CONVENTION AbstractState_first_partial_deriv(const long handle, const long Of, const long Wrt, const long Constant, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        return AS->first_partial_deriv(static_cast<CoolProp::parameters>(Of), static_cast<CoolProp::parameters>(Wrt), static_cast<CoolProp::parameters>(Constant));
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
    return _HUGE;
}
Exemplo n.º 10
0
EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        return AS->keyed_output(static_cast<CoolProp::parameters>(param));
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
    return _HUGE;
}
Exemplo n.º 11
0
EXPORT_CODE void CONVENTION AbstractState_get_spinodal_data(const long handle, const long length, double* tau, double* delta, double* M1, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        CoolProp::SpinodalData spin = AS->get_spinodal_data();
        if (spin.tau.size() > static_cast<std::size_t>(length)){
            throw CoolProp::ValueError(format("Length of spinodal vectors [%d] is greater than allocated buffer length [%d]", static_cast<int>(spin.tau.size()), static_cast<int>(length)));
        }
        for (std::size_t i = 0; i<spin.tau.size(); ++i){
            *(tau+i) = spin.tau[i];
            *(delta+i) = spin.delta[i];
            *(M1+i) = spin.M1[i];
        }
    }
    catch (...) {
        HandleException(errcode, message_buffer, buffer_length);
    }
}
Exemplo n.º 12
0
EXPORT_CODE void CONVENTION AbstractState_all_critical_points(const long handle, long length, double *T, double *p, double *rhomolar, long *stable, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        std::vector<CoolProp::CriticalState> pts = AS->all_critical_points();
        if (pts.size() > static_cast<std::size_t>(length)){
            throw CoolProp::ValueError(format("Length of critical point vector [%d] is greater than allocated buffer length [%d]", static_cast<int>(pts.size()), static_cast<int>(length)));
        }
        for (std::size_t i = 0; i < pts.size(); ++i){
            *(T+i) = pts[i].T;
            *(p+i) = pts[i].p;
            *(rhomolar+i) = pts[i].rhomolar;
            *(stable+i) = pts[i].stable;
        }
    }
    catch (...) {
        HandleException(errcode, message_buffer, buffer_length);
    }
}
Exemplo n.º 13
0
EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double *fractions, const long N, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    std::vector<double> _fractions(fractions, fractions + N);
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        if (AS->using_mole_fractions()){
            AS->set_mole_fractions(_fractions);
        }
        else if (AS->using_mass_fractions()){
            AS->set_mass_fractions(_fractions);
        }
        else if (AS->using_volu_fractions()){
            AS->set_volu_fractions(_fractions);
        }
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}
Exemplo n.º 14
0
EXPORT_CODE void CONVENTION AbstractState_update_and_1_out(const long handle, const long input_pair, const double* value1, const double* value2, const long length, const long output, double* out, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);

        for (int i = 0; i<length; i++) {
            try {
                AS->update(static_cast<CoolProp::input_pairs>(input_pair), *(value1 + i), *(value2 + i));
                *(out + i) = AS->keyed_output(static_cast<CoolProp::parameters>(output));
            }
            catch (...) {

            }
        };
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}
Exemplo n.º 15
0
EXPORT_CODE void CONVENTION AbstractState_set_fractions(const long handle, const double *fractions, const long N, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    std::vector<double> _fractions(fractions, fractions + N);
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        if (AS->using_mole_fractions()){
            AS->set_mole_fractions(_fractions);
        }
        else if (AS->using_mass_fractions()){
            AS->set_mass_fractions(_fractions);
        }
        else if (AS->using_volu_fractions()){
            AS->set_volu_fractions(_fractions);
        }
    }
    catch(CoolProp::HandleError &e){
        std::string errmsg = std::string("HandleError: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(CoolProp::CoolPropBaseError &e){
        std::string errmsg = std::string("Error: ") + e.what();
        if (errmsg.size() < static_cast<std::size_t>(buffer_length)){
            *errcode = 1;
            strcpy(message_buffer, errmsg.c_str());
        }
        else{
            *errcode = 2;
        }
    }
    catch(...){
        *errcode = 3;
    }
}
Exemplo n.º 16
0
EXPORT_CODE void CONVENTION AbstractState_get_phase_envelope_data(const long handle, const long length, double* T, double* p, double* rhomolar_vap, double *rhomolar_liq, double *x, double *y, long *errcode, char *message_buffer, const long buffer_length) {
    *errcode = 0;
    try {
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
        CoolProp::PhaseEnvelopeData pe = AS->get_phase_envelope_data();
        if (pe.T.size() > static_cast<std::size_t>(length)){
            throw CoolProp::ValueError(format("Length of phase envelope vectors [%d] is greater than allocated buffer length [%d]", static_cast<int>(pe.T.size()), static_cast<int>(length)));
        }
        std::size_t N = pe.x.size();
        for (std::size_t i = 0; i<pe.T.size(); i++){
            *(T+i) = pe.T[i];
            *(p+i) = pe.p[i];
            *(rhomolar_vap+i) = pe.rhomolar_vap[i];
            *(rhomolar_liq+i) = pe.rhomolar_liq[i];
            for (std::size_t j = 0; j < N; ++j){
                *(x+i*N+j) = pe.x[j][i];
                *(y+i*N+j) = pe.y[j][i];
            }
        }
    }
    catch (...) {
        HandleException(errcode, message_buffer, buffer_length);
    }
}
Exemplo n.º 17
0
EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handle, const long input_pair, const double* value1, const double* value2, const long length, double* T, double* p, double* rhomolar, double* hmolar, double* smolar, long *errcode, char *message_buffer, const long buffer_length)
{
    *errcode = 0;
    try{
        shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);

        for (int i = 0; i<length; i++){
            try{
                AS->update(static_cast<CoolProp::input_pairs>(input_pair), *(value1+i), *(value2+i));
                *(T+i) = AS->T();
                *(p+i) = AS->p();
                *(rhomolar+i) = AS->rhomolar();
                *(hmolar+i) = AS->hmolar();
                *(smolar+i) = AS->smolar();
            }
            catch (...){
                
            }
        };
    }
    catch (...) {
		HandleException(errcode, message_buffer, buffer_length);
	}
}