sol.dat: vode solver,

sol_check.dat: LSODA(odenit),

ddasac_results_1.out : DDASAC,

model.c: species order(result order) which is different from ours is included in this file.

Please make a dataframe, species as rows, solvers as columns, and %error comparing to ddasac’s result.


In [1]:
import pandas as pd
pd.set_option('display.max_rows', None)
import numpy as np

In [2]:
#for VODE and LSODA
species_list = ['time','T', 'ADIO', 'ADIOM2', 'ALD3', 'C10H2', 'C10H2M2', 'C10H2M4', 'C2H6', 'C3H4O', 'C3H4O2', 'C3H6', 'C3H6O2', 'C3H8O2', 
                'CH2CO', 'CH3CHO', 'CH3OH', 'CH4', 'CHAR', 'CO', 'CO2', 'COUMARYL', 'ETOH', 'H2', 'H2O', 'KET', 'KETD', 'KETDM2', 'KETM2', 
                'LIG', 'LIGC', 'LIGH', 'LIGM2', 'LIGO', 'MGUAI', 'OH', 'PADIO', 'PADIOM2', 'PC2H2', 'PCH2OH', 'PCH2P', 'PCH3', 'PCHO', 
                'PCHOHP', 'PCHP2', 'PCOH', 'PCOHP2', 'PCOS', 'PFET3', 'PFET3M2', 'PH2', 'PHENOL', 'PKETM2', 'PLIG', 'PLIGC', 'PLIGH', 
                'PLIGM2', 'PLIGO', 'PRADIO', 'PRADIOM2', 'PRFET3', 'PRFET3M2', 'PRKETM2', 'PRLIGH', 'PRLIGH2', 'PRLIGM2A', 'RADIO', 
                'RADIOM2', 'RC3H3O', 'RC3H5O2', 'RC3H7O2', 'RCH3', 'RCH3O', 'RKET', 'RKETM2', 'RLIGA', 'RLIGB', 'RLIGH', 'RLIGM2A', 
                'RLIGM2B', 'RMGUAI', 'RPHENOL', 'RPHENOX', 'RPHENOXM2', 'SYNAPYL', 'VADIO', 'VADIOM2', 'VCOUMARYL', 'VKET', 'VKETD', 
                'VKETDM2', 'VKETM2', 'VMGUAI', 'VPHENOL', 'VSYNAPYL']

In [3]:
vode_file = pd.read_csv('sol.dat',delim_whitespace = True, header = None)
vode_results = list(vode_file.iloc[-2])
LSODA_file = pd.read_csv('sol_check.dat',delim_whitespace = True, header = None)
LSODA_results = list(LSODA_file.iloc[175])

In [4]:
results = pd.DataFrame({'species':species_list,'VODE':vode_results,'LSODA':LSODA_results}).drop([0,1]).sort_values('species').reset_index(drop=True)

In [5]:
results.LSODA[abs(results.LSODA) < 1e-11] = 1e-11
results.VODE[abs(results.VODE) < 1e-11] = 1e-11


C:\Users\Jiayuan\Miniconda3\lib\site-packages\ipykernel\__main__.py:1: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  if __name__ == '__main__':
C:\Users\Jiayuan\Miniconda3\lib\site-packages\ipykernel\__main__.py:2: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
  from ipykernel import kernelapp as app

In [6]:
#for ddasac
species_ddasac = ['PLIGC', 'PLIGH', 'PLIGO', 'PRLIGH', 'LIGH', 'C3H6', 'OH', 'RLIGM2A', 'LIGM2',
      'RPHENOXM2', 'RADIOM2', 'PLIGM2', 'PRADIOM2', 'LIG', 'RPHENOX', 'RADIO', 'PLIG', 'PRADIO',
      'PADIOM2', 'PADIO', 'PKETM2', 'PRKETM2', 'KETDM2', 'CO', 'C10H2M4', 'H2', 'C10H2', 'RLIGH',
      'ALD3', 'PRLIGH2', 'PRLIGM2A', 'RMGUAI', 'C3H6O2', 'KETM2', 'RLIGM2B', 'PFET3M2',
      'PRFET3M2', 'C3H4O2', 'RPHENOL',' RLIGA', 'KET', 'RLIGB', 'PFET3', 'PRFET3', 'SYNAPYL',
      'RKETM2', 'COUMARYL', 'RKET', 'KETD', 'RC3H7O2', 'RCH3O', 'CH3CHO', 'C10H2M2', 'CH2CO',
      'CO2', 'ADIOM2', 'PH2', 'PCOH', 'RC3H5O2', 'RC3H3O', 'PCOS', 'ADIO', 'RCH3', 'PCH3', 'ETOH',
      'H2O', 'PCH2OH', 'PCHP2', 'PCHOHP', 'CHAR', 'PCOHP2', 'PC2H2', 'PCHO', 'CH3OH', 'C2H6',
      'PCH2P', 'VADIOM2', 'VKETM2', 'VKETDM2', 'VSYNAPYL', 'MGUAI', 'VMGUAI', 'VCOUMARYL',
      'VADIO', 'VKET', 'VKETD', 'PHENOL', 'VPHENOL', 'LIGC', 'LIGO', 'C3H8O2', 'CH4', 'C3H4O']

