Making an Atom
To make an atom we start out by simply making an association to hold the properties of the atom and wrapping the Head
Atom
around it:
SetChemicalSystemUpValues@Atom;
elementDict[el_]:=<|
"Position"->{0,0,0},
"Mass"->ElementData[el,"AtomicMass"],
"Radius"->ElementData[el,"VanDerWaalsRadius"],
"Bonds"->{},
"Valence"->ElementData[el,"Valence"],
"Color"->ColorData["Atoms"][el]
|>;
Atom[attrs:(_Rule|_RuleDelayed)..]:=ChemicalSystemAdd[
Atom@With[{ad=<|attrs|>},
Replace[ad["Element"],{
e_String:>Merge[{ad,elementDict[e]},First],
_->$Failed}]
]];
Atom[element_String,
position:{x_?NumericQ,y_?NumericQ,z_?NumericQ}:Automatic,
mass:_?NumericQ:Automatic
]:=Atom@@DeleteCases[{"Element"->element,"Position"->position,"Mass"->mass},_->Automatic]