WOLFRAM NOTEBOOK

Chemical Entities

Out[]=
A central feature of the Wolfram Language is that it’s got real-world data built right in. It’s got data on elements, isotopes and even molecules. It gets all of this from the Wolfram Knowledgebase, which is being updated all the time and is what powers WolframAlpha.

Creation

So how can you talk about a molecule in the Wolfram Language? The easiest way is by pressing + = .
Enter in plain English such as “water”:
As soon as you press or click away, the Wolfram Language will try to interpret what you typed. Assuming it succeeds, it’ll display a little yellow box representing a Wolfram Language
Entity
. In this case, it’s the entity corresponding to water.
water
CHEMICAL
Press the check mark to confirm that’s what you want:
water
CHEMICAL

Values

Now you can ask for lots of properties for this entity such as the molecule plot, which is rotatable.
Ask for the molecule plot property of water:
water
CHEMICAL
["MoleculePlot"]
Out[]=
The result you get is something you can do computations with - such as image processing.
Color-negate the molecule plot of water:
ColorNegate
Out[]=
If all you want to do is visualize the molecule of water, you can just ask for it in English.
Out[]=
EntityValue
is a more flexible way to ask for the values of properties.
Use EntityValue to get the molecule plot of water:
EntityValue
water
CHEMICAL
,"MoleculePlot"
Out[]=
EntityValue
also works with lists of entities.
Get molecule plots for a list of molecules:
EntityValue
water
CHEMICAL
,
benzene
CHEMICAL
,
sucrose
CHEMICAL
,"MoleculePlot"
Out[]=
,
,
The Wolfram Language has deep knowledge about molecules, as about many other things.
Find out how many atoms there are in the list of molecules:
EntityValue
water
CHEMICAL
,
benzene
CHEMICAL
,
sucrose
CHEMICAL
,"AtomCount"
Out[]=
{
3
atoms
,
12
atoms
,
45
atoms
}
Make a pie chart of the results:
PieChartEntityValue
water
CHEMICAL
,
benzene
CHEMICAL
,
sucrose
CHEMICAL
,"AtomCount"
Out[]=
Find the elements contained in sucrose:
sucrose
CHEMICAL
["ElementTypes"]
Out[]=
carbon
,
hydrogen
,
oxygen
Find their known isotopes:
EntityValue
sucrose
CHEMICAL
["ElementTypes"],"KnownIsotopes"
Out[]=
carbon-8
,
carbon-9
,
carbon-10
,
carbon-11
,
carbon-12
,
carbon-13
,
carbon-14
,
carbon-15
,
carbon-16
,
carbon-17
,
carbon-18
,
carbon-19
,
carbon-20
,
carbon-21
,
carbon-22
,
hydrogen-1
,
deuterium
,
tritium
,
hydrogen-4
,
hydrogen-5
,
hydrogen-6
,
hydrogen-7
,
oxygen-12
,
oxygen-13
,
oxygen-14
,
oxygen-15
,
oxygen-16
,
oxygen-17
,
oxygen-18
,
oxygen-19
,
oxygen-20
,
oxygen-21
,
oxygen-22
,
oxygen-23
,
oxygen-24
,
oxygen-25
,
oxygen-26
,
oxygen-27
,
oxygen-28
Sometimes you’ll want to talk about a class of entities such as strong acids.
Ask for strong acids and get the class of entities corresponding to strong acids.
strong acids
CHEMICALS
You can get a list of all entities in a class using
EntityList
.
Get the list of strong acids:
Get the chemical formula for all of the strong acids:
Get the number of atoms in each of the strong acids and make a bar chart of them:
It’s very convenient to use plain English to describe things. A downside is that it can be ambiguous. If you say “mercury”, do you mean the planet Mercury or the element mercury or something else called “mercury”? When you use + =, it’ll make an initial choice. If you press the you can change to another choice. Press the check mark to accept a choice.
See the internal form of the entity representing uranium:
See the internal form of the entity representing water:

Properties

Possible properties for elements, isotopes and chemicals:
In practice, though, a good approach is to ask in plain English for a property of some entity, then to look at the interpretation that’s found, and re-use the property from it.
Ask for the atomic mass of tritium:
Re-use the “AtomicMass” property, applied to the aluminum:
Different types of entities have different properties. One common property for many types of entities is “Image”.
Get images of various entities:
Wolfram Cloud

You are using a browser not supported by the Wolfram Cloud

Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


I understand and wish to continue anyway »

You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.