Benutzer Diskussion:Debenben/mhchem

aus Wikipedia, der freien Enzyklopädie
Letzter Kommentar: vor 6 Jahren von Salix alba in Abschnitt Differences in output
Zur Navigation springen Zur Suche springen

Differences in output

[Quelltext bearbeiten]

I noticed quite a few difference in the output look at results for one article en:Pourbaix_diagram.

Your output

My output

Pourbaix diagram 	:<math> 	E_\mathrm{H} = E^0 - \frac{0.0592 \mathrm{V}}{n} \log\frac{[C]^c[D]^d}{[A]^a[B]^b} \ \{ V \} 
Pourbaix diagram 	:<math chem> 	\ce{pH} = - \log_{10}(a_\ce{H+}) = \log_{10}\left(\frac{1}{a_\ce{H+}}\right)
Pourbaix diagram 	:<math chem> 	\begin{cases}    a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{H+(aq)} + n\ce{e^-  <=> 0} & \text{acid balanced}\\    a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{OH^-(aq)} + n\ce{e^- <=> 0} & \text{base balanced}    \end{cases}\qquad(n > 0)
Pourbaix diagram 	<math> 	\Delta G^\circ
Pourbaix diagram 	:<math chem> 	a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{H+} + n\ce{e^-  <=> 0}
Pourbaix diagram 	<math> 	\Delta G^\circ = -RT \ln K
Pourbaix diagram 	<math chem> 	K=[r_1]^a[r_2]^b[\ce{H2O}]^c[\ce{H+}]^d
Pourbaix diagram 	:<math chem> 	\Delta G^\circ = -R T \ln( [r_1]^a [r_2]^b [\ce{H2O}]^c [\ce{H+}]^d  )
Pourbaix diagram 	:<math chem> 	\Delta G^\circ = -(R T \lambda) \, ( \log(  [r_1]^a [r_2]^b [\ce{H2O}]^c )  -d\,\ce{pH} )
Pourbaix diagram 	:<chem> 	2 Fe^3+ (aq) + 3 H2O (l) <=> Fe2O3 (s) + 6 H+ (aq)
Pourbaix diagram 	<math> 	\Delta G^\circ = -8242.5 \mathrm{J/mol}
Pourbaix diagram 	:<math chem> 	\ce{pH}=\frac{1}{6}\left( \frac{\Delta G^\circ}{R T \lambda} + \log\left( \frac\ce{[Fe2O3]}\ce{[Fe^{3+}]^2[H2O]^3}\right) \right) 
Pourbaix diagram 	:<math chem> 	a {r_1} + b {r_2} + c \ce{H2O(l)} + n\ce{e^- <=>0} \qquad (n>0)
Pourbaix diagram 	:<math chem> 	\Delta G = \Delta G^\circ - (R T) \ln [r_1]^a[r_2]^b[\ce{H2O}]^c 
Pourbaix diagram 	:<math chem> 	E_h = {E^\circ} + \frac{\Delta}{n} \ln ([r_1]^a[r_2]^b[\ce{H2O}]^c) 
Pourbaix diagram 	:<math chem> 	E_h = {E^\circ} + \frac{\Delta \lambda}{n} \log ([r_1]^a[r_2]^b[\ce{H2O}]^c )
Pourbaix diagram 	:<chem> 	Fe^3+ (aq) + e^- <=> Fe^2+ (aq)
Pourbaix diagram 	:<math chem> 	E_h = {E^\circ} + \Delta\lambda \log\left(\frac\ce{[Fe^{2+}]}\ce{[Fe^{3+}]}\right)
Pourbaix diagram 	<math> 	10^{-6}
Pourbaix diagram 	<math> 	E_h=E^\circ=0.771 \mathrm V
Pourbaix diagram 	:<math chem> 	a {r_1} + b {r_2} + c \ce{H2O(l)} + d \ce{H+(aq)} + n \ce{e^- <=> 0}
Pourbaix diagram 	:<math chem> 	E_h = {E^\circ} + \frac{\Delta\lambda}{n}(  \log( [r_1]^a [r_2]^b[\ce{H2O}]^c ) -d\, \ce{pH})
Pourbaix diagram 	:<chem> 	{Fe2O3(s)} + 6{H+(aq)}  + 2e^- <=> {2Fe^{2+}(aq)} + {3H2O(l)}
Pourbaix diagram 	<math> 	E^\circ =0.728 \mathrm V
Pourbaix diagram 	:<math chem> 	E_h ={E^\circ} - \frac{\Delta \lambda}{2}  \left ( \log\left ( \frac\ce{[Fe^{+2}]^2[H2O]^3}\ce{[Fe2O3]} \right ) + 6 \ce{pH}\right)
Pourbaix diagram 	:<chem> 	2 H2O + 2e^- -> H2(g) + 2 OH^- 
Pourbaix diagram 	:<chem> 	2 H3O+ + 2e^- -> H2(g) + 2H2O 
Pourbaix diagram 	:<math chem> 	E_\ce{H} = - 0.0591*\ce{pH} \ \{ V \} 
Pourbaix diagram 	:<chem> 	6 H2O -> 4 H3O+ + O2(g) + 4e^- 
Pourbaix diagram 	:<math chem> 	E_\ce{H} = 1.229 V - 0.0591*\ce{pH} \ \{ V \} 
Pourbaix diagram 	:<math> 	pE = \frac{E_{H}}{0.0591 V}

