script below
# coding: utf-8
The import pprint
The import re
The import matplotlib. Pyplot as PLT
ZongBuShu=1000000
Filename='species. The out'
Wendu='PH 2200 k
Dump=400
Timestep_start=0
Timestep_end=ZongBuShu
# split each molecular species, save into a new dictionary
Def ChaiFenFenZiShi (FenZi) :
I=len (FenZi)
FenZi_list=[]
while i !=0:
Result=re. Match (' [CHON] [\ d] *, FenZi)
FenZi_list. Append (result. Group ())
Q=len (FenZi_list [len (FenZi_list) - 1))
FenZi=FenZi [Q:)
I=len (FenZi)
Return FenZi_list
Calculating the relative molecular mass #
Def JiSuanFenZiZhiLiang (FenZi) :
FenZi=ChaiFenFenZiShi (FenZi)
N=len (FenZi)
I=0
Fenzizhiliang=0
Yuanzizhiliang=0
While I & lt; N:
YuanZiZhongleiheshumu=FenZi [I]
Yuanzizhonglei=YuanZiZhongleiheshumu [0]
If yuanzizhonglei=='C' :
Yuanzizhiliang=12
Elif yuanzizhonglei=='H' :
Yuanzizhiliang=1
Elif yuanzizhonglei=='O:
Yuanzizhiliang=16
Elif yuanzizhonglei=='N' :
Yuanzizhiliang=14
Yuanzishu=YuanZiZhongleiheshumu. Strip (yuanzizhonglei)
If len (yuanzishu)==0:
Yuanzishu=1
The else:
Yuanzishu=int (yuanzishu)
Fenzizhiliang=fenzizhiliang + yuanzizhiliang * yuanzishu
I=I + 1
Return fenzizhiliang
# identify kinds of each species, heavy oil light oil or gas composition
Def PanDuanZhongLei (FenZi) :
FenZi=ChaiFenFenZiShi (FenZi)
N=len (FenZi)
I=0
Yuanzizhiliang=0
While I & lt; N:
YuanZiZhongleiheshumu=FenZi [I]
Yuanzizhonglei=YuanZiZhongleiheshumu [0]
If yuanzizhonglei=='C' :
Yuanzishu=YuanZiZhongleiheshumu. Strip (yuanzizhonglei)
If len (yuanzishu)==0:
Yuanzishu=1
The else:
Yuanzishu=int (yuanzishu)
If yuanzishu & lt;=4:
Return 'gas composition'
Break
Elif yuanzishu & gt; 4 and yuanzishu & lt;=13:
Return the 'light tar'
Elif yuanzishu & gt; 13 and yuanzishu & lt;=39:
Return 'heavy tar'
Elif yuanzishu & gt; 39:
Return 'carbocoal'
The else:
Pass
I=I + 1
Return 'gas composition'
# the input file into two dictionaries, bushu and ZiDian
Def TongJiShengChengWu (filename) :
The file=open (filename)
Content_partA=file. Readline ()
BANJIAO_ZHANBI_TOTAL=[]
ZHONGZHIJIAOYOU_ZHANBI_TOTAL=[]
QINGZHIJIAOYOU_ZHANBI_TOTAL=[]
QITI_ZHANBI_TOTAL=[]
While content_partA!=' ':
Content_partB=file. Readline ()
A_LIST=content_partA. The split ()
B_LIST=content_partB. The split ()
TIMESTEP within=B_LIST [0]
No_Moles=B_LIST [1]
No_Specs=B_LIST [2]
A_LIST=A_LIST/4:
B_LIST=B_LIST/3:
BANJIAO_ZUFEN=[]
BANJIAO_NUMBER=[]
ZHONGZHIJIAOYOU_ZUFEN=[]
ZHONGZHIJIAOYOU_NUMBER=[]
QINGZHIJIAOYOU_ZUFEN=[]
QINGZHIJIAOYOU_NUMBER=[]
QITI_ZUFEN=[]
QITI_NUMBER=[]
I=0
FENZI_ZONGZHILIANG=18-450 *
BANJIAO_ZONGZHILIANG=0
ZHONGZHIJIAOYOU_ZONGZHILIANG=0
QINGZHIJIAOYOU_ZONGZHILIANG=0
QITI_ZONGZHILIANG=0
While I & lt; Len (A_LIST) :
FENZI=A_LIST [I]
FENZI_NUMBER=B_LIST [I]
FENZI_ZHILIANG=JiSuanFenZiZhiLiang (FENZI)
FENZI_TYPE=PanDuanZhongLei (FENZI)
FENZI_ZONGZHILIANG=FENZI_ZONGZHILIANG + int (FENZI_ZHILIANG) * int (FENZI_NUMBER)
If FENZI_TYPE=='carbocoal:
BANJIAO_ZUFEN. Append (FENZI)
BANJIAO_NUMBER. Append (FENZI_NUMBER)
BANJIAO_ZONGZHILIANG=BANJIAO_ZONGZHILIANG + int (FENZI_ZHILIANG) * int (FENZI_NUMBER)
If FENZI_TYPE=='heavy tar:
ZHONGZHIJIAOYOU_ZUFEN. Append (FENZI)
ZHONGZHIJIAOYOU_NUMBER. Append (FENZI_NUMBER)
ZHONGZHIJIAOYOU_ZONGZHILIANG=ZHONGZHIJIAOYOU_ZONGZHILIANG + int (FENZI_ZHILIANG) * int (FENZI_NUMBER)
If FENZI_TYPE=='light tar:
QINGZHIJIAOYOU_ZUFEN. Append (FENZI)
QINGZHIJIAOYOU_NUMBER. Append (FENZI_NUMBER)
QINGZHIJIAOYOU_ZONGZHILIANG=QINGZHIJIAOYOU_ZONGZHILIANG + int (FENZI_ZHILIANG) * int (FENZI_NUMBER)
If FENZI_TYPE=='gas composition:
QITI_ZUFEN. Append (FENZI)
QITI_NUMBER. Append (FENZI_NUMBER)
QITI_ZONGZHILIANG=QITI_ZONGZHILIANG + int (FENZI_ZHILIANG) * int (FENZI_NUMBER)
I=I + 1
J1=0
While J1 & lt; Len (BANJIAO_ZUFEN) :
J1=J1 + 1
J2=0
While J2 & lt; Len (ZHONGZHIJIAOYOU_ZUFEN) :
J2=J2 + 1
J3=0
While J3 & lt; Len (QINGZHIJIAOYOU_ZUFEN) :
J3=J3 + 1
J4=0
While J4 & lt; Len (QITI_ZUFEN) :
J4=J4 + 1
BANJIAO_ZHANBI_TOTAL. Append (BANJIAO_ZONGZHILIANG/FENZI_ZONGZHILIANG * 100)
ZHONGZHIJIAOYOU_ZHANBI_TOTAL. Append (ZHONGZHIJIAOYOU_ZONGZHILIANG/FENZI_ZONGZHILIANG * 100)
QINGZHIJIAOYOU_ZHANBI_TOTAL. Append (QINGZHIJIAOYOU_ZONGZHILIANG/FENZI_ZONGZHILIANG * 100)
QITI_ZHANBI_TOTAL. Append ((FENZI_ZONGZHILIANG - QINGZHIJIAOYOU_ZONGZHILIANG - ZHONGZHIJIAOYOU_ZONGZHILIANG - BANJIAO_ZONGZHILIANG)/FENZI_ZONGZHILIANG * 100)
Content_partA=file. Readline ()
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull