diff options
Diffstat (limited to 'Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index b7a841c9ca2..0263485267c 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 3.57 Copyright (c) 2013-2015 Akira Yamaji +% mcf2graph ver 3.58 Copyright (c) 2013-2015 Akira Yamaji % % Permission is hereby granted, free of charge, to any person obtaining a copy of this software % and associated documentation files (the "Software"), to deal in the Software without restriction, @@ -39,12 +39,12 @@ numeric angB[],angA[],br_ang[],sB[],eB[],f_FON[],atom_w[],atom_h[],atom_d[],strA ps_env[],comMC[][],parMC[][],stock_p[],cntMC[],colorA[],colorB[],tblN[],tblB[][], wtA[],sumA[],CH[],NH[],NO[],SO[],CCl[],CF[],CBr[],?[],??[],![],!![],Ph[],ph[]; path pA,pB,pC,pT; -string info[],tblA[],com_str[],fomula_str,mp_log_name,mol_name; +string info[],tblA[],com_str[],calc_formula,mp_log_name,mol_name,mol_formula,calc_weight_str; picture atom_font[],chem_structure,temp_picture; %------------------------------------------------------------------------------------------------- sw_numberA:=sw_numberB:=sw_frame:=sw_logout:=sw_solid:=sw_expand:=sw_start_vector:=0; sw_atom_frame:=sw_checklist:=sw_MOLfile:=char_num:=str_cnt:=size_changed:=proc_end:=0; -sw_info_file:=sw_info_char:=1; sw_info_lenx:=sw_info_leny:=sw_info_mw:=sw_info_fm:=0; +sw_info_file:=sw_info_char:=1; sw_info_lenx:=sw_info_leny:=sw_info_weight:=sw_info_formula:=0; if known green: f_MP:=1; mp_log_name:=jobname&"-info.aux"; if ahlength=1: proc_end:=1; fi % first molecular only @@ -93,18 +93,22 @@ def store_par(text t)= nA:=0; for list=t: if st_p[incr nA]<>list: st_p[nA]:=list def restore_par(text t)= nA:=0; forsuffixes list=t: if list<>st_p[incr nA]: list:=st_p[nA]; fi endfor enddef; %------------------------------------------------------------------------------------------------- -def beginfont(text s)= mol_name:=""; len_x:=len_y:=cntA:=info_num:=0; +def beginfont(text s)= mol_name:=mol_formula:=""; len_x:=len_y:=cntA:=info_num:=mol_weight:=0; store_par(parameter_list); ratio_bond_width:=1mm#/font_wd#; for list=s: info_num:=info_num+1; info[info_num]:=list; - if substring (0,2) of list="EN": mol_name:=substring (3,length(list)) of list; fi endfor + if substring (0,2) of list="EN": mol_name:=substring (3,length(list)) of list; fi + if substring (0,2) of list="FM": mol_formula:=substring (3,length(list)) of list; fi + if substring (0,2) of list="MW": mol_weight:=scantokens(substring (3,length(list)) of list); fi + endfor beginchar(char_num,font_wd#,font_ht#,0); clearit; enddef; %------------------------------------------------------------------------------------------------- def endfont= if sw_frame=1: AUX(draw_frame(len_x,len_y,(min_x,min_y),0.2pt);) fi if sw_start_vector=1: AUX(start_vector) fi - if sw_checklist=1: mol_check; checklist_out; fi - if sw_MOLfile=1: mol_check; MOL_out; fi - if sw_logout=1: logfile_out; fi + if (sw_logout=1)or(sw_checklist=1)or(sw_MOLfile=1): mol_check; fi + if sw_logout=1: logfile_out; fi + if sw_checklist=1: checklist_out; fi + if sw_MOLfile=1: MOL_out; fi char_num:=char_num+1; currentpicture:=chem_structure; chem_structure:=nullpicture; restore_par(parameter_list); if size_changed=1: font_wd#:=stock_wd#; font_ht#:=stock_ht#; size_changed:=0; fi @@ -484,12 +488,12 @@ enddef; %------------------------------------------------------------------------------------------------- vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; def info_c(expr sw,c,cc)= if sw=1: &"{"&c&":"&cc&"}" fi enddef; -def info_n(expr sw,c,n)= if sw=1: &"{"&c&":"&decimal(n)&"}" fi enddef; +def info_n(expr sw,c,n)= if sw=1: &"{"&c&":"&decimal(n)&"}" fi enddef; def logfile_out= printf "\INFO{" info_c(sw_info_file,"F",jobname) info_n(sw_info_char,"C",char_num) info_n(sw_info_lenx,"Lx",len_x) info_n(sw_info_leny,"Ly",len_y) - info_n(sw_info_mw,"Mw",Mol_wt) info_c(sw_info_fm,"Fm",fomula_str) + info_n(sw_info_weight,"MWc",calc_weight) info_c(sw_info_formula,"FMc",calc_formula) for i=1 upto info_num: &"{"&info[i]&"}" endfor &"}%"; enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -647,10 +651,10 @@ def blank_str:= " " enddef; def fixed_r(expr n)(expr s)= (substring(0,n-length(s)) of blank_str)&s enddef; def fixed_l(expr n)(expr s)= s&(substring(0,n-length(s)) of blank_str) enddef; def fdr(expr n)(expr s)=fixed_r(n)(decimal(s)) enddef; -def warning(expr s)= message "%"&fdr(3)(incr warning_cnt)&")"&s&" !!!"; enddef; +def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s&" !!!"; enddef; def B_check(expr s)(expr t)(expr n)= if com_str[strA[s]]=t: if nA>n: - warning(fdr(4)(s)&" ["&com_str[strA[s]]&"] has "&fdr(3)(nA)&" bonds"); fi fi enddef; + warning(fdr(4)(s)&" ["&com_str[strA[s]]&"] has "&fdr(3)(nA)&" bonds"); fi fi enddef; vardef stripP(expr a)=if length(a)=4: substring (1,3) of a else: a fi enddef; def STa(expr a,b)= tblA[incr tbl_cnt]:=a; tblN[tbl_cnt]:=0; wtA[tbl_cnt]:=b; enddef; def STb(expr a)(text s)= tblA[incr tbl_cnt]:=a; tblN[tbl_cnt]:=0; @@ -671,7 +675,8 @@ STb("CHO")("C","H","O"); STb("N{O_2_}")("N","O","O"); STb("N{H_2_}")("N","H","H STb("S{O_3_}")("S","O","O","O"); STb("COOH")("C","O","O","H"); STb("C{H_3_}")("C","H","H","H"); STb("C{F_3_}")("C","F","F","F"); %------------------------------------------------------------------------------------------------- -def mol_check= hide_H:=warning_cnt:=0; for i=1 upto tbl_max: sumA[i]:=0; endfor +def mol_check= hide_H:=warning_cnt:=calc_weight:=calc_weightp:=0; calc_formula:=""; + for i=1 upto tbl_max: sumA[i]:=0; endfor for i=1 upto cntA: knownA:=nA:=0; for j=1 upto cntB: if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): nB:=2; elseif (lineB[j]=tm): nB:=3; elseif lineB[j]=nl: nB:=0; @@ -690,34 +695,41 @@ def mol_check= hide_H:=warning_cnt:=0; for i=1 upto tbl_max: sumA[i]:=0; endfor if knownA=0: warning(" Unknown Str("&com_str[strA[i]]&") is used "&decimal(i)); fi endfor sumA[2]:=sumA[2]+hide_H; + for i=1 upto tbl_max: + if sumA[i]>=1: + tmp_wtp:=(wtA[i]/100)*sumA[i]; + if (tmp_wtp<=40)and(calc_weightp<=40): calc_weight:=calc_weight+(wtA[i]*sumA[i]); + else: calc_weightp:=calc_weightp+tmp_wtp; fi + calc_formula:=calc_formula&stripP(tblA[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; + fi + endfor enddef; %------------------------------------------------------------------------------------------------- -def checklist_out= Mol_wt:=Mol_wtp:=nA:=0; fomula_str:=""; +def checklist_out= nA:=0; calc_weight_str:=""; + message "% Molecular name = "& mol_name; message "% There were "&fdr(3)(warning_cnt)&" warnings"; message "% width * height = " & fdr(8)(max_x-min_x)&" * "&fdr(8)(max_y-min_y); message "% Shift width * height = "& fdr(8)(min_x)&" * "&fdr(8)(min_y); message "% Bond length = "&fdr(3)(BL)&" Atom size = "&fdr(3)(AL); - message "% Atom count="&fdr(3)(cntA)&" Bond count="&fdr(3)(cntB)& - " Ring count = "&fdr(3)(cntB-cntA+1); + message "% Atom count="&fdr(3)(cntA)&" Bond count="&fdr(3)(cntB)&" Ring count="&fdr(3)(cntB-cntA+1); + message "% Hide H = "&fdr(3)(hide_H); message "%-----------------------------------< atom >< bond >-------"; for i=1 upto cntA: message "% "&fdr(3)(i)&" ("&fdr(10)(xpart(posA[i])/BL)&" ) ("& fdr(10)(ypart(posA[i])/BL)&" ) "&fixed_l(8)(com_str[strA[i]])&" "&fdr(3)(Bcnt[i]); endfor message "%Bond list---------------------------------------------------------"; for i=1 upto cntB: if lineB[i]<>0: message "% "&fdr(3)(incr nA)&" "&fdr(3)(sB[i])& " -> "&fdr(3)(eB[i])&" ("&fdr(3)(lineB[i]-si+1)&")"; fi endfor - message "%Fomula -----------------------------------------------------------"; + message "%Fomula / Molecular weight ---------------------------------------"; + if calc_weightp<=40: calc_weight_str:=fdr(10)(calc_weight); + else: calc_weight_str:=fdr(10)(calc_weightp)&" * 100"; fi for i=1 upto tbl_max: - if sumA[i]>=1: tmp_wtp:=(wtA[i]/100)*sumA[i]; - if (tmp_wtp<=40)and(Mol_wtp<=40): Mol_wt:=Mol_wt+(wtA[i]*sumA[i]); - else: Mol_wtp:=Mol_wtp+tmp_wtp; fi - fomula_str:=fomula_str&stripP(tblA[i])&decimal(sumA[i]); - message "% "&fixed_l(4)(stripP(tblA[i]))&"("&fdr(9)(wtA[i])&") * "&fdr(6)(sumA[i])&" = " - if tmp_wtp<=40: &fdr(12)(wtA[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi endfor - message "% Hide H = "&fdr(3)(hide_H); - message "% Molecular Weight: " - if Mol_wtp<=40: &fdr(10)(Mol_wt); else: &fdr(10)(Mol_wtp)&" * 100"; fi - message "% --------------------------------------"; - message "% Molecular Fomula: "&fomula_str; + if sumA[i]>=1: + message "% "&fixed_l(4)(stripP(tblA[i]))&"("&fdr(9)(wtA[i])&") * "&fdr(6)(sumA[i])&" = " + if tmp_wtp<=40: &fdr(12)(wtA[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi endfor + message "% Weight Calc: " &calc_weight_str &" / Input: " + if mol_weight>0: &decimal(mol_weight) &" / weight gap= " &decimal(calc_weight-mol_weight) fi; + message "% Fomula Calc: "&calc_formula&" / Input: " + if mol_formula<>"":&mol_formula&" / "& if mol_formula=calc_formula: "MACTCH" else: "NOT MACTCH" fi fi; message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; enddef; %------------------------------------------------------------------------------------------------ |