Merge branch 'master' into devel
[wrffire.git] / wrfv2_fire / chem / KPP / kpp / kpp-2.1 / drv / general_stochastic.c
blob64f826b8a298d81198ec285edf358fd6a80e26bf
1 int InitSaveData();
2 int SaveData();
3 int CloseSaveData();
4 int GenerateMatlab( char * prefix );
5 void GetMass( double CL[], double Mass[] );
6 void INTEGRATE( double TIN, double TOUT );
7 void Gillespie(int Nssa, double Volume, double* T, int NmlcV[], int NmlcF[]);
8 void Update_RCONST();
10 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
11 int main()
12 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
14 /*~~~> Output results file */
15 FILE* fpDat;
16 /*~~~> No of molecules */
17 int NmlcV[NVAR], NmlcF[NFIX];
18 /*~~~> No of reaction events per output step */
19 int Nevents;
20 /*~~~> Local variables */
21 int i;
22 double T;
24 Initialize();
26 fpDat = fopen("KPP_ROOT_stochastic.dat", "w");
28 /* Translate initial values from conc. to molecules */
29 /* Volume = 100.0; */
30 Nevents = 20;
31 for( i = 0; i < NVAR; i++ )
32 NmlcV[i] = (int)(Volume*VAR[i]);
33 for( i = 0; i < NFIX; i++ )
34 NmlcF[i] = (int)(Volume*FIX[i]);
36 /*~~~> Begin Time Loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
37 T = TSTART;
38 while (T <= TEND) {
39 printf("\n%6.1f%% %10.4f ", (T-TSTART)/(TEND-TSTART)*100, T );
40 for( i = 0; i < NVAR; i++ )
41 printf( "%s=%d ", SPC_NAMES[i], NmlcV[i] );
43 fprintf(fpDat,"\n%g ", T );
44 for( i = 0; i < NVAR; i++ )
45 fprintf(fpDat,"%d ", NmlcV[i]);
47 Gillespie( Nevents, Volume, &T , NmlcV, NmlcF );
49 } /* while (T <= TEND) */
50 /*~~~> End Time Loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
52 fprintf(fpDat,"\n%g ", T );
53 for( i = 0; i < NVAR; i++ )
54 fprintf(fpDat,"%d ", NmlcV[i]);
55 fprintf(fpDat,"\n");
56 fclose(fpDat);
58 printf("\n");
60 return 0;
63 /*~~~> End of MAIN function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */