[3] | 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; |
---|
[2326] | 13 | double ai,ao,ar,ei,eo,er,ki,ko,kr,m,ti,to,tr,fc; |
---|
[3] | 14 | FILE *out; |
---|
[2326] | 15 | static char reaction[NREAC+1][16][10]={ |
---|
[3] | 16 | #include VERCHIM |
---|
[2326] | 17 | "", "", "", "", "", "","","","","","","","","","","",}; |
---|
[3] | 18 | |
---|
| 19 | for( i = 0; i <= NC-1; i++ ) |
---|
| 20 | { |
---|
| 21 | NOM_PERTE[i] = NOM_PROD[i] = 0; |
---|
| 22 | for( j = 0; j < 200; j++ ) |
---|
| 23 | PERTE[i][j][0] = PERTE[i][j][1] = PROD[i][j] = 0; |
---|
| 24 | } |
---|
| 25 | dep = 0; |
---|
| 26 | for( i = dep; i <= NREAC-1; i++ ) /* Number of reactions */ |
---|
| 27 | { |
---|
| 28 | for( j = 0; j <= 4; j++ ) /* Number of compouds in each reactions */ |
---|
| 29 | { |
---|
| 30 | k = 0; |
---|
| 31 | if( (strcmp(reaction[i][j],"prod")) /* prod and soot are not */ |
---|
| 32 | && (strcmp(reaction[i][j],"soot")) /* considered in the compounds */ |
---|
| 33 | && (strcmp(reaction[i][j],"")) ) /* Which compound ? */ |
---|
| 34 | { |
---|
[2099] | 35 | while( strcmp(reaction[i][j],CORPS[k]) ) /* Compound in reaction j, column i */ |
---|
[3] | 36 | { |
---|
| 37 | if( k == NC+1 ) |
---|
| 38 | { |
---|
| 39 | out = fopen( "err.log", "a" ); |
---|
[2326] | 40 | fprintf( out, "I cannot find %s, for %i and %i\n", reaction[i][j],i,j ); |
---|
[3] | 41 | fclose( out ); |
---|
| 42 | exit(0); |
---|
| 43 | } |
---|
| 44 | k++; |
---|
| 45 | } |
---|
| 46 | REACTIF[i][j] = k; /* is number k */ |
---|
| 47 | } |
---|
| 48 | else REACTIF[i][j] = NC; |
---|
| 49 | } |
---|
| 50 | } |
---|
| 51 | for( i = dep; i <= NREAC-1; i++ ) /* Total loss and production */ |
---|
| 52 | { |
---|
| 53 | j = REACTIF[i][0]; /* First compound reaction i */ |
---|
| 54 | k = NOM_PERTE[j] + 1; /* Loss one more times */ |
---|
| 55 | if( k >= 200 ) exit(0); |
---|
| 56 | NOM_PERTE[j] = k; |
---|
| 57 | PERTE[j][k-1][0] = i; /* Compound j loss in reaction i for the kth time */ |
---|
| 58 | PERTE[j][k-1][1] = REACTIF[i][1]; /* Compound j reacts with number 2 in reaction i */ |
---|
| 59 | j = REACTIF[i][1]; /* Second compound reaction i */ |
---|
| 60 | if( j != NC ) /* Neither photodissociation nor desexcitation */ |
---|
| 61 | { |
---|
| 62 | k = NOM_PERTE[j] + 1; /* Loss one more times */ |
---|
| 63 | if( k >= 200 ) exit(0); |
---|
| 64 | NOM_PERTE[j] = k; |
---|
| 65 | PERTE[j][k-1][0] = i; /* Compound j is loss in reaction i for the kth times */ |
---|
| 66 | PERTE[j][k-1][1] = REACTIF[i][0]; /* Compound j reacts with number 1 reaction i */ |
---|
| 67 | } |
---|
| 68 | for( j = 2; j < 5; j++ ) /* Compounds from 3 to 5 */ |
---|
| 69 | { |
---|
| 70 | k = REACTIF[i][j]; /* Number of compound */ |
---|
| 71 | if( k != NC ) |
---|
| 72 | { |
---|
| 73 | l = NOM_PROD[k] + 1; /* One more time produced */ |
---|
| 74 | if( l >= 200 ) exit(0); |
---|
| 75 | NOM_PROD[k] = l; |
---|
| 76 | PROD[k][l-1] = i; /* at reaction i */ |
---|
| 77 | } |
---|
| 78 | } |
---|
| 79 | } |
---|
| 80 | for( i = RDISS+1; i <= NREAC-1; i++ ) /* 0 a RDISS-1: photodiss, RDISS: disso N2 */ |
---|
| 81 | { |
---|
| 82 | ao = strtod(reaction[i][5], NULL); |
---|
| 83 | to = strtod(reaction[i][6], NULL); |
---|
| 84 | eo = strtod(reaction[i][7], NULL); |
---|
| 85 | ai = strtod(reaction[i][8], NULL); |
---|
| 86 | ti = strtod(reaction[i][9], NULL); |
---|
| 87 | ei = strtod(reaction[i][10],NULL); |
---|
| 88 | m = strtod(reaction[i][11],NULL); |
---|
[2326] | 89 | ar = strtod(reaction[i][12], NULL); |
---|
| 90 | tr = strtod(reaction[i][13], NULL); |
---|
| 91 | er = strtod(reaction[i][14], NULL); |
---|
| 92 | fc = strtod(reaction[i][15], NULL); |
---|
[3] | 93 | for( j = 0; j <= NLEV-1; j++ ) |
---|
| 94 | { |
---|
| 95 | ko = ao * pow( TEMP[j], to) * exp( eo / TEMP[j] ); |
---|
| 96 | if( m == 1.0e0 ) |
---|
| 97 | KRATE[i][j] = ko; |
---|
| 98 | else if( m == 2.0e0 ) |
---|
| 99 | { |
---|
| 100 | KRATE[i][j] = ko * pow( NB[j], 2.0e0 ); |
---|
| 101 | } |
---|
| 102 | else if( m == 3.0e0 ) |
---|
| 103 | { |
---|
| 104 | if( ai == 0.0e0 ) |
---|
| 105 | KRATE[i][j] = ko * pow( NB[j], 3.0e0 ); |
---|
| 106 | else |
---|
| 107 | { |
---|
| 108 | ki = ai * pow( TEMP[j], ti ) * exp( ei / TEMP[j] ); |
---|
| 109 | KRATE[i][j] = pow( NB[j], 3.0e0 ) * ko * ki / ( ko * NB[j] + ki ); |
---|
| 110 | } |
---|
| 111 | } |
---|
[2326] | 112 | else if( m == 4.0e0 ) /* Type 4 in Vuitton 2018 */ |
---|
| 113 | { |
---|
| 114 | ki = ai * pow( TEMP[j], ti ) * exp( ei / TEMP[j] ); |
---|
| 115 | kr = ar * pow( TEMP[j], tr ) * exp( er / TEMP[j] ); |
---|
| 116 | if ( kr > 0.99e0 * ko ) |
---|
| 117 | { |
---|
| 118 | KRATE[i][j] = ko; |
---|
| 119 | } |
---|
| 120 | else |
---|
| 121 | { |
---|
| 122 | KRATE[i][j] = fc * (ko-kr)*ki*NB[j] / ( ko - kr + ki*NB[j] ) + kr; |
---|
| 123 | } |
---|
| 124 | KRATE[i][j] = KRATE[i][j] * pow( NB[j], 2.0e0 ); |
---|
| 125 | } |
---|
| 126 | else if( m == 7.0e0 ) /* Tabulated values for H+C2H3 in Vuitton 2018 */ |
---|
| 127 | { |
---|
| 128 | // This is quick and dirty for now ( above 100 mbar asympotic at 2.44e-10 ) |
---|
| 129 | // It's constant in the strato and below -> condensation so threshold at 100K |
---|
| 130 | KRATE[i][0] = 6.46e-11; |
---|
| 131 | if ( TEMP[j] > 100.0 ) |
---|
| 132 | { |
---|
| 133 | KRATE[i][j] = 2.44e-10; |
---|
| 134 | } |
---|
| 135 | else |
---|
| 136 | { |
---|
| 137 | KRATE[i][j] = 1.0e-10; // To fix this is really dirty |
---|
| 138 | } |
---|
| 139 | } |
---|
[3] | 140 | } |
---|
| 141 | } |
---|
| 142 | } |
---|