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(); |
---|
9 | |
---|
10 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
---|
11 | int main() |
---|
12 | /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
---|
13 | { |
---|
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; |
---|
23 | |
---|
24 | Initialize(); |
---|
25 | |
---|
26 | fpDat = fopen("KPP_ROOT_stochastic.dat", "w"); |
---|
27 | |
---|
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]); |
---|
35 | |
---|
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] ); |
---|
42 | |
---|
43 | fprintf(fpDat,"\n%g ", T ); |
---|
44 | for( i = 0; i < NVAR; i++ ) |
---|
45 | fprintf(fpDat,"%d ", NmlcV[i]); |
---|
46 | |
---|
47 | Gillespie( Nevents, Volume, &T , NmlcV, NmlcF ); |
---|
48 | |
---|
49 | } /* while (T <= TEND) */ |
---|
50 | /*~~~> End Time Loop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
---|
51 | |
---|
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); |
---|
57 | |
---|
58 | printf("\n"); |
---|
59 | |
---|
60 | return 0; |
---|
61 | |
---|
62 | } |
---|
63 | /*~~~> End of MAIN function ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ |
---|
64 | |
---|