({{, (RefLink[ValenceErrorHandling, paclet:ref/ValenceErrorHandling]) 
is an option for (RefLink[MoleculeModify, paclet:ref/MoleculeModify]) that specifies whether molecule valences should be automatically adjusted after modification.}})

OpenersNotesSection(Spacer1)Details

When (RefLink[ValenceErrorHandling, paclet:ref/ValenceErrorHandling]) is (RefLink[True, paclet:ref/True]), hydrogens will be added or subtracted in order to fix valence errors.

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Add a bond to a molecule, removing hydrogen atoms as necessary:

m=Molecule["hexane"]

MoleculeModify[m,{"AddBond",Bond[{1,6},"Single"]}]

Add the bond, turning off valence fixing:

MoleculeModify[m,{"AddBond",Bond[{1,6},"Single"]},ValenceErrorHandling->False]

MoleculePlot[%,PlotTheme->"AllAtom"]

Adding a positive charge to oxygen will remove its hydrogen by default:

m=Molecule["CC(=O)O"]

MoleculeModify[m,{"SetFormalCharge",4->-1}]

Turning off error handling will give a divalent oxygen anion:

MoleculeModify[m,{"SetFormalCharge",4->-1},ValenceErrorHandling->False]

Deleting a bond will by default add hydrogens to fill valences:

m=Molecule["cyclooctane"]

MoleculeModify[m,{"DeleteBond",{1,2}}]

With automatic valence handling disabled:

MoleculeModify[m,{"DeleteBond",{1,2}},ValenceErrorHandling->False]

The atoms participating in the deleted bond have their "UnpairedElectronCount" incremented:

MoleculeValue[%,{"UnpairedElectronCount",{1,2}}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[MoleculeModify, paclet:ref/MoleculeModify])  ▪  (RefLink[Molecule, paclet:ref/Molecule])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Molecular Structure & Computation, paclet:guide/MolecularStructureAndComputation])}})}})