mirror of
https://github.com/CoolProp/CoolProp.git
synced 2026-04-23 03:00:17 -04:00
* Cubic calc_molar_mass, closes #1124 * Add simplified update and output functions This allows simpler use of the low level interface by using the strings name instead of the parameter number. The parameter number version stays and will be faster for more than one call with the same parameter. * Add AbstractState_update_and_1_out * Export specify_phase() to the library * small correction Safer to only accept an array of real numbers here. * Small correction Specifying the type of the array to avoid any convertion
This commit is contained in:
@@ -479,6 +479,68 @@ EXPORT_CODE void CONVENTION AbstractState_update(const long handle, const long i
|
||||
*errcode = 3;
|
||||
}
|
||||
}
|
||||
EXPORT_CODE void CONVENTION AbstractState_specify_phase(const long handle,const char *phase, long *errcode, char *message_buffer, const long buffer_length)
|
||||
{
|
||||
*errcode = 0;
|
||||
try {
|
||||
shared_ptr<CoolProp::AbstractState> &AS = handle_manager.get(handle);
|
||||
return AS->specify_phase(CoolProp::get_phase_index(std::string(phase)));
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
EXPORT_CODE double CONVENTION AbstractState_keyed_output(const long handle, const long param, long *errcode, char *message_buffer, const long buffer_length)
|
||||
{
|
||||
*errcode = 0;
|
||||
@@ -613,6 +675,37 @@ EXPORT_CODE void CONVENTION AbstractState_update_and_common_out(const long handl
|
||||
}
|
||||
}
|
||||
|
||||
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 (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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user