WOLFRAM

New in 13.1: Chemical Representations and Pattern Reactions

Last year we released Version 13.0 of the Wolfram Language. Here are the updates in chemical representations and symbolic pattern reactions since then, including the latest features in 13.1.

 

Representing Amounts of Chemicals

Molecule lets one symbolically represent a molecule. Quantity lets one symbolically represent a quantity with units. In Version 13.1 we now have the new construct ChemicalInstance that’s in effect a merger of these, allowing one to represent a certain quantity of a certain chemical.

This gives a symbolic representation of 1 liter of acetone (by default at standard temperature and pressure):

ChemicalInstance
&#10005


We can ask what the mass of this instance of this chemical is:

ChemicalInstance
&#10005


ChemicalConvert lets us do a conversion returning particular units:

ChemicalConvert
&#10005


Here’s instead a conversion to moles:

ChemicalConvert
&#10005


This directly gives the amount of substance that 1 liter of acetone corresponds to:

ChemicalInstance
&#10005


This generates a sequence of straight-chain hydrocarbons:

GraphicsBox
&#10005


Here’s the amount of substance corresponding to 1 g of each of these chemicals:

Table
&#10005


ChemicalInstance lets you specify not just the amount of a substance, but also its state, in particular temperature and pressure. Here we’re converting 1 kg of water at 4° C to be represented in terms of volume:

ChemicalConvert
&#10005


Chemistry as Rule Application: Symbolic Pattern Reactions

At the core of the Wolfram Language is the abstract idea of applying transformations to symbolic expressions. And at some level one can view chemistry and chemical reactions as a physical instantiation of this idea, where one’s not dealing with abstract symbolic constructs, but instead with actual molecules and atoms.

In Version 13.1 we’re introducing PatternReaction as a symbolic representation for classes of chemical reactions—in effect providing an analog for chemistry of Rule for general symbolic expressions.

Here’s an example of a “pattern reaction”:

PatternReaction
&#10005


The first argument specifies a pair of “reactant” molecule patterns to be transformed into “product” molecule patterns. The second argument specifies which atoms in which reactant molecules map to which atoms in which product molecules. If you mouse over the resulting pattern reaction, you’ll see corresponding atoms “light up”:

PatternReaction output
&#10005


Given a pattern reaction, we can use ApplyReaction to apply the reaction to concrete molecules:

ApplyReaction
&#10005


Here are plots of the resulting product molecules:

MoleculePlot
&#10005


The molecule patterns in the pattern reaction are matched against subparts of the concrete molecules, then the transformation is done, leaving the other parts of the molecules unchanged. In a sense it’s the direct analog of something like

{{a, b}, {c, d}} /. b -> {u, v}
&#10005


where the b in the symbolic expression is replaced, and the result is “knitted back” to fill in where the b used to be.

You can do what amounts to various kinds of “chemical functional programming” with ApplyReaction and PatternReaction. Here’s an example where we’re essentially building up a polymer by successive nesting of a reaction:

NestList
&#10005


 

MoleculePlot
&#10005


It’s often convenient to build pattern reactions symbolically using Wolfram Language “chemical primitives”. But PatternReaction also lets you specify reactions as SMARTS strings:

PatternReaction
&#10005


Comments

Join the discussion

!Please enter your comment (at least 5 characters).

!Please enter your name.

!Please enter a valid email address.