[2696] | 1 | /****************************************************************************** |
---|
| 2 | |
---|
| 3 | KPP - The Kinetic PreProcessor |
---|
| 4 | Builds simulation code for chemical kinetic systems |
---|
| 5 | |
---|
| 6 | Copyright (C) 1995-1996 Valeriu Damian and Adrian Sandu |
---|
| 7 | Copyright (C) 1997-2005 Adrian Sandu |
---|
| 8 | |
---|
| 9 | KPP is free software; you can redistribute it and/or modify it under the |
---|
| 10 | terms of the GNU General Public License as published by the Free Software |
---|
| 11 | Foundation (http://www.gnu.org/copyleft/gpl.html); either version 2 of the |
---|
| 12 | License, or (at your option) any later version. |
---|
| 13 | |
---|
| 14 | KPP is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 15 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
| 16 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
| 17 | details. |
---|
| 18 | |
---|
| 19 | You should have received a copy of the GNU General Public License along |
---|
| 20 | with this program; if not, consult http://www.gnu.org/copyleft/gpl.html or |
---|
| 21 | write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
| 22 | Boston, MA 02111-1307, USA. |
---|
| 23 | |
---|
| 24 | Adrian Sandu |
---|
| 25 | Computer Science Department |
---|
| 26 | Virginia Polytechnic Institute and State University |
---|
| 27 | Blacksburg, VA 24060 |
---|
| 28 | E-mail: sandu@cs.vt.edu |
---|
| 29 | |
---|
| 30 | ******************************************************************************/ |
---|
| 31 | |
---|
| 32 | #define KPP_VERSION "2.2.3" |
---|
| 33 | |
---|
| 34 | #ifndef _GDATA_H_ |
---|
| 35 | #define _GDATA_H_ |
---|
| 36 | |
---|
| 37 | #include <stdio.h> |
---|
| 38 | |
---|
| 39 | #define MAX_EQN 400 |
---|
| 40 | #define MAX_SPECIES 500 |
---|
| 41 | #define MAX_SPNAME 30 |
---|
| 42 | #define MAX_IVAL 40 |
---|
| 43 | /* MAX_EQNTAG = max length of equation ID in eqn file */ |
---|
| 44 | #define MAX_EQNTAG 12 |
---|
| 45 | /* MAX_K = max length of rate expression in eqn file */ |
---|
| 46 | #define MAX_K 150 |
---|
| 47 | #define MAX_ATOMS 10 |
---|
| 48 | #define MAX_ATNAME 10 |
---|
| 49 | #define MAX_ATNR 250 |
---|
| 50 | #define MAX_PATH 120 |
---|
| 51 | #define MAX_FILES 20 |
---|
| 52 | #define MAX_EQNLEN 100 |
---|
| 53 | |
---|
| 54 | #define NO_CODE -1 |
---|
| 55 | #define max( x, y ) (x) > (y) ? (x) : (y) |
---|
| 56 | #define min( x, y ) (x) < (y) ? (x) : (y) |
---|
| 57 | |
---|
| 58 | #define IncName(x) FileName((x),"MODELS","models","") |
---|
| 59 | #define ModelName(x) FileName((x),"MODELS","models",".def") |
---|
| 60 | #define IntegName(x) FileName((x),"INTEG","int",".def") |
---|
| 61 | |
---|
| 62 | enum krtypes { NUMBER, EXPRESION, PHOTO }; |
---|
| 63 | enum table_modes { F_TEXT, FC_TEXT, C_TEXT, S_TEXT }; |
---|
| 64 | enum lang { NO_LANG, C_LANG, F77_LANG, F90_LANG, MATLAB_LANG }; |
---|
| 65 | enum inl_code { F77_GLOBAL, F77_INIT, F77_DATA, F77_UTIL, F77_RATES, F77_RCONST, |
---|
| 66 | F90_GLOBAL, F90_INIT, F90_DATA, F90_UTIL, F90_RATES, F90_RCONST, |
---|
| 67 | C_GLOBAL, C_INIT, C_DATA, C_UTIL, C_RATES, C_RCONST, |
---|
| 68 | MATLAB_GLOBAL, MATLAB_INIT, MATLAB_DATA, MATLAB_UTIL, MATLAB_RATES, MATLAB_RCONST, |
---|
| 69 | INLINE_OPT |
---|
| 70 | }; |
---|
| 71 | |
---|
| 72 | enum jacobian_format { JAC_OFF, JAC_FULL, JAC_LU_ROW, JAC_ROW }; |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | typedef short int CODE; |
---|
| 76 | typedef float EQ_VECT[ MAX_EQN ]; |
---|
| 77 | |
---|
| 78 | typedef struct { |
---|
| 79 | char name[ MAX_ATNAME ]; |
---|
| 80 | char check; |
---|
| 81 | char masscheck; |
---|
| 82 | } ATOM_DEF; |
---|
| 83 | |
---|
| 84 | typedef struct { |
---|
| 85 | unsigned char code; |
---|
| 86 | unsigned char nr; |
---|
| 87 | } ATOM; |
---|
| 88 | |
---|
| 89 | typedef struct { |
---|
| 90 | char type; |
---|
| 91 | char lookat; |
---|
| 92 | char moni; |
---|
| 93 | char trans; |
---|
| 94 | short int nratoms; |
---|
| 95 | char name[ MAX_SPNAME ]; |
---|
| 96 | char ival[ MAX_IVAL ]; |
---|
| 97 | ATOM atoms[ MAX_ATOMS ]; |
---|
| 98 | } SPECIES_DEF; |
---|
| 99 | |
---|
| 100 | typedef struct { |
---|
| 101 | char type; |
---|
| 102 | union { |
---|
| 103 | char st[ MAX_K ]; |
---|
| 104 | float f; |
---|
| 105 | } val; |
---|
| 106 | char label[ MAX_EQNTAG ]; |
---|
| 107 | } KREACT; |
---|
| 108 | |
---|
| 109 | typedef struct { |
---|
| 110 | char * code; |
---|
| 111 | int maxlen; |
---|
| 112 | } ICODE; |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | extern int SpeciesNr; |
---|
| 116 | extern int EqnNr; |
---|
| 117 | extern int SpcNr; |
---|
| 118 | extern int AtomNr; |
---|
| 119 | extern int VarNr; |
---|
| 120 | extern int VarActiveNr; |
---|
| 121 | extern int FixNr; |
---|
| 122 | extern int VarStartNr; |
---|
| 123 | extern int FixStartNr; |
---|
| 124 | extern int Hess_NZ; |
---|
| 125 | extern int LU_Jac_NZ; |
---|
| 126 | extern int Jac_NZ; |
---|
| 127 | |
---|
| 128 | extern int generateSD; |
---|
| 129 | |
---|
| 130 | extern int initNr; |
---|
| 131 | extern int xNr; |
---|
| 132 | extern int yNr; |
---|
| 133 | extern int zNr; |
---|
| 134 | |
---|
| 135 | extern int falseSpcNr; |
---|
| 136 | |
---|
| 137 | extern int useAggregate; |
---|
| 138 | extern int useJacobian; |
---|
| 139 | extern int useJacSparse; |
---|
| 140 | extern int useHessian; |
---|
| 141 | extern int useStoicmat; |
---|
| 142 | extern int useDouble; |
---|
| 143 | extern int useReorder; |
---|
| 144 | extern int useMex; |
---|
| 145 | extern int useDummyindex; |
---|
| 146 | extern int useEqntags; |
---|
| 147 | extern int useLang; |
---|
| 148 | extern int useStochastic; |
---|
| 149 | |
---|
| 150 | /* if useValues=1 KPP replaces parameters like NVAR etc. |
---|
| 151 | by their values in vector/matrix declarations */ |
---|
| 152 | extern int useDeclareValues; |
---|
| 153 | |
---|
| 154 | extern char Home[ MAX_PATH ]; |
---|
| 155 | extern char integrator[ MAX_PATH ]; |
---|
| 156 | extern char driver[ MAX_PATH ]; |
---|
| 157 | extern char runArgs[ MAX_PATH ]; |
---|
| 158 | |
---|
| 159 | extern char *eqFileName; |
---|
| 160 | extern char *rootFileName; |
---|
| 161 | |
---|
| 162 | extern ATOM_DEF AtomTable[ MAX_ATNR ]; |
---|
| 163 | extern SPECIES_DEF SpeciesTable[ MAX_SPECIES ]; |
---|
| 164 | extern KREACT kr [ MAX_EQN ]; |
---|
| 165 | extern CODE ReverseCode[ MAX_SPECIES ]; |
---|
| 166 | extern CODE Code [ MAX_SPECIES ]; |
---|
| 167 | extern float** Stoich_Left; |
---|
| 168 | extern float** Stoich; |
---|
| 169 | extern float** Stoich_Right; |
---|
| 170 | extern int Reactive [ MAX_SPECIES ]; |
---|
| 171 | |
---|
| 172 | extern int **structB; |
---|
| 173 | extern int **structJ; |
---|
| 174 | extern int **LUstructJ; |
---|
| 175 | |
---|
| 176 | extern ICODE InlineCode[ INLINE_OPT ]; |
---|
| 177 | |
---|
| 178 | extern char *fileList[ MAX_FILES ]; |
---|
| 179 | extern int fileNr; |
---|
| 180 | |
---|
| 181 | extern char varDefault[ MAX_IVAL ]; |
---|
| 182 | extern char radDefault[ MAX_IVAL ]; |
---|
| 183 | extern char fixDefault[ MAX_IVAL ]; |
---|
| 184 | extern double cfactor; |
---|
| 185 | |
---|
| 186 | void CmdFunction( char *cmd ); |
---|
| 187 | void CmdJacobian( char *cmd ); |
---|
| 188 | void CmdHessian( char *cmd ); |
---|
| 189 | void CmdDeclareValues( char *cmd ); |
---|
| 190 | void CmdDouble( char *cmd ); |
---|
| 191 | void CmdReorder( char *cmd ); |
---|
| 192 | void CmdMex( char *cmd ); |
---|
| 193 | void CmdDummyindex( char *cmd ); |
---|
| 194 | void CmdEqntags( char *cmd ); |
---|
| 195 | void CmdUse( char *cmd ); |
---|
| 196 | void CmdLanguage( char *cmd ); |
---|
| 197 | void CmdIntegrator( char *cmd ); |
---|
| 198 | void CmdDriver( char *cmd ); |
---|
| 199 | void CmdRun( char *cmd ); |
---|
| 200 | void CmdStochastic( char *cmd ); |
---|
| 201 | |
---|
| 202 | void Generate(); |
---|
| 203 | |
---|
| 204 | char * FileName( char *name, char* env, char *dir, char *ext ); |
---|
| 205 | |
---|
| 206 | int* AllocIntegerVector( int n, char* message ); |
---|
| 207 | int** AllocIntegerMatrix( int m, int n, char* message ); |
---|
| 208 | void FreeIntegerMatrix ( int** mat, int m, int n ); |
---|
| 209 | int Index( int i ); |
---|
| 210 | |
---|
| 211 | #endif |
---|
| 212 | |
---|