Skip to content

Commit

Permalink
Add first_saturation_deriv to high-level interface around AbstractSta…
Browse files Browse the repository at this point in the history
…te; closes #835
  • Loading branch information
ibell committed Oct 16, 2015
1 parent 62bb74d commit 4b8bd14
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
12 changes: 12 additions & 0 deletions include/CoolPropLib.h
Expand Up @@ -271,6 +271,18 @@
* @return
*/
EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long *errcode, char *message_buffer, const long buffer_length);

/**
* @brief Calculate a saturation derivative from the AbstractState using integer values for the desired parameters
* @param handle The integer handle for the state class stored in memory
* @param Of The parameter of which the derivative is being taken
* @param Wrt The derivative with with respect to this parameter
* @param errcode The errorcode that is returned (0 = no error, !0 = error)
* @param message_buffer A buffer for the error code
* @param buffer_length The length of the buffer for the error code
* @return
*/
EXPORT_CODE double CONVENTION AbstractState_first_saturation_deriv(const long handle, const long Of, const long Wrt, long *errcode, char *message_buffer, const long buffer_length);



Expand Down
33 changes: 33 additions & 0 deletions src/CoolPropLib.cpp
Expand Up @@ -485,4 +485,37 @@ EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, cons
*errcode = 3;
}
return _HUGE;
}

EXPORT_CODE double CONVENTION AbstractState_first_saturation_deriv(const long handle, const long Of, const long Wrt, long *errcode, char *message_buffer, const long buffer_length)
{
*errcode = 0;
try{
shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
return AS->first_saturation_deriv(static_cast<CoolProp::parameters>(Of), static_cast<CoolProp::parameters>(Wrt));
}
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;
}

0 comments on commit 4b8bd14

Please sign in to comment.