1 | /* chimie: Chemistry fabric */ |
---|
2 | /* GCCM */ |
---|
3 | |
---|
4 | /* ko: low pressure limit: 3 body reaction (1st) */ |
---|
5 | /* ki: high pressure limit: 2 body reaction (2nd) */ |
---|
6 | |
---|
7 | #include "titan.h" |
---|
8 | |
---|
9 | void chimie_( char CORPS[][10], double *NB, double *TEMP, double KRATE[][NLEV], int REACTIF[][5], |
---|
10 | int *NOM_PERTE, int *NOM_PROD, int PERTE[][200][2], int PROD[][200] ) |
---|
11 | { |
---|
12 | int dep,i,j,k,l,lat; |
---|
13 | double ai,ao,ei,eo,ki,ko,m,ti,to; |
---|
14 | FILE *out; |
---|
15 | char corps[100][10]; |
---|
16 | static char reaction[NREAC+1][12][10]={ |
---|
17 | #include VERCHIM |
---|
18 | "", "", "", "", "", "","","","","","",""}; |
---|
19 | |
---|
20 | for( i = 0; i <= NC; i++) |
---|
21 | { |
---|
22 | strcpy( corps[i], CORPS[i] ); |
---|
23 | corps[i][strcspn(CORPS[i], " ")] = '\0'; |
---|
24 | } |
---|
25 | |
---|
26 | for( i = 0; i <= NC-1; i++ ) |
---|
27 | { |
---|
28 | NOM_PERTE[i] = NOM_PROD[i] = 0; |
---|
29 | for( j = 0; j < 200; j++ ) |
---|
30 | PERTE[i][j][0] = PERTE[i][j][1] = PROD[i][j] = 0; |
---|
31 | } |
---|
32 | dep = 0; |
---|
33 | for( i = dep; i <= NREAC-1; i++ ) /* Number of reactions */ |
---|
34 | { |
---|
35 | for( j = 0; j <= 4; j++ ) /* Number of compouds in each reactions */ |
---|
36 | { |
---|
37 | k = 0; |
---|
38 | if( (strcmp(reaction[i][j],"prod")) /* prod and soot are not */ |
---|
39 | && (strcmp(reaction[i][j],"soot")) /* considered in the compounds */ |
---|
40 | && (strcmp(reaction[i][j],"")) ) /* Which compound ? */ |
---|
41 | { |
---|
42 | while( strcmp(reaction[i][j],corps[k]) ) /* Compound in reaction j, column i */ |
---|
43 | { |
---|
44 | if( k == NC+1 ) |
---|
45 | { |
---|
46 | out = fopen( "err.log", "a" ); |
---|
47 | fprintf( out, "I cannot find %s\n", reaction[i][j] ); |
---|
48 | fclose( out ); |
---|
49 | exit(0); |
---|
50 | } |
---|
51 | k++; |
---|
52 | } |
---|
53 | REACTIF[i][j] = k; /* is number k */ |
---|
54 | } |
---|
55 | else REACTIF[i][j] = NC; |
---|
56 | } |
---|
57 | } |
---|
58 | for( i = dep; i <= NREAC-1; i++ ) /* Total loss and production */ |
---|
59 | { |
---|
60 | j = REACTIF[i][0]; /* First compound reaction i */ |
---|
61 | k = NOM_PERTE[j] + 1; /* Loss one more times */ |
---|
62 | if( k >= 200 ) exit(0); |
---|
63 | NOM_PERTE[j] = k; |
---|
64 | PERTE[j][k-1][0] = i; /* Compound j loss in reaction i for the kth time */ |
---|
65 | PERTE[j][k-1][1] = REACTIF[i][1]; /* Compound j reacts with number 2 in reaction i */ |
---|
66 | j = REACTIF[i][1]; /* Second compound reaction i */ |
---|
67 | if( j != NC ) /* Neither photodissociation nor desexcitation */ |
---|
68 | { |
---|
69 | k = NOM_PERTE[j] + 1; /* Loss one more times */ |
---|
70 | if( k >= 200 ) exit(0); |
---|
71 | NOM_PERTE[j] = k; |
---|
72 | PERTE[j][k-1][0] = i; /* Compound j is loss in reaction i for the kth times */ |
---|
73 | PERTE[j][k-1][1] = REACTIF[i][0]; /* Compound j reacts with number 1 reaction i */ |
---|
74 | } |
---|
75 | for( j = 2; j < 5; j++ ) /* Compounds from 3 to 5 */ |
---|
76 | { |
---|
77 | k = REACTIF[i][j]; /* Number of compound */ |
---|
78 | if( k != NC ) |
---|
79 | { |
---|
80 | l = NOM_PROD[k] + 1; /* One more time produced */ |
---|
81 | if( l >= 200 ) exit(0); |
---|
82 | NOM_PROD[k] = l; |
---|
83 | PROD[k][l-1] = i; /* at reaction i */ |
---|
84 | } |
---|
85 | } |
---|
86 | } |
---|
87 | for( i = RDISS+1; i <= NREAC-1; i++ ) /* 0 a RDISS-1: photodiss, RDISS: disso N2 */ |
---|
88 | { |
---|
89 | ao = strtod(reaction[i][5], NULL); |
---|
90 | to = strtod(reaction[i][6], NULL); |
---|
91 | eo = strtod(reaction[i][7], NULL); |
---|
92 | ai = strtod(reaction[i][8], NULL); |
---|
93 | ti = strtod(reaction[i][9], NULL); |
---|
94 | ei = strtod(reaction[i][10],NULL); |
---|
95 | m = strtod(reaction[i][11],NULL); |
---|
96 | for( j = 0; j <= NLEV-1; j++ ) |
---|
97 | { |
---|
98 | ko = ao * pow( TEMP[j], to) * exp( eo / TEMP[j] ); |
---|
99 | if( m == 1.0e0 ) |
---|
100 | KRATE[i][j] = ko; |
---|
101 | else if( m == 2.0e0 ) |
---|
102 | { |
---|
103 | KRATE[i][j] = ko * pow( NB[j], 2.0e0 ); |
---|
104 | } |
---|
105 | else if( m == 3.0e0 ) |
---|
106 | { |
---|
107 | if( ai == 0.0e0 ) |
---|
108 | KRATE[i][j] = ko * pow( NB[j], 3.0e0 ); |
---|
109 | else |
---|
110 | { |
---|
111 | ki = ai * pow( TEMP[j], ti ) * exp( ei / TEMP[j] ); |
---|
112 | KRATE[i][j] = pow( NB[j], 3.0e0 ) * ko * ki / ( ko * NB[j] + ki ); |
---|
113 | } |
---|
114 | } |
---|
115 | } |
---|
116 | } |
---|
117 | } |
---|