|
CoolProp 8.0.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 <array>#include "CoolProp/detail/PlatformDetermination.h"#include "CoolProp/detail/strings.h"#include "CoolProp/Exceptions.h"#include <iostream>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 | |
| template<typename T , size_t N> | |
| std::array< T, N > | create_filled_array (T value) |
| 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 (const 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 > | |
| bool | 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 43 of file numerics.h.
| #define M_PI 3.14159265358979323846 |
Definition at line 39 of file numerics.h.
| #define POW5 | ( | x | ) | ((x) * (x) * (x) * (x) * (x)) |
Definition at line 497 of file numerics.h.
| #define POW6 | ( | x | ) | ((x) * (x) * (x) * (x) * (x) * (x)) |
Definition at line 498 of file numerics.h.
| #define POW7 | ( | x | ) | ((x) * (x) * (x) * (x) * (x) * (x) * (x)) |
Definition at line 499 of file numerics.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 669 of file numerics.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.
| mat | 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 312 of file numerics.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 232 of file numerics.h.
|
inline |
Definition at line 428 of file numerics.h.
|
inline |
Some functions related to testing and comparison of values.
Definition at line 415 of file numerics.h.
| std::array< T, N > create_filled_array | ( | T | value | ) |
Definition at line 27 of file numerics.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 556 of file numerics.h.
| T CubicInterp | ( | T | x0, |
| T | x1, | ||
| T | x2, | ||
| T | x3, | ||
| T | f0, | ||
| T | f1, | ||
| T | f2, | ||
| T | f3, | ||
| T | x | ||
| ) |
Definition at line 528 of file numerics.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 543 of file numerics.h.
|
inline |
Definition at line 599 of file numerics.h.
| T factorial | ( | T | n | ) |
from http://stackoverflow.com/a/5721830/1360263
Definition at line 464 of file numerics.h.
|
inline |
A simple function for use in wrappers where macros cause problems.
Definition at line 674 of file numerics.h.
| double interp1d | ( | const std::vector< double > * | x, |
| const std::vector< double > * | y, | ||
| double | x0 | ||
| ) |
Definition at line 13 of file CPnumerics.cpp.
| bool is_in_closed_range | ( | T | x1, |
| T | x2, | ||
| T | x | ||
| ) |
Definition at line 561 of file numerics.h.
|
inline |
Definition at line 636 of file numerics.h.
|
inline |
Definition at line 629 of file numerics.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 506 of file numerics.h.
| T LinearInterp | ( | T | x0, |
| T | x1, | ||
| T | y0, | ||
| T | y1, | ||
| T | x | ||
| ) |
Definition at line 502 of file numerics.h.
| std::vector< T > linspace | ( | T | xmin, |
| T | xmax, | ||
| std::size_t | n | ||
| ) |
Make a linearly spaced vector of points.
Definition at line 192 of file numerics.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 202 of file numerics.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 213 of file numerics.h.
| void MatInv_2 | ( | double | A[2][2], |
| double | B[2][2] | ||
| ) |
Definition at line 71 of file CPnumerics.cpp.
|
inline |
Definition at line 587 of file numerics.h.
|
inline |
Definition at line 595 of file numerics.h.
| T max_abs_value | ( | const std::vector< T > & | x | ) |
Definition at line 604 of file numerics.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 179 of file numerics.h.
|
inline |
Definition at line 583 of file numerics.h.
|
inline |
Definition at line 591 of file numerics.h.
| T min_abs_value | ( | const std::vector< T > & | x | ) |
Definition at line 617 of file numerics.h.
| void normalize_vector | ( | std::vector< T > & | x | ) |
Definition at line 433 of file numerics.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 471 of file numerics.h.
| T POW2 | ( | const T & | x | ) |
Definition at line 486 of file numerics.h.
| T POW3 | ( | T | x | ) |
Definition at line 490 of file numerics.h.
| T POW4 | ( | T | x | ) |
Definition at line 494 of file numerics.h.
|
inline |
Definition at line 388 of file numerics.h.
|
inline |
Definition at line 383 of file numerics.h.
| double powInt | ( | double | x, |
| int | y | ||
| ) |
Definition at line 40 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 523 of file numerics.h.
| T QuadInterp | ( | T | x0, |
| T | x1, | ||
| T | x2, | ||
| T | f0, | ||
| T | f1, | ||
| T | f2, | ||
| T | x | ||
| ) |
Definition at line 511 of file numerics.h.
| double root_sum_square | ( | const std::vector< double > & | x | ) |
Definition at line 6 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 82 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 134 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 646 of file numerics.h.
|
inline |
Definition at line 33 of file numerics.h.