A line by line comparison gives

  1. Pourbaix diagram E_\mathrm{H} = E^0 - \frac{0.0592 \mathrm{V}}{n} \log\frac{[C]^c[D]^d}{[A]^a[B]^b} \ \{ V \}
  1. Pourbaix diagram \ce{pH} = - \log_{10}(a_\ce{H+}) = \log_{10}\left(\frac{1}{a_\ce{H+}}\right)
  1. Pourbaix diagram \begin{cases} a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{H+(aq)} + n\ce{e^- <=> 0} & \text{acid balanced}\\ a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{OH^-(aq)} + n\ce{e^- <=> 0} & \text{base balanced} \end{cases}\qquad(n > 0)
  2. Pourbaix diagram \Delta G^\circ
  3. Pourbaix diagram a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{H+} + n\ce{e^- <=> 0}
  4. Pourbaix diagram \Delta G^\circ = -RT \ln K
  5. Pourbaix diagram K=[r_1]^a[r_2]^b[\ce{H2O}]^c[\ce{H+}]^d
  1. Pourbaix diagram \Delta G^\circ = -R T \ln( [r_1]^a [r_2]^b [\ce{H2O}]^c [\ce{H+}]^d )
  1. Pourbaix diagram \Delta G^\circ = -(R T \lambda) \, ( \log( [r_1]^a [r_2]^b [\ce{H2O}]^c ) -d\,\ce{pH} )
  • w:en:Pourbaix diagram 71 \Delta G^\circ = -(R T \lambda) \, ( \log( [r_1]^a [r_2]^b [\ce{H2O}]^c ) -d\,\ce{pH} )
  1. Pourbaix diagram 2 Fe^3+ (aq) + 3 H2O (l) <=> Fe2O3 (s) + 6 H+ (aq)
  1. Pourbaix diagram \Delta G^\circ = -8242.5 \mathrm{J/mol}
  2. Pourbaix diagram \ce{pH}=\frac{1}{6}\left( \frac{\Delta G^\circ}{R T \lambda} + \log\left( \frac\ce{[Fe2O3]}\ce{[Fe^{3+}]^2[H2O]^3}\right) \right)
  • w:en:Pourbaix diagram 81 \ce{pH}=\frac{1}{6}\left( \frac{\Delta G^\circ}{R T \lambda} + \log\left( \frac\ce{[Fe2O3]}\ce{[Fe^{3+}]^2[H2O]^3}\right) \right)
  1. Pourbaix diagram a {r_1} + b {r_2} + c \ce{H2O(l)} + n\ce{e^- <=>0} \qquad (n>0)
  2. Pourbaix diagram \Delta G = \Delta G^\circ - (R T) \ln [r_1]^a[r_2]^b[\ce{H2O}]^c
  1. Pourbaix diagram E_h = {E^\circ} + \frac{\Delta}{n} \ln ([r_1]^a[r_2]^b[\ce{H2O}]^c)
  1. Pourbaix diagram E_h = {E^\circ} + \frac{\Delta \lambda}{n} \log ([r_1]^a[r_2]^b[\ce{H2O}]^c )
  1. Pourbaix diagram Fe^3+ (aq) + e^- <=> Fe^2+ (aq)
  1. Pourbaix diagram E_h = {E^\circ} + \Delta\lambda \log\left(\frac\ce{[Fe^{2+}]}\ce{[Fe^{3+}]}\right)
  • w:en:Pourbaix diagram 109 E_h = {E^\circ} + \Delta\lambda \log\left(\frac\ce{[Fe^{2+}]}\ce{[Fe^{3+}]}\right)
  1. Pourbaix diagram 10^{-6}
  2. Pourbaix diagram E_h=E^\circ=0.771 \mathrm V
  3. Pourbaix diagram a {r_1} + b {r_2} + c \ce{H2O(l)} + d \ce{H+(aq)} + n \ce{e^- <=> 0}
  4. Pourbaix diagram E_h = {E^\circ} + \frac{\Delta\lambda}{n}( \log( [r_1]^a [r_2]^b[\ce{H2O}]^c ) -d\, \ce{pH})
  • w:en:Pourbaix diagram 121 E_h = {E^\circ} + \frac{\Delta\lambda}{n}( \log( [r_1]^a [r_2]^b[\ce{H2O}]^c ) -d\, \ce{pH})
  1. Pourbaix diagram {Fe2O3(s)} + 6{H+(aq)} + 2e^- <=> {2Fe^{2+}(aq)} + {3H2O(l)}
  1. Pourbaix diagram E^\circ =0.728 \mathrm V
  2. Pourbaix diagram E_h ={E^\circ} - \frac{\Delta \lambda}{2} \left ( \log\left ( \frac\ce{[Fe^{+2}]^2[H2O]^3}\ce{[Fe2O3]} \right ) + 6 \ce{pH}\right)
  • w:en:Pourbaix diagram 129 E_h ={E^\circ} - \frac{\Delta \lambda}{2} \left ( \log\left ( \frac\ce{[Fe^{+2}]^2[H2O]^3}\ce{[Fe2O3]} \right ) + 6 \ce{pH}\right)
  1. Pourbaix diagram 2 H2O + 2e^- -> H2(g) + 2 OH^-
  1. Pourbaix diagram 2 H3O+ + 2e^- -> H2(g) + 2H2O
  1. Pourbaix diagram E_\ce{H} = - 0.0591*\ce{pH} \ \{ V \}
  1. Pourbaix diagram 6 H2O -> 4 H3O+ + O2(g) + 4e^-
  1. Pourbaix diagram E_\ce{H} = 1.229 V - 0.0591*\ce{pH} \ \{ V \}
  1. Pourbaix diagram pE = \frac{E_{H}}{0.0591 V}


