Degrees of unsaturation (rings plus π bonds) of a molecular formula
mol_degrees_unsaturation
Counts the degrees of unsaturation (rings plus pi bonds) of a neutral molecular formula.
- Runs
- On the server
- Level
- Checked against a reference: exact arithmetic in a Python program; each structure counted in RDKit 2024.9.6; a second implementation in Python by a separate agent of the same model family
What it is
Returns the degrees of unsaturation (rings plus π bonds) of one neutral molecular formula, as 1 + ½ Σ n(v − 2). Use when a molecular formula is known and the number of rings plus double and triple bonds it allows is wanted, as before proposing structures. Refuses a charged formula, an adduct, an element without a fixed valence, and a half-integer count; sulfur may be stated as 2, 4 or 6 and phosphorus as 3 or 5. Not for a structure's descriptors: use `molecule_descriptors`; not for a formula weight: use `calc_formula_mass`.
What it does
You give
formula(required): One neutral, closed-shell molecular formula (e.g. C6H6, C2H6OS). A charge, an adduct (·) or a SMILES is refused. Leading and trailing white space is removed before the pattern is checked.sulfurValence: Valence of sulfur, if not 2: 2, 4 or 6 (4 for a sulfoxide, 6 for a sulfone or sulfate). 3 or 5 is invalid input (VALENCE_NOT_ALLOWED); a value outside 2 to 6 is invalid input (OUT_OF_RANGE). Must be at least 2 and at most 6. Optional.phosphorusValence: Valence of phosphorus, if not 3: 3 or 5 (5 for a phosphate or phosphine oxide). 4 is invalid input (VALENCE_NOT_ALLOWED); a value outside 3 to 5 is invalid input (OUT_OF_RANGE). Must be at least 3 and at most 5. Optional.
No request is recorded for this tool.
Limits
- Bench and process arithmetic on a reaction you write down.
- Research and education software: it does not predict products or routes, check that the chemistry will work, or assess hazards.
- Counts rings plus π bonds together from a neutral molecular formula alone, at the stated valences (H and the halogens one, O and S two, N, P and B three, C and Si four, unless a valence is stated for S or P); it cannot tell rings from π bonds, see the structure, charge separation or hypervalent halogens, and assumes one connected, closed-shell molecule.
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.
It will not answer when
- the formula carries a charge: which atom carries it decides the count, and a formula does not say; give the neutral parent formula.
- the formula is an adduct of more than one molecule (·, . or *).
- an element is outside the record's valence table (metals and every element other than H, the halogens, O, S, N, P, B, C and Si).
- the count is a half at these valences: an odd-electron species, or a wrong valence; it is never reported or rounded.
Every input, with its units3 inputs
formula(required): One neutral, closed-shell molecular formula (e.g. C6H6, C2H6OS). A charge, an adduct (·) or a SMILES is refused. Leading and trailing white space is removed before the pattern is checked.sulfurValence: Valence of sulfur, if not 2: 2, 4 or 6 (4 for a sulfoxide, 6 for a sulfone or sulfate). 3 or 5 is invalid input (VALENCE_NOT_ALLOWED); a value outside 2 to 6 is invalid input (OUT_OF_RANGE). Must be at least 2 and at most 6. Optional.phosphorusValence: Valence of phosphorus, if not 3: 3 or 5 (5 for a phosphate or phosphine oxide). 4 is invalid input (VALENCE_NOT_ALLOWED); a value outside 3 to 5 is invalid input (OUT_OF_RANGE). Must be at least 3 and at most 5. Optional.
Every refusal, with its code8 refusals
| Code | When |
|---|---|
FORMULA_CHARGED | the formula carries a charge: which atom carries it decides the count, and a formula does not say; give the neutral parent formula. |
FORMULA_ADDUCT | the formula is an adduct of more than one molecule (·, . or *). |
ELEMENT_NO_VALENCE | an element is outside the record's valence table (metals and every element other than H, the halogens, O, S, N, P, B, C and Si). |
DOU_NOT_INTEGER | the count is a half at these valences: an odd-electron species, or a wrong valence; it is never reported or rounded. |
FORMULA_IS_SMILES | a formula reads as a SMILES (= # @ / \ or a lower-case letter not after an upper-case one); for a structure, molecule_descriptors. |
FORMULA_INVALID | the formula cannot be read exactly as written: it is an electron; it writes a charge of zero; the formula-mass parser refuses it (an unknown symbol or one without a standard atomic weight, an ambiguous charge such as Fe3+, an unclosed bracket, a number before the formula such as 13CH4); it holds a count of zero; a count or the charge is above 2^53 − 1; or its molar-mass sum is too large to hold exactly (the shared routine formula-reading). |
VALENCE_NOT_ALLOWED | a valence is stated for an element other than S or P, at a value not offered (S 2, 4 or 6; P 3 or 5), or for an element not in the formula. |
DOU_NEGATIVE | the count is negative at these valences, so no connected neutral molecule has the formula. |
The calculation
The method's equations, constants and worked example.
D = 1 + ½ Σ_i n_i (v_i − 2)
| Symbol | Meaning |
|---|---|
D | rings plus π bonds |
n_i | count of element i in the formula |
v_i | valence of element i: H and the halogens 1; O and S 2; N, P and B 3; C and Si 4; or a stated valence for S (2, 4, 6) or P (3, 5) |
A definition, not a model: the equation states what the quantity means. A different convention gives a different number.
Worked example
Worked example: one case of mol-degrees-unsaturation@1.0.2, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- formula = C6H6
Steps
- carbon = 12, from formula; by the equation above.
- hydrogen = -6, from formula; by the equation above.
- D = 4, from carbon, hydrogen; by the equation above; gives ringsPlusPiBonds.
The working, as the case writes it:
D = 1 + ½ Σ n(v − 2) on C6H6: C 6 × (4 − 2) = 12
H 6 × (1 − 2) = −6
Σ = 6
D = 1 + ½ × 6 = 4
Answer
ringsPlusPiBonds = 4
Where these values came from: our own exact-arithmetic script and a hand-worked case; worked by hand by Drybench (ruling, §7).
At build the tool returned this answer within the tolerance the file states: counts exact; valences, formulas, flags, statuses and codes exact.
Sources
No source is recorded for this tool's methods.
How it is checked
- Level
Checked against a reference.
- Checked against
Our own exact-arithmetic script and a hand-worked case.
- Cases
No case set is linked to this version.
- Not checked
The IUPAC terms 'degree of unsaturation' and 'index of hydrogen deficiency' (the Gold Book, not read); electron-deficient boron (B2H6 gives −1 at these valences and is refused, DOU_NEGATIVE; three-centre bonds are not counted); a disconnected species written as one formula; hypervalent halogens. A formula starting with a digit (13C6H6) is refused FORMULA_INVALID since 1.0.2, through formula-mass 1.3.0, with no case in this method's fixtures; the refusal is covered by stored reference values and unit tests only.
Changes to its methods1 change
- 25 November 2026, mol-degrees-unsaturation@1.0.2: In 1.0.2, through formula-mass 1.3.0, a formula starting with a digit is now refused (FORMULA_INVALID); every other output is unchanged, and every pinned output hash is the same.