1 /**
2  *  @file vcs_internal.h Internal declarations for the VCSnonideal package
3  */
4 
5 // This file is part of Cantera. See License.txt in the top-level directory or
6 // at https://cantera.org/license.txt for license and copyright information.
7 
8 #ifndef _VCS_INTERNAL_H
9 #define _VCS_INTERNAL_H
10 
11 #include "cantera/base/global.h"
12 namespace Cantera
13 {
14 //! define this Cantera function to replace printf
15 /*!
16  * We can replace this with printf easily
17  */
18 #define plogf writelogf
19 
20 //! Global hook for turning on and off time printing.
21 /*!
22  * Default is to allow printing. But, you can assign this to zero globally to
23  * turn off all time printing. This is helpful for test suite purposes where you
24  * are interested in differences in text files.
25  */
26 extern int vcs_timing_print_lvl;
27 
28 //! Class to keep track of time and iterations
29 /*!
30  * class keeps all of the counters together.
31  */
32 class VCS_COUNTERS
33 {
34 public:
35     //! Total number of iterations in the main loop
36     //! of vcs_TP() to solve for thermo equilibrium
37     int T_Its;
38 
39     //! Current number of iterations in the main loop
40     //! of vcs_TP() to solve for thermo equilibrium
41     int Its;
42 
43     //! Total number of optimizations of the components basis set done
44     int T_Basis_Opts;
45 
46     //! number of optimizations of the components basis set done
47     int Basis_Opts;
48 
49     //! Current number of times the initial thermo equilibrium estimator has
50     //! been called
51     int T_Calls_Inest;
52 
53     //! Current number of calls to vcs_TP
54     int T_Calls_vcs_TP;
55 
56     //! Current time spent in vcs_TP
57     double T_Time_vcs_TP;
58 
59     //! Current time spent in vcs_TP
60     double Time_vcs_TP;
61 
62     //! Total Time spent in basopt
63     double T_Time_basopt;
64 
65     //! Current Time spent in basopt
66     double Time_basopt;
67 
68     //! Time spent in initial estimator
69     double T_Time_inest;
70 
71     //! Time spent in the vcs suite of programs
72     double T_Time_vcs;
73 };
74 
75 //! Definition of the function pointer for the root finder
76 /*!
77  *  see vcsUtil_root1d for a definition of how to use this.
78  */
79 typedef double(*VCS_FUNC_PTR)(double xval, double Vtarget,
80                               int varID, void* fptrPassthrough,
81                               int* err);
82 
83 //! determine the l2 norm of a vector of doubles
84 /*!
85  * @param vec vector of doubles
86  * @returns   the l2 norm of the vector
87  */
88 double vcs_l2norm(const vector_fp& vec);
89 
90 //! Returns a const char string representing the type of the species given by
91 //! the first argument
92 /*!
93  * @param speciesStatus  Species status integer representing the type
94  *                       of the species.
95  * @param length         Maximum length of the string to be returned.
96  *                       Shorter values will yield abbreviated strings.
97  *                       Defaults to a value of 100.
98  */
99 const char* vcs_speciesType_string(int speciesStatus, int length = 100);
100 
101 //! Simple routine to check whether two doubles are equal up to roundoff error
102 /*!
103  * Currently it's set to check for 10 digits of relative accuracy.
104  *
105  * @param d1 first double
106  * @param d2 second double
107  *
108  * @returns true if the doubles are "equal" and false otherwise
109  */
110 bool vcs_doubleEqual(double d1, double d2);
111 }
112 
113 #endif
114