CoolProp
6.6.0
An open-source fluid property and humid air property database
|
#include <vector>
#include <set>
#include <cfloat>
#include <stdlib.h>
#include <algorithm>
#include <numeric>
#include <cmath>
#include "PlatformDetermination.h"
#include "CPstrings.h"
#include "Exceptions.h"
Go to the source code of this file.
Classes | |
class | Spline< X, Y > |
class | Spline< X, Y >::Element |
class | SplineClass |
Macros | |
#define | M_PI 3.14159265358979323846 |
#define | COOLPROP_OK 1 |
#define | POW5(x) ((x) * (x) * (x) * (x) * (x)) |
#define | POW6(x) ((x) * (x) * (x) * (x) * (x) * (x)) |
#define | POW7(x) ((x) * (x) * (x) * (x) * (x) * (x) * (x)) |
Functions | |
bool | ValidNumber (double x) |
template<typename T > | |
T | maxvectordiff (const std::vector< T > &z1, const std::vector< T > &z2) |
Return the maximum difference between elements in two vectors where comparing z1[i] and z2[i]. More... | |
template<typename T > | |
std::vector< T > | linspace (T xmin, T xmax, std::size_t n) |
Make a linearly spaced vector of points. More... | |
template<typename T > | |
std::vector< T > | log10space (T xmin, T xmax, std::size_t n) |
Make a base-10 logarithmically spaced vector of points. More... | |
template<typename T > | |
std::vector< T > | logspace (T xmin, T xmax, std::size_t n) |
Make a base-e logarithmically spaced vector of points. More... | |
template<typename T > | |
void | bisect_vector (const std::vector< T > &vec, T val, std::size_t &i) |
Use bisection to find the inputs that bisect the value you want, the trick here is that this function is allowed to have "holes" where parts of the the array are also filled with invalid numbers for which ValidNumber(x) is false. More... | |
template<typename T > | |
void | bisect_segmented_vector_slice (const std::vector< std::vector< T >> &mat, std::size_t j, T val, std::size_t &i) |
Use bisection to find the inputs that bisect the value you want, the trick here is that this function is allowed to have "holes" where parts of the the array are also filled with invalid numbers for which ValidNumber(x) is false. More... | |
std::size_t | powerset_dereference (std::set< std::size_t >::const_iterator v) |
std::set< std::set< std::size_t > > | powerset (std::set< std::size_t > const &set) |
bool | check_abs (double A, double B, double D) |
Some functions related to testing and comparison of values. More... | |
bool | check_abs (double A, double B) |
template<class T > | |
void | normalize_vector (std::vector< T > &x) |
template<class T > | |
T | factorial (T n) |
from http://stackoverflow.com/a/5721830/1360263 More... | |
template<class T1 , class T2 > | |
T1 | nth_derivative_of_x_to_m (T1 x, T2 n, T2 m) |
void | MatInv_2 (double A[2][2], double B[2][2]) |
double | root_sum_square (const std::vector< double > &x) |
double | interp1d (const std::vector< double > *x, const std::vector< double > *y, double x0) |
double | powInt (double x, int y) |
template<class T > | |
T | POW2 (T x) |
template<class T > | |
T | POW3 (T x) |
template<class T > | |
T | POW4 (T x) |
template<class T > | |
T | LinearInterp (T x0, T x1, T y0, T y1, T x) |
template<class T1 , class T2 > | |
T2 | LinearInterp (const std::vector< T1 > &x, const std::vector< T1 > &y, std::size_t i0, std::size_t i1, T2 val) |
template<class T > | |
T | QuadInterp (T x0, T x1, T x2, T f0, T f1, T f2, T x) |
template<class T1 , class T2 > | |
T2 | QuadInterp (const std::vector< T1 > &x, const std::vector< T1 > &y, std::size_t i0, std::size_t i1, std::size_t i2, T2 val) |
template<class T > | |
T | CubicInterp (T x0, T x1, T x2, T x3, T f0, T f1, T f2, T f3, T x) |
template<class T > | |
T | CubicInterpFirstDeriv (T x0, T x1, T x2, T x3, T f0, T f1, T f2, T f3, T x) |
template<class T1 , class T2 > | |
T2 | CubicInterp (const std::vector< T1 > &x, const std::vector< T1 > &y, std::size_t i0, std::size_t i1, std::size_t i2, std::size_t i3, T2 val) |
template<class T > | |
T | is_in_closed_range (T x1, T x2, T x) |
void | solve_cubic (double a, double b, double c, double d, int &N, double &x0, double &x1, double &x2) |
Solve a cubic with coefficients in decreasing order. More... | |
void | solve_quartic (double a, double b, double c, double d, double e, int &N, double &x0, double &x1, double &x2, double &x3) |
template<class T > | |
T | min3 (T x1, T x2, T x3) |
template<class T > | |
T | max3 (T x1, T x2, T x3) |
template<class T > | |
T | min4 (T x1, T x2, T x3, T x4) |
template<class T > | |
T | max4 (T x1, T x2, T x3, T x4) |
bool | double_equal (double a, double b) |
template<class T > | |
T | max_abs_value (const std::vector< T > &x) |
template<class T > | |
T | min_abs_value (const std::vector< T > &x) |
int | Kronecker_delta (std::size_t i, std::size_t j) |
int | Kronecker_delta (int i, int j) |
template<typename T > | |
void | sort3 (T &a, T &b, T &c) |
Sort three values in place; see http://codereview.stackexchange.com/a/64763. More... | |
template<class T > | |
T | angle_difference (T angle1, T angle2) |
double | get_HUGE () |
A simple function for use in wrappers where macros cause problems. More... | |
#define COOLPROP_OK 1 |
Definition at line 34 of file CPnumerics.h.
#define M_PI 3.14159265358979323846 |
Definition at line 30 of file CPnumerics.h.
#define POW5 | ( | x | ) | ((x) * (x) * (x) * (x) * (x)) |
Definition at line 488 of file CPnumerics.h.
#define POW6 | ( | x | ) | ((x) * (x) * (x) * (x) * (x) * (x)) |
Definition at line 489 of file CPnumerics.h.
#define POW7 | ( | x | ) | ((x) * (x) * (x) * (x) * (x) * (x) * (x)) |
Definition at line 490 of file CPnumerics.h.
T angle_difference | ( | T | angle1, |
T | angle2 | ||
) |
Due to the periodicity of angles, you need to handle the case where the angles wrap around - suppose theta_d is 6.28 and you are at an angles of 0.1 rad, the difference should be around 0.1, not -6.27
This brilliant method is from http://blog.lexique-du-net.com/index.php?post/Calculate-the-real-difference-between-two-angles-keeping-the-sign and the comment of user tk
Originally implemented in PDSim
Definition at line 660 of file CPnumerics.h.
void bisect_segmented_vector_slice | ( | const std::vector< std::vector< T >> & | mat, |
std::size_t | j, | ||
T | val, | ||
std::size_t & | i | ||
) |
Use bisection to find the inputs that bisect the value you want, the trick here is that this function is allowed to have "holes" where parts of the the array are also filled with invalid numbers for which ValidNumber(x) is false.
matrix | The vector to be bisected |
j | The index of the matric in the off-grain dimension |
val | The value to be found |
i | The index to the left of the final point; i and i+1 bound the value |
Definition at line 303 of file CPnumerics.h.
void bisect_vector | ( | const std::vector< T > & | vec, |
T | val, | ||
std::size_t & | i | ||
) |
Use bisection to find the inputs that bisect the value you want, the trick here is that this function is allowed to have "holes" where parts of the the array are also filled with invalid numbers for which ValidNumber(x) is false.
vec | The vector to be bisected |
val | The value to be found |
i | The index to the left of the final point; i and i+1 bound the value |
Definition at line 223 of file CPnumerics.h.
|
inline |
Definition at line 419 of file CPnumerics.h.
|
inline |
Some functions related to testing and comparison of values.
Definition at line 406 of file CPnumerics.h.
T2 CubicInterp | ( | const std::vector< T1 > & | x, |
const std::vector< T1 > & | y, | ||
std::size_t | i0, | ||
std::size_t | i1, | ||
std::size_t | i2, | ||
std::size_t | i3, | ||
T2 | val | ||
) |
Definition at line 547 of file CPnumerics.h.
T CubicInterp | ( | T | x0, |
T | x1, | ||
T | x2, | ||
T | x3, | ||
T | f0, | ||
T | f1, | ||
T | f2, | ||
T | f3, | ||
T | x | ||
) |
Definition at line 519 of file CPnumerics.h.
T CubicInterpFirstDeriv | ( | T | x0, |
T | x1, | ||
T | x2, | ||
T | x3, | ||
T | f0, | ||
T | f1, | ||
T | f2, | ||
T | f3, | ||
T | x | ||
) |
/brief Calculate the first derivative of the function using a cubic interpolation form
Definition at line 534 of file CPnumerics.h.
|
inline |
Definition at line 590 of file CPnumerics.h.
T factorial | ( | T | n | ) |
from http://stackoverflow.com/a/5721830/1360263
Definition at line 455 of file CPnumerics.h.
|
inline |
A simple function for use in wrappers where macros cause problems.
Definition at line 665 of file CPnumerics.h.
double interp1d | ( | const std::vector< double > * | x, |
const std::vector< double > * | y, | ||
double | x0 | ||
) |
Definition at line 12 of file CPnumerics.cpp.
T is_in_closed_range | ( | T | x1, |
T | x2, | ||
T | x | ||
) |
Definition at line 552 of file CPnumerics.h.
|
inline |
Definition at line 627 of file CPnumerics.h.
|
inline |
Definition at line 620 of file CPnumerics.h.
T2 LinearInterp | ( | const std::vector< T1 > & | x, |
const std::vector< T1 > & | y, | ||
std::size_t | i0, | ||
std::size_t | i1, | ||
T2 | val | ||
) |
Definition at line 497 of file CPnumerics.h.
T LinearInterp | ( | T | x0, |
T | x1, | ||
T | y0, | ||
T | y1, | ||
T | x | ||
) |
Definition at line 493 of file CPnumerics.h.
std::vector<T> linspace | ( | T | xmin, |
T | xmax, | ||
std::size_t | n | ||
) |
Make a linearly spaced vector of points.
Definition at line 183 of file CPnumerics.h.
std::vector<T> log10space | ( | T | xmin, |
T | xmax, | ||
std::size_t | n | ||
) |
Make a base-10 logarithmically spaced vector of points.
Definition at line 193 of file CPnumerics.h.
std::vector<T> logspace | ( | T | xmin, |
T | xmax, | ||
std::size_t | n | ||
) |
Make a base-e logarithmically spaced vector of points.
Definition at line 204 of file CPnumerics.h.
void MatInv_2 | ( | double | A[2][2], |
double | B[2][2] | ||
) |
Definition at line 70 of file CPnumerics.cpp.
|
inline |
Definition at line 578 of file CPnumerics.h.
|
inline |
Definition at line 586 of file CPnumerics.h.
T max_abs_value | ( | const std::vector< T > & | x | ) |
Definition at line 595 of file CPnumerics.h.
T maxvectordiff | ( | const std::vector< T > & | z1, |
const std::vector< T > & | z2 | ||
) |
Return the maximum difference between elements in two vectors where comparing z1[i] and z2[i].
Definition at line 170 of file CPnumerics.h.
|
inline |
Definition at line 574 of file CPnumerics.h.
|
inline |
Definition at line 582 of file CPnumerics.h.
T min_abs_value | ( | const std::vector< T > & | x | ) |
Definition at line 608 of file CPnumerics.h.
void normalize_vector | ( | std::vector< T > & | x | ) |
Definition at line 424 of file CPnumerics.h.
T1 nth_derivative_of_x_to_m | ( | T1 | x, |
T2 | n, | ||
T2 | m | ||
) |
see https://proofwiki.org/wiki/Nth_Derivative_of_Mth_Power and https://proofwiki.org/wiki/Definition:Falling_Factorial
Definition at line 462 of file CPnumerics.h.
T POW2 | ( | T | x | ) |
Definition at line 477 of file CPnumerics.h.
T POW3 | ( | T | x | ) |
Definition at line 481 of file CPnumerics.h.
T POW4 | ( | T | x | ) |
Definition at line 485 of file CPnumerics.h.
|
inline |
Definition at line 379 of file CPnumerics.h.
|
inline |
Definition at line 374 of file CPnumerics.h.
double powInt | ( | double | x, |
int | y | ||
) |
Definition at line 39 of file CPnumerics.cpp.
T2 QuadInterp | ( | const std::vector< T1 > & | x, |
const std::vector< T1 > & | y, | ||
std::size_t | i0, | ||
std::size_t | i1, | ||
std::size_t | i2, | ||
T2 | val | ||
) |
Definition at line 514 of file CPnumerics.h.
T QuadInterp | ( | T | x0, |
T | x1, | ||
T | x2, | ||
T | f0, | ||
T | f1, | ||
T | f2, | ||
T | x | ||
) |
Definition at line 502 of file CPnumerics.h.
double root_sum_square | ( | const std::vector< double > & | x | ) |
Definition at line 5 of file CPnumerics.cpp.
void solve_cubic | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
int & | N, | ||
double & | x0, | ||
double & | x1, | ||
double & | x2 | ||
) |
Solve a cubic with coefficients in decreasing order.
0 = ax^3 + b*x^2 + c*x + d
a | The x^3 coefficient |
b | The x^2 coefficient |
c | The x^1 coefficient |
d | The x^0 coefficient |
N | The number of unique real solutions found |
x0 | The first solution found |
x1 | The second solution found |
x2 | The third solution found |
Definition at line 81 of file CPnumerics.cpp.
void solve_quartic | ( | double | a, |
double | b, | ||
double | c, | ||
double | d, | ||
double | e, | ||
int & | N, | ||
double & | x0, | ||
double & | x1, | ||
double & | x2, | ||
double & | x3 | ||
) |
Definition at line 133 of file CPnumerics.cpp.
void sort3 | ( | T & | a, |
T & | b, | ||
T & | c | ||
) |
Sort three values in place; see http://codereview.stackexchange.com/a/64763.
Definition at line 637 of file CPnumerics.h.
|
inline |
Definition at line 24 of file CPnumerics.h.