It see there are problems with expressions spanning multiple lines. The \begin{cases} example

Also the expression 2 Fe^3+ (aq) + 3 H2O (l) <=> Fe2O3 (s) + 6 H+ (aq) is being translated to \ce{ Fe2O3 (s) + 6 H+ (aq)}.

Something odd happens with a r_1 + b r_2 + c \ce{H2O(l)} + d\ce{H+} + n\ce{e^- <=> 0} which is skipped.

--Salix alba (Diskussion) 09:20, 10. Jun. 2018 (CEST)Beantworten

@Salix alba: Thanks, the comparison very helpful, I think by trying to improve on the details, I made my script worse [1], maybe we should use yours. I am just worried that it is not as fast as awk.--Debenben (Diskussion) 22:16, 10. Jun. 2018 (CEST)Beantworten

Apparently the only problem with my script is, that it still cuts off at >. If I have a look at all equations in Porbaix diagram, I have

[[Pourbaix diagram]] 26 E_\mathrm{H} = E^0 - \frac{0.0592 \mathrm{V}}{n} \log\frac{[C]^c[D]^d}{[A]^a[B]^b} \ \{ V \} 
[[Pourbaix diagram]] 28 \ce{pH} = - \log_{10}(a_\ce{H+}) = \log_{10}\left(\frac{1}{a_\ce{H+}}\right)
[[Pourbaix diagram]] 53  0)
[[Pourbaix diagram]] 55 \Delta G^\circ
[[Pourbaix diagram]] 63  0}
[[Pourbaix diagram]] 65 \Delta G^\circ = -RT \ln K
[[Pourbaix diagram]] 65 K=[r_1]^a[r_2]^b[\ce{H2O}]^c[\ce{H+}]^d
[[Pourbaix diagram]] 67 \Delta G^\circ = -R T \ln( [r_1]^a [r_2]^b [\ce{H2O}]^c [\ce{H+}]^d  )
[[Pourbaix diagram]] 71 \Delta G^\circ = -(R T \lambda) \, ( \log(  [r_1]^a [r_2]^b [\ce{H2O}]^c )  -d\,\ce{pH} )
[[Pourbaix diagram]] 77 \ce{ Fe2O3 (s) + 6 H+ (aq)}
[[Pourbaix diagram]] 79 \Delta G^\circ = -8242.5 \mathrm{J/mol}
[[Pourbaix diagram]] 81 \ce{pH}=\frac{1}{6}\left( \frac{\Delta G^\circ}{R T \lambda} + \log\left( \frac\ce{[Fe2O3]}\ce{[Fe^{3+}]^2[H2O]^3}\right) \right) 
[[Pourbaix diagram]] 89 0)
[[Pourbaix diagram]] 93 \Delta G = \Delta G^\circ - (R T) \ln [r_1]^a[r_2]^b[\ce{H2O}]^c 
[[Pourbaix diagram]] 97 E_h = {E^\circ} + \frac{\Delta}{n} \ln ([r_1]^a[r_2]^b[\ce{H2O}]^c) 
[[Pourbaix diagram]] 101 E_h = {E^\circ} + \frac{\Delta \lambda}{n} \log ([r_1]^a[r_2]^b[\ce{H2O}]^c )
[[Pourbaix diagram]] 105 \ce{ Fe^2+ (aq)}
[[Pourbaix diagram]] 109 E_h = {E^\circ} + \Delta\lambda \log\left(\frac\ce{[Fe^{2+}]}\ce{[Fe^{3+}]}\right)
[[Pourbaix diagram]] 111 10^{-6}
[[Pourbaix diagram]] 111 E_h=E^\circ=0.771 \mathrm V
[[Pourbaix diagram]] 117  0}
[[Pourbaix diagram]] 121 E_h = {E^\circ} + \frac{\Delta\lambda}{n}(  \log( [r_1]^a [r_2]^b[\ce{H2O}]^c ) -d\, \ce{pH})
[[Pourbaix diagram]] 125 \ce{ {2Fe^{2+}(aq)} + {3H2O(l)}}
[[Pourbaix diagram]] 127 E^\circ =0.728 \mathrm V
[[Pourbaix diagram]] 129 E_h ={E^\circ} - \frac{\Delta \lambda}{2}  \left ( \log\left ( \frac\ce{[Fe^{+2}]^2[H2O]^3}\ce{[Fe2O3]} \right ) + 6 \ce{pH}\right)
[[Pourbaix diagram]] 141 \ce{ H2(g) + 2 OH^- }
[[Pourbaix diagram]] 145 \ce{ H2(g) + 2H2O }
[[Pourbaix diagram]] 149 E_\ce{H} = - 0.0591*\ce{pH} \ \{ V \} 
[[Pourbaix diagram]] 155 \ce{ 4 H3O+ + O2(g) + 4e^- }
[[Pourbaix diagram]] 159 E_\ce{H} = 1.229 V - 0.0591*\ce{pH} \ \{ V \} 
[[Pourbaix diagram]] 172 pE = \frac{E_{H}}{0.0591 V}

and the reason that equations like the \begin{cases} example are not there is, that \ce has been cut off, but I really don't know how that can still be the case.--Debenben (Diskussion) 00:20, 11. Jun. 2018 (CEST)Beantworten

@Mhchem, Salix alba:The problem was the sub(/.*?>/,"",itstring); #remove html arguments line, that removes the leftmost longest instead of the shortest matching pattern. I am running the extraction script again and then it should contain all mhchem in Wikimedia projects except Wikidata and math or chem tags that use capital letters, but I have only come across one instance of capital letter tags so far.--Debenben (Diskussion) 21:57, 11. Jun. 2018 (CEST)Beantworten
I've tweaked my script a bit and I'm now running on all name spaces and all wikis. Think it will take about a day to finish. Getting matching start and end tag when then span multiple lines was tricky. Hopefully out results will converge.
Spotted a few real awkward examples. en:Engelbart's Law has a long math opening tag which spans two lines. --Salix alba (Diskussion) 01:30, 12. Jun. 2018 (CEST)Beantworten