In [7]:
ddasac_file = pd.read_csv('ddasac_results_1.out',delim_whitespace = True, header = None)
ddasac_df = list(ddasac_file.iloc[37])[2:95]

In [8]:
ddasac = pd.DataFrame({'name':species_ddasac,'ddasac':ddasac_df}).sort_values('name').reset_index(drop=True)

In [9]:
# modify the order of species
ddasac_1 = ddasac.iloc[0]
ddasac_2 = ddasac.iloc[1:74]
ddasac_3 = ddasac.iloc[74:]
ddasac_resort = ddasac_2.append(ddasac_1).append(ddasac_3).reset_index(drop=True)
#abtol=1e-11
ddasac_resort['ddasac'] = ddasac_resort['ddasac'].astype(float)
ddasac_resort.ddasac[abs(ddasac_resort.ddasac) < 1e-11] = 1e-11


C:\Users\Jiayuan\Miniconda3\lib\site-packages\ipykernel\__main__.py:8: SettingWithCopyWarning: 
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy

In [10]:
%%javascript
IPython.OutputArea.prototype._should_scroll = function(lines) {
    return false;
}



In [11]:
results_comparison = pd.DataFrame()
results_comparison['species'] = results['species']
results_comparison['ddasac'] = ddasac_resort['ddasac']
#LSODA results and error%
results_comparison['LSODA'] = results['LSODA']
LSODA_error = (results_comparison['LSODA'].values - results_comparison['ddasac'].values.astype(np.float))/results_comparison['ddasac'].values.astype(float)
LSODA_errlist = []
for i in LSODA_error:
    percent = "{0:.2f}%".format(i * 100)
    LSODA_errlist.append(percent)
results_comparison['LSODA_error(%)'] = LSODA_errlist
#VODE results and error%
results_comparison['VODE'] = results['VODE']
VODE_error = (results_comparison['VODE'].values - results_comparison['ddasac'].values.astype(np.float))/results_comparison['ddasac'].values.astype(float)
VODE_errlist = []
for i in VODE_error:
    percent = "{0:.2f}%".format(i * 100)
    VODE_errlist.append(percent)
results_comparison['VODE_error(%)'] = VODE_errlist

#LSODA and VODE error compare%
compare_error = LSODA_error - VODE_error
compare_errlist = []
for i in compare_error:
    percent = "{0:.8f}%".format(i * 100)
    compare_errlist.append(percent)
results_comparison['LSODA-VODE(%)'] = compare_errlist

#results_comparison.to_csv('results_comparison.csv',index = False)

In [12]:
#Full comparison results 
results_comparison


