Commit Graph

55 Commits

Author SHA1 Message Date
Ian Bell
91704a450b Export critical points in DLL; closes #1274 2016-10-17 19:55:25 -06:00
Ian Bell
c929e92b3d Build/retrieve phase envelope through high-level DLL; closes #1158 2016-10-13 19:35:36 -06:00
JonWel
c813eb1ace Refactor exceptions in CoolPropLib.cpp close #1200 (#1214)
There are also some exceptions that do not use this new `HandleException` function yet as they don't use the errcode and message buffer (they just set the error string):
```C++
catch (std::exception &e){ CoolProp::set_error_string(e.what()); }
    catch (...){ CoolProp::set_error_string("Undefined error"); }
```

Some functions like `AbstractState_update_and_common_out` do not have the `CoolPropBaseError` in the previous code. This will be also tested now, but should not be a problem (the `HandleError` is triggered first).
2016-08-27 19:25:26 -06:00
Ian Bell
3e9ca1fbf4 Remove non-c types from CoolPropLib.[cpp/h]
@JonWel - watch out for the use of C++ types in C header
2016-08-21 12:45:35 -06:00
Ian Bell
57584a7254 Merge VTPR (#1195)
* Added first working version of VTPR;

* Get VTPR building hopefully

* Remove more constant iterators

* Make VTPR accessible through factory

* One last const iterator

* Fix a_alpha bug and make sqrt(2) into sqrt(2.0)

* Added analytic first derivative for VTPR

* Fix another set of sqrt(2) -> sqrt(2.0)

* Add some info on the derivatives for VTPR

Looks less hopeless than I had feared

* gE/RT needs to be multiplied by RT; closes #1161

* Added first working version of VTPR;

* Get VTPR building hopefully

* Remove more constant iterators

* Make VTPR accessible through factory

* One last const iterator

* Fix a_alpha bug and make sqrt(2) into sqrt(2.0)

* Added analytic first derivative for VTPR

* Fix another set of sqrt(2) -> sqrt(2.0)

* Add some info on the derivatives for VTPR

Looks less hopeless than I had feared

* gE/RT needs to be multiplied by RT; closes #1161

* Add VTPR code from @JonWel (#1194)

* 1rst draft to implement a simple volume translation to cubics

* A bit more of VT

* Derivatives for volume translation

* Better cm initialisation

* Solves the cubic equation with volume translation

* Correct the volume translation analytic development
Looks good now

* Update VTPR to be able to use volume translation

* Unprotect cm_term
This allows it to be used from the VTPR backend

* Update CoolPropLib.def

* Better derrivative of PI_12

The expression is simpler this way

* Solves #1176
Thanks @ibell

* Change the way the volume translation parrameter is set

* Start the bm derivatives for VTPR

* Correct one derivative

* Small bug

* Better bm derivatives for VTPR

* Add am and bm component derivatives for VTPR
@ibell I did not check yet the component derivatives of this commit, bu I checked the other ones with your code.
I'll have to addapt your code to also check these ones.

I separate the `am_term` and `bm_term` as the `am_bm_term` function was called twice. This reduce the call to the am_term part as this part ends up being called only once, and this helped writing the component derivatives.

The tau derivative is done numerically untill we find time to develop the analytical one.

The `am_bm_term` function started with a `set_temperature()`. I did not checked yet why this is needed and put this set temperature at the beginning of each of the `am_term` component derivatives.

I'll try to addapt the checking code tomorow.

* tab to spaces

* Re-writing of cubic coefficients
Introducing 3 intermediary varriables that simplify the cubic's coefficient with the volume translation.

* 1rst draft to implement a simple volume translation to cubics

* A bit more of VT

* Derivatives for volume translation

* Better cm initialisation

* Solves the cubic equation with volume translation

* Correct the volume translation analytic development
Looks good now

* Update VTPR to be able to use volume translation

* Unprotect cm_term
This allows it to be used from the VTPR backend

* Update CoolPropLib.def

* Better derrivative of PI_12

The expression is simpler this way

* Solves #1176
Thanks @ibell

* Change the way the volume translation parrameter is set

* Start the bm derivatives for VTPR

* Correct one derivative

* Small bug

* Better bm derivatives for VTPR

* Add am and bm component derivatives for VTPR
@ibell I did not check yet the component derivatives of this commit, bu I checked the other ones with your code.
I'll have to addapt your code to also check these ones.

I separate the `am_term` and `bm_term` as the `am_bm_term` function was called twice. This reduce the call to the am_term part as this part ends up being called only once, and this helped writing the component derivatives.

The tau derivative is done numerically untill we find time to develop the analytical one.

The `am_bm_term` function started with a `set_temperature()`. I did not checked yet why this is needed and put this set temperature at the beginning of each of the `am_term` component derivatives.

I'll try to addapt the checking code tomorow.

* tab to spaces

* Re-writing of cubic coefficients
Introducing 3 intermediary varriables that simplify the cubic's coefficient with the volume translation.
2016-08-21 12:34:55 -06:00
JonWel
75da119182 Export set_config_string, closes #1160 (#1163) 2016-07-19 08:08:38 -06:00
JonWel
579bba98c4 Export specify_phase() to the library, closes #1133 (#1134)
* 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
2016-06-22 21:57:13 -06:00
JonWel
87fd90af84 Correct AbstractState_set_binary_interaction_double in shared library (#1117)
* Correct AbstractState_set_binary_interaction_double

Convert `i` and `j` to `size_t` when calling `AbstractState_set_binary_interaction_double`

* Addapt Julia wrapper to c16a4b6

Now `AbstractState_set_binary_interaction_double` needs `long` for `i` and `j`
2016-06-09 07:51:49 -06:00
Ian Bell
c16a4b64f5 Fix integer types in #1114 2016-06-08 07:30:28 -06:00
JonWel
afeca6a8b2 Export set_binary_interaction_double + Julia wrapper improvement (#1114)
* Precompiling of Julia Wrapper only for Julia 0.4+
Should allow to keep compatibility with Julia 0.3

* Export set_binary_interaction_double
to the shared library and add it to Julia Wrapper

* Correct comment in previous commit

* Change tab to spaces in precendent commit

* Add update_and_*_out functions

Add `AbstractState_update_and_common_out` and `AbstractState_update_and_5_out` to the wrapper

* Update .gitignore
2016-06-08 07:19:14 -06:00
Mike Kaganski
0d39b04b4b One small tweak to Props1 (#1103)
Do not try to call possibly throwing get_parameter_index if Props1SI
already returned an error

Also, add include/cubic_fluids_schema_JSON.h to gitignore
2016-06-06 19:29:30 -06:00
Ian Bell
154de451fe Fix set_reference_stateD(); closes #1091
Now all inputs are molar, and the function actually works!
2016-06-05 15:16:02 -06:00
Mike Kaganski
f7ef611f50 Set error string in get_parameter_information_string() : fixes #1096 (#1097)
Set error string in get_parameter_information_string() and fix SMath wrapper : fixes #1096
2016-06-05 14:54:42 -06:00
JonWel
a858417397 Revert part of 763d4ce to solve #1077 (#1093)
* Revert part of #763d4ce to solve #974

* Addapt Julia wrapper to dfbb3a4

May be better in the future to use a second argument and insert it to the buffer, but I don't know yet how to do properly the conversion.
So for now, will always return the "long" option.

* "long" in byte array literal

* Enhance get_parameter_information_string

as discussed in #1093

I however have a strange behavior during my testing, sometimes the parameter gets correctly recognised and I have the correct output, but sometimes it answer "parameter is invalid: parametername", whereas I send the exact same commend in Julia side...

* Terminate string with 0 when instering in the buffer

As discussed in #1093

* Better error handling for get_parameter_information_string

Now there is a distinction between error in `param` or in `Output`.

* Update CoolProp.jl

Closes #1077
2016-06-03 08:36:37 -06:00
JonWel
a5c7886e47 Export first_partial_deriv to DLL wrapper of AbstractState, see #946 (#1062) 2016-05-11 07:10:51 -06:00
Ian Bell
9ec2acc664 Add cair_sat to DLL/SO; closes #1005 2016-03-24 17:31:18 -06:00
JonWel
763d4ceb11 Correct get_parameter_information_string, fixes #974
Put the catch in a more useful way and solves the call to CoolProp::get_parameter_information.
2016-02-15 01:03:21 +01:00
Ian Bell
3c821e0637 Convert javascript to use embind - works! 2015-12-19 17:18:39 -07:00
Ian Bell
240165006a Add an accessor function to DLL to allow for getting multiple outputs at once from low-level interface
see #888
see #880
2015-12-13 00:15:24 -07:00
Ian Bell
4b8bd14d93 Add first_saturation_deriv to high-level interface around AbstractState; closes #835 2015-10-16 14:37:02 +02:00
Ian Bell
7137b0fd23 Close #535 for real this time 2015-03-11 19:24:59 -06:00
Ian Bell
7eeb81c818 Errors are handled properly in high-level wrapping of low-level API; Closes #535 2015-03-11 19:15:07 -06:00
mikekaganski
e875b56f9a Fix AbstractState_keyed_output return on error 2015-03-09 17:52:58 +10:00
mikekaganski
81e18a0a08 Fix Coverity CID 38574 2015-03-07 16:57:11 +10:00
mikekaganski
0b96d38859 Fix Coverity CID 38624 2015-03-06 19:09:11 +10:00
Ian Bell
c063a40183 Implement a wrapper of AbstractState that can be called through the shared library
Closes #508
Closes #497

Sample code:

```
    #include "CoolPropLib.h"

    const long buffer_length = 255;
    char message_buffer[buffer_length];
    long errcode = 0;
    const long N = 2;
    double fractions[N] = {0.5, 0.5};
    long T_param = get_param_index("T");
    long PQ = get_input_pair_index("PQ_INPUTS");

    long handle = AbstractState_factory("HEOS", "Water&Ethanol", &errcode, message_buffer, buffer_length);
    AbstractState_set_fractions(handle, fractions, N, &errcode, message_buffer, buffer_length);
    AbstractState_update(handle, PQ, 101325, 0,  &errcode, message_buffer, buffer_length);
    double Tc = AbstractState_keyed_output(handle, T_param, &errcode, message_buffer, buffer_length);
    AbstractState_free(handle, &errcode, message_buffer, buffer_length);
```
2015-03-01 15:30:31 -07:00
mikekaganski
28691e8e75 const, ref and iterator optimization
1. Another set of arguments optimized:
* args-by-val converted to args-by-ref
* in some cases, reverse has been done, if that is better: if the
object's copy is modified in the func, it's better to avoid extra copy
from arg to local var
2. some const functions marked as such (this is just a beginning)
3. iterators were replaced with const_iterators where applicable
4. catches that catch std::exception& changed to catch (...) - that is
safer; if exception handling is restructured, this will have to be
reconsidered anyway
5. removed some basic structures' constructors; changed them to hold
const char*s to avoid unnecessary string constructions;
6. in some places, moved variable declarations to their definitions, to
avoid calling default constructors and then assigning
7. removed some unnecessary shared_pointers in favor of local objects;
8. in FORTRAN-style functions, added const specifiers to input doubles;
9. fixed a place where values were inserted into a map while iterating
through it
10. fixed is_valid_*_derivative: they could accept incorrect values and
throw when upper index is less than lower
2015-03-01 10:51:01 +10:00
mikekaganski
75b7d51f59 Return result of redirect_stdout to user
What happens if stdout had been closed and not reopen?
2015-02-22 13:58:00 +10:00
Ian Bell
6d2f52f230 Squashed bugs found by @mikekaganski; See #483
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2015-02-21 11:26:24 -07:00
Ian Bell
4f63c8834f Fix potential buffer overflow; fixed #472 2015-02-18 20:31:52 -05:00
Ian Bell
0064728b56 Fix bug with CoolPropLib.cpp int key scope
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2015-01-30 05:07:06 -07:00
Ian Bell
2495df75ed Catch exceptions in High-Level API; Closes #441
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2015-01-30 05:00:31 -07:00
Ian Bell
2285e3b8c9 Removed some more functions
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-26 22:23:01 -05:00
Ian Bell
d064baf230 Fix bug with PhaseSI function (at DLL level) taking Output parameter as first parameter
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-18 18:18:45 -06:00
Ian Bell
71e59e3410 Disable the clearing of FPU exceptions on platforms that do not support it
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-18 16:03:27 -06:00
Ian Bell
b4e8dad1f3 On gcc/clang, always turn on FPU clearing; See #353
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-18 15:16:19 -06:00
Ian Bell
55c0e89609 Clear FPU bits for non-MSVC compilers; See #353 2014-12-18 00:47:15 +01:00
Ian Bell
4a59d578aa Only check FPU bits with MSVC compiler
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-06 16:48:03 -05:00
Ian Bell
2ae3445810 Resolved bizarre FPU exception error on windows with visual studio
Resetting the FPU flags seems to make Excel not error out randomly.  This is sort of a bug in Excel.

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-12-06 16:14:22 -05:00
Ian Bell
41fc9b1144 saturation ancillaries are now exposed through the high-level API
Closes https://github.com/CoolProp/CoolProp/issues/225

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-24 13:06:37 -05:00
Ian Bell
71a5944f51 Added tests for global and fluid params
Closes https://github.com/CoolProp/CoolProp/issues/239

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-24 12:28:29 -05:00
Ian Bell
919d155602 Fixed functions in the dll export to require the length of the output string to be supplied
See https://github.com/CoolProp/CoolProp/issues/228

Should be fixed now

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-20 18:39:33 -05:00
Ian Bell
2f94572dad Fixed (?) bug with get_global_param_string always returning empty string
See https://github.com/CoolProp/CoolProp/issues/228

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-20 17:56:52 -05:00
Ian Bell
7f0764878c Removed error variables to avoid warning
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-19 13:22:24 -05:00
Ian Bell
8327d54ea2 Replaced all tabs with spaces (finally) in C++ files
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-19 12:16:14 -05:00
Ian Bell
82faac7a14 Improve docs for DLL
See https://github.com/CoolProp/CoolProp/issues/222

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-11-19 12:00:26 -05:00
Ian Bell
70e9e14226 Exported set_reference_stateD through the library
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-10-27 20:17:38 -04:00
Ian Bell
9299cb8e07 Re-implements HAProps function at the C++ level.
Closes https://github.com/CoolProp/CoolProp/issues/182

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-10-22 21:32:22 +00:00
Ian Bell
1416f62682 Fixed bug with second linkage problem with CoolPropLib
Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-10-15 21:37:23 +02:00
Ian Bell
3310d1cf11 Fixed (?) splines in critical region
I have no explanation for the broken code that used to be in the solve_cubic function.  Seems it was related to the linear or quadratic cases but it makes no sense. Removed the code.

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
2014-10-14 14:49:19 +02:00