Pentru a putea vota, modifica pagini sau abona la modificările unei pagini trebuie să fiți autentificați. Cu această ocazie scăpați și de acest mesaj deranjant.

:Chemical formula

De la
Versiunea din 15 noiembrie 2007 02:25, autor: (Discuție) (Chemical formula)
(dif) ← Versiunea anterioară | Versiunea curentă (dif) | Versiunea următoare → (dif)
Salt la: navigare, căutare

A chemical formula describes an atom or a molecule such as Fe or FeCl3 or 3FeCl3. They are not to be confused with Type:Chemical equation which are a concatenation of chemical formulas.

Syntax of chemical formulas (in chemistry)

  • The formula is a concatenation of atom names. Each of these can have a subscript that defines the number of the atom's occurrences in the molecule.
  • A number at the beginning of the formula indicates the number of molecules/atoms/mols e.g. 3KCl.
  • Representation as ion e.g. Mg2+.
  • Representation as isotope e.g. 48Ti3+ is the ion of titanium-48. Isotopes can only be given for elements, not for molecules.
  • Molecules in a molecule can have an index e.g. Mg(NO3)2
  • The state of matter ((g)as, (l)iquid, (s)olid, (aq)ueous) can optionally be defined.

Chemical formulas in the wiki

There is a simple syntax for chemical formulas in the wiki.

  • Elements are the standardized abbreviations for elements where the first letter is always uppercase e.g. Fe.
  • Subscripts are simply appended to the element e.g. H2 (=> H2)
  • Isotopes of elements are defined like this:
    • 48^Ti (=>48Ti).
    • The element can have an index e.g. 48^Ti3 (=> 48Ti3).
    • Ions of isotopes are defined like this: 48^Ti^2+ (=> 48Ti2+).
    • This can also be combined with an index for the element.
    • Isotopes can not be defined for molecules
  • Elements can be combined to molecules by just concatenating them e.g. KCl.
  • Elements can have indices in a molecule e.g. H2O (=>H2O)
  • Molecules can be grouped within molecules e.g. Mg(NO3)2 (=> Mg(NO3)2) Nested brackets are allowed.
  • Molecules can be radicals e.g. .OOH (=> •OOH) or CH3. (=> CH3•)
  • Molecules can have double or triple connections e.g. CH2=CH2 (=> CH2=CH) or CH2=-CH2 (=> CH2≡CH2)
  • Ions can also be defined for molecules e.g SO4^3+ (=> SO43+)
  • The amount of elements, isotopes and molecules can be given by a number in front of them e.g. 2 H2O or 2H2O (=> 2 H2O)
  • Sometimes a variable is needed for the amount. In this case the number can be replaced by an n e.g. nH2O. There can also be factors for variable amounts e.g. 2nH2O.
  • The state of all matter can be appended e.g. NaCl(aq) (=> NaCl(aq)). These are the possible states:
    • (g) gas
    • (l) liquid
    • (s) solid
    • (aq) aqueous
Each of these four descriptions can be arbitrarily augmented e.g. (conc. aq, 98%). There must be no further brackets within the state's description.


  • Spaces are allowed between the number and the molecule.
  • Within a molecule there must be no spaces.
  • There must be no spaces in and around the exponent of isotopes and ions.

Type for chemical formula

The wiki offers the type Type:Chemical formula. Attributes with this type are checked for correctness with the rules above.

Grammar for chemical formulas as wiki text

(Elements in brackets [] are optional)

  • Chemical formula: CF := N ' ' M[SOM]
  • Number of molecules/atoms/mols: N := number ['n']
  • Molecule: M := ED | '('M')'number | MM | M MC M | M ION | ["."] M ["."]]
  • Molecule connection: MC := '=' | '=-'
  • Element descriptor: ED := [I]E[number] | [I]E[number][ION]
  • Isotope: I := number '^'
  • Ion: ION := '^'[number]{'+'|'-'}
  • Element: E := Symbol of all chemical elements
  • State of matter: SOM := '(' [SOMMOD NOTALPHANUM] 'g' [NOTALPHANUM SOMMOD] ')' |
  • State of matter modifier:
SOMMOD := any string but "(" and ")"
NOTALPHANUM := anything but letters nor digits

Testing chemical formulas

Below is a set of expressions in wiki text for chemical formulas. The attribute has formula must have the type Type:Chemical formula. Formulas that are rejected by the parser are rendered in a box. Error messages will be displayed in the fact box.

''''x' has the same meaning as '*''''

[[has equation:=2nH2O(l) -> 2Fe2O3xnH2O(s)]]

[[has equation:=2nH2O(l) -> 2Fe2O3*nH2O(s)]]

'''The former meaning of 'x' as variable is now written as 'n':'''

[[has formula:= nMg(aq)]]

[[has formula:= 2nMg(aq)]]

'''Arbitrary modifiers for states of matter:'''

* Correct
[[has formula:= H2O(,98%)]]
[[has formula:= H2O(conc aq 98%)]]
[[has formula:= H2O(aq,conc.)]]
[[has formula:= H2O(98% aq)]]
* Wrong
[[has formula:= H2O(concaq,98%)]]
[[has formula:= H2O(conc aq98%)]]
[[has formula:= H2O((conc) aq98%)]]
[[has formula:= H2O(solid)]]


* Correct

[[has formula:= CH2=CH2]]
[[has formula:= CH2=-CH2]]

* Wrong
[[has formula:= CH2==CH2]]
[[has formula:= CH2==-CH2]]
[[has formula:= CH2-=CH2]]


[[has equation:=C2H5. + O2 -> C2H4 + .OOH]]


* Correct

[[has formula:= Mg]]

[[has formula:= 2Mg]]

[[has formula:= 2 Mg]]

[[has formula:= Mg(aq)]]

[[has formula:= 2Mg(aq)]]

[[has formula:= nMg(aq)]]

[[has formula:= 2nMg(aq)]]

* Wrong

[[has formula:= Mi]]

[[has formula:= Mg (aq)]]

[[has formula:= 2(aq)]]


* Correct

[[has formula:= MgAg]]
[[has formula:= Mg2Ag3]]

* Wrong

[[has formula:= Mg Ag]]

'''Isotopes / Ions'''

* Correct

[[has formula:= 48^Ti]]

[[has formula:= 48^Ti3]]

[[has formula:= 48^Ti^2-]]

[[has formula:= 48^Ti3^2-]]

[[has formula:= 2 48^Ti^2-]]

* Wrong

[[has formula:= 48 ^ Ti]]

[[has formula:= 48^Ti3Ag4]]

[[has formula:= 48^Ti^2 -]]

[[has formula:= 48^Ti^ab]]

[[has formula:= Ti3-]]

[[has formula:= Ti3+]]

'''Molecule groups'''

* Correct

[[has formula:= Mg(NO3)2(l)]]

[[has formula:= Mg(((NO3)2)5)4(aq)]]

* Wrong

[[has formula:= Mg(((()NO3)2)5)4(aq)]]

[[has formula:= Mg(N)O3)2(l)]]

[[has formula:= Mg(NupQ3)2(l)]]

[[has formula:= Mg(N(O3)2(l)]]

'''Equation assigned to formula (wrong):'''

[[has formula := 4H + O2 -> 2H2O]]

'''Neither equation nor formula'''

[[has formula := 2Fe2O3*nH2O(s)]]