Out[12]:
species ddasac LSODA LSODA_error(%) VODE VODE_error(%) LSODA-VODE(%)
0 ADIO 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
1 ADIOM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
2 ALD3 3.966974e-01 3.968274e-01 0.03% 3.968274e-01 0.03% -0.00000779%
3 C10H2 5.512506e-04 5.394858e-04 -2.13% 5.394859e-04 -2.13% -0.00001814%
4 C10H2M2 2.281646e-03 3.744611e-03 64.12% 3.744613e-03 64.12% -0.00005259%
5 C10H2M4 3.740217e-02 2.716637e-02 -27.37% 2.716638e-02 -27.37% -0.00001872%
6 C2H6 1.924486e-02 2.071977e-02 7.66% 2.071977e-02 7.66% -0.00000468%
7 C3H4O 5.354366e-04 1.226960e-03 129.15% 1.226959e-03 129.15% 0.00022412%
8 C3H4O2 1.651874e-01 1.784503e-01 8.03% 1.784504e-01 8.03% -0.00005394%
9 C3H6 5.248976e-02 5.235927e-02 -0.25% 5.235928e-02 -0.25% -0.00001581%
10 C3H6O2 2.007737e-02 1.779422e-02 -11.37% 1.779422e-02 -11.37% 0.00000747%
11 C3H8O2 2.273146e-04 2.096811e-03 822.43% 2.096812e-03 822.43% -0.00057189%
12 CH2CO 1.416971e+00 1.416971e+00 0.00% 1.416971e+00 0.00% 0.00001036%
13 CH3CHO 1.826846e-01 2.518667e-01 37.87% 2.518668e-01 37.87% -0.00007401%
14 CH3OH 6.018294e-01 7.687014e-01 27.73% 7.687013e-01 27.73% 0.00001364%
15 CH4 3.084947e-02 8.058968e-03 -73.88% 8.058975e-03 -73.88% -0.00002172%
16 CHAR 1.432492e+00 1.567157e+00 9.40% 1.567157e+00 9.40% 0.00000008%
17 CO 7.972507e-02 9.644097e-02 20.97% 9.644098e-02 20.97% -0.00001154%
18 CO2 4.482589e-01 4.644186e-01 3.60% 4.644188e-01 3.61% -0.00004810%
19 COUMARYL 1.566738e-02 6.795021e-03 -56.63% 6.795006e-03 -56.63% 0.00009383%
20 ETOH 5.331256e-02 5.083569e-02 -4.65% 5.083572e-02 -4.65% -0.00005290%
21 H2 3.104976e+00 3.025562e+00 -2.56% 3.025562e+00 -2.56% -0.00000262%
22 H2O 2.416953e+00 2.427879e+00 0.45% 2.427879e+00 0.45% -0.00000321%
23 KET 3.421181e-08 3.320000e-08 -2.96% 3.320000e-08 -2.96% 0.00000000%
24 KETD 7.809741e-01 5.964793e-01 -23.62% 5.964792e-01 -23.62% 0.00001383%
25 KETDM2 4.147822e-02 2.760751e-02 -33.44% 2.760752e-02 -33.44% -0.00002025%
26 KETM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
27 LIG 3.419535e-08 3.320000e-08 -2.91% 3.320000e-08 -2.91% 0.00000000%
28 LIGC 2.476434e-04 2.476434e-04 0.00% 2.476433e-04 -0.00% 0.00004038%
29 LIGH 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
30 LIGM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
31 LIGO 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
32 MGUAI 1.195542e-02 1.183102e-02 -1.04% 1.183102e-02 -1.04% -0.00002175%
33 OH 4.338898e-07 4.549000e-07 4.84% 4.549000e-07 4.84% 0.00000000%
34 PADIO 1.108562e-03 1.106231e-03 -0.21% 1.106231e-03 -0.21% -0.00000902%
35 PADIOM2 6.152954e-04 6.163178e-04 0.17% 6.163179e-04 0.17% -0.00001625%
36 PC2H2 6.307415e-01 9.099045e-01 44.26% 9.099044e-01 44.26% 0.00000541%
37 PCH2OH 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
38 PCH2P 1.963090e-01 2.085470e-01 6.23% 2.085470e-01 6.23% -0.00001920%
39 PCH3 3.916523e-08 1.070000e-08 -72.68% 1.070000e-08 -72.68% 0.00000000%
40 PCHO 4.658251e-07 3.960000e-07 -14.99% 3.960000e-07 -14.99% 0.00000000%
41 PCHOHP 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
42 PCHP2 1.536105e-01 1.534111e-01 -0.13% 1.534111e-01 -0.13% -0.00000436%
43 PCOH 1.531473e+00 1.859883e+00 21.44% 1.859883e+00 21.44% -0.00001072%
44 PCOHP2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
45 PCOS 2.450485e+00 2.580176e+00 5.29% 2.580176e+00 5.29% 0.00000443%
46 PFET3 1.710941e-08 1.660000e-08 -2.98% 1.660000e-08 -2.98% 0.00000000%
47 PFET3M2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
48 PH2 2.024939e+00 2.601500e+00 28.47% 2.601499e+00 28.47% 0.00000350%
49 PHENOL 3.303966e-02 4.534619e-02 37.25% 4.534620e-02 37.25% -0.00004964%
50 PKETM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
51 PLIG 4.220316e-09 4.200000e-09 -0.48% 4.200000e-09 -0.48% 0.00000000%
52 PLIGC 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
53 PLIGH 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
54 PLIGM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
55 PLIGO 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
56 PRADIO 4.406347e-03 4.486347e-03 1.82% 4.486347e-03 1.82% -0.00000227%
57 PRADIOM2 1.402997e-03 1.455611e-03 3.75% 1.455611e-03 3.75% -0.00000713%
58 PRFET3 1.678310e-08 1.680000e-08 0.10% 1.670000e-08 -0.50% 0.59583748%
59 PRFET3M2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
60 PRKETM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
61 PRLIGH 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
62 PRLIGH2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
63 PRLIGM2A 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
64 RADIO 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
65 RADIOM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
66 RC3H3O 5.682383e-06 1.389090e-05 144.46% 1.389090e-05 144.46% 0.00000000%
67 RC3H5O2 3.974174e-09 6.400000e-09 61.04% 6.400000e-09 61.04% 0.00000000%
68 RC3H7O2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
69 RCH3 4.249850e-06 2.020200e-06 -52.46% 2.020200e-06 -52.46% 0.00000000%
70 RCH3O 2.316644e-05 2.161850e-05 -6.68% 2.161850e-05 -6.68% 0.00000000%
71 RKET 1.123766e-08 1.120000e-08 -0.34% 1.120000e-08 -0.34% 0.00000000%
72 RKETM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
73 RLIGA 1.677205e-08 1.680000e-08 0.17% 1.680000e-08 0.17% 0.00000000%
74 RLIGB 8.349950e-07 8.365000e-07 0.18% 8.365000e-07 0.18% 0.00000000%
75 RLIGH 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
76 RLIGM2A 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
77 RLIGM2B 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
78 RMGUAI 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
79 RPHENOL 5.405155e-05 6.735870e-05 24.62% 6.735860e-05 24.62% 0.00018501%
80 RPHENOX 3.996541e-03 1.658763e-03 -58.50% 1.658764e-03 -58.50% -0.00001251%
81 RPHENOXM2 1.000000e-11 1.000000e-11 0.00% 1.000000e-11 0.00% 0.00000000%
82 SYNAPYL 3.202143e-02 1.748431e-02 -45.40% 1.748431e-02 -45.40% -0.00001280%
83 VADIO 5.695688e-06 1.047600e-06 -81.61% 1.047600e-06 -81.61% 0.00000000%
84 VADIOM2 5.195152e-04 5.043547e-04 -2.92% 5.043548e-04 -2.92% -0.00001925%
85 VCOUMARYL 4.466498e-04 2.186496e-04 -51.05% 2.186491e-04 -51.05% 0.00011194%
86 VKET 2.128118e-03 1.082146e-03 -49.15% 1.082143e-03 -49.15% 0.00012687%
87 VKETD 2.058864e-02 1.801577e-02 -12.50% 1.801577e-02 -12.50% 0.00001117%
88 VKETDM2 3.075704e-01 2.610817e-01 -15.11% 2.610818e-01 -15.11% -0.00002367%
89 VKETM2 3.846540e-05 3.595380e-05 -6.53% 3.595380e-05 -6.53% 0.00000000%
90 VMGUAI 7.419203e-03 7.342253e-03 -1.04% 7.342254e-03 -1.04% -0.00002157%
91 VPHENOL 7.316815e-02 9.997323e-02 36.63% 9.997328e-02 36.63% -0.00006724%
92 VSYNAPYL 6.603805e-02 4.562040e-02 -30.92% 4.562041e-02 -30.92% -0.00001484%

In [22]:
# Results of compositions whose comcentration is larger than 0.01 
print("Length is " + str(len(results_comparison[results_comparison.ddasac > 0.01])))
results_comparison[results_comparison.ddasac > 0.01]


Length is 32
Out[22]:
species ddasac LSODA LSODA_error(%) VODE VODE_error(%) LSODA-VODE(%)
2 ALD3 0.396697 0.396827 0.03% 0.396827 0.03% -0.00000779%
5 C10H2M4 0.037402 0.027166 -27.37% 0.027166 -27.37% -0.00001872%
6 C2H6 0.019245 0.020720 7.66% 0.020720 7.66% -0.00000468%
8 C3H4O2 0.165187 0.178450 8.03% 0.178450 8.03% -0.00005394%
9 C3H6 0.052490 0.052359 -0.25% 0.052359 -0.25% -0.00001581%
10 C3H6O2 0.020077 0.017794 -11.37% 0.017794 -11.37% 0.00000747%
12 CH2CO 1.416971 1.416971 0.00% 1.416971 0.00% 0.00001036%
13 CH3CHO 0.182685 0.251867 37.87% 0.251867 37.87% -0.00007401%
14 CH3OH 0.601829 0.768701 27.73% 0.768701 27.73% 0.00001364%
15 CH4 0.030849 0.008059 -73.88% 0.008059 -73.88% -0.00002172%
16 CHAR 1.432492 1.567157 9.40% 1.567157 9.40% 0.00000008%
17 CO 0.079725 0.096441 20.97% 0.096441 20.97% -0.00001154%
18 CO2 0.448259 0.464419 3.60% 0.464419 3.61% -0.00004810%
19 COUMARYL 0.015667 0.006795 -56.63% 0.006795 -56.63% 0.00009383%
20 ETOH 0.053313 0.050836 -4.65% 0.050836 -4.65% -0.00005290%
21 H2 3.104976 3.025562 -2.56% 3.025562 -2.56% -0.00000262%
22 H2O 2.416953 2.427879 0.45% 2.427879 0.45% -0.00000321%
24 KETD 0.780974 0.596479 -23.62% 0.596479 -23.62% 0.00001383%
25 KETDM2 0.041478 0.027608 -33.44% 0.027608 -33.44% -0.00002025%
32 MGUAI 0.011955 0.011831 -1.04% 0.011831 -1.04% -0.00002175%
36 PC2H2 0.630741 0.909904 44.26% 0.909904 44.26% 0.00000541%
38 PCH2P 0.196309 0.208547 6.23% 0.208547 6.23% -0.00001920%
42 PCHP2 0.153611 0.153411 -0.13% 0.153411 -0.13% -0.00000436%
43 PCOH 1.531473 1.859883 21.44% 1.859883 21.44% -0.00001072%
45 PCOS 2.450485 2.580176 5.29% 2.580176 5.29% 0.00000443%
48 PH2 2.024939 2.601500 28.47% 2.601499 28.47% 0.00000350%
49 PHENOL 0.033040 0.045346 37.25% 0.045346 37.25% -0.00004964%
82 SYNAPYL 0.032021 0.017484 -45.40% 0.017484 -45.40% -0.00001280%
87 VKETD 0.020589 0.018016 -12.50% 0.018016 -12.50% 0.00001117%
88 VKETDM2 0.307570 0.261082 -15.11% 0.261082 -15.11% -0.00002367%
91 VPHENOL 0.073168 0.099973 36.63% 0.099973 36.63% -0.00006724%
92 VSYNAPYL 0.066038 0.045620 -30.92% 0.045620 -30.92% -0.00001484%

In [23]:
#Results whose difference between LSODA and VODE is larger than 0.0001%
index_list = []
for index,per in enumerate(results_comparison['LSODA-VODE(%)']):
    if float(per.split('%')[0]) > 0.0001:
        index_list.append(index)

print("Length is " + str(len(results_comparison.loc[index_list])))
results_comparison.loc[index_list]


Length is 5
Out[23]:
species ddasac LSODA LSODA_error(%) VODE VODE_error(%) LSODA-VODE(%)
7 C3H4O 5.354366e-04 1.226960e-03 129.15% 1.226959e-03 129.15% 0.00022412%
58 PRFET3 1.678310e-08 1.680000e-08 0.10% 1.670000e-08 -0.50% 0.59583748%
79 RPHENOL 5.405155e-05 6.735870e-05 24.62% 6.735860e-05 24.62% 0.00018501%
85 VCOUMARYL 4.466498e-04 2.186496e-04 -51.05% 2.186491e-04 -51.05% 0.00011194%
86 VKET 2.128118e-03 1.082146e-03 -49.15% 1.082143e-03 -49.15% 0.00012687%

tol vs runtime profile

computational_effiency


In [ ]: