# Tag Info

29

In an presentation by Markus van Almsick, he gives an solution to visualize atomic orbitals using Image3D. Radius wave function (hydrogen): R[n_Integer?Positive, l_Integer?NonNegative, r_] := Block[{ρ = (2 r)/n}, Sqrt[(2/n)^3 (n - l - 1)!/(2 n (n + l)!)] E^(-ρ/2) ρ^l LaguerreL[n - l - 1, 2 l + 1, ρ]] /; l < n full wave function: ψ[n_, l_, m_, ...

26

Preload all chemical data: ChemicalData[All, "Preload"]; RebuildPacletData[]; (* the latter should not really be necessary *) Get all names: cd = ChemicalData[]; Get their molecular formulae: l = ChemicalData[#, "MolecularFormulaString"] & /@ cd; By counting the Cs, Os and Hs in the tattooed diagram we know we have to find ...

25

You can "preload" all the data to your computer so that it doesn't have to look it up each time. An added advantage is that it'll also be available when you're offline. This is covered in this support article on wolfram.com. In your case, you would do: ChemicalData[All,"Preload"] RebuildPacletData[] and you should be all set. Note that it will take a ...

23

My preferred method for this kind of thing is projecting each dimension onto a plane and then combining them together. I think MATLAB has similar functionality. Mind you, the answers and comments on my question about projecting are right in pointing out that this will become inefficient for high polygon counts (essentially more PlotPoints) so if you want to ...

18

Simple version using a variant of memoization While part of the answer I was going to give was already posted by Istvan, I will still post mine since the self-precomputing part was not part of Istvan's answer. The following will use the variant of memoization to precompute the dispatch table: ClearAll[elem]; elem[chem_, element_] := With[{dispatchTable = ...

18

I recently revisited this, and found that RegionPlot3D is by far the fastest way to plot orbitals, compared to Image3D and ContourPlot3D. I was surprised by the difference, so I thought it's worth posting this. In addition, I also made the process of choosing the plot parameters automatic, based on simple estimates for the size of the orbital wave ...

18

In the version 10.2, there is a builtin DensityPlot3D function, which can be used to visualize orbitals. a0=1; ψ[{n_, l_, m_}, {r_, θ_, ϕ_}] :=With[{ρ = 2 r/(n a0)}, Sqrt[(2/(n a0))^3 (n - l - 1)!/(2 n (n + l)!)] Exp[-ρ/2] ρ^ l LaguerreL[n - l - 1, 2 l + 1, ρ] SphericalHarmonicY[l, m, θ, ϕ]] DensityPlot3D[(Abs@ψ[{3, 2, 0}, {Sqrt[x^2 + y^2 + z^2], ...

17

myAtoms = {"H", "Li", "Na"}; defCols = myAtoms /. ColorData["Atoms", "ColorRules"]; newCols = {Pink, Yellow, LightBlue}; ColorData["Atoms", "Panel"] /. Thread[defCols -> newCols] Edit: Changing the font color isn't related to the ColorRules, but to the special formatting used by the Panel. So it's cumbersome, but you can see that Mma uses a similar ...

17

Use a dispatch table. It is an optimized element -> value lookup table that can be used to replace an element any time with its value. Now it does matching-and-finding every time, but if your list is not too big, this is pretty fast. dispatch = Dispatch[Thread[elements -> chemistry]]; ratio[elemA_, elemB_, disp_] := (elemA/elemB) /. disp; ratio[elemA_, ...

17

It is a nice application for the Graph[] features in Mma. We can calculate quickly all possible decays for all known isotopes, and then let VertexComponent[] look for the chains ending in {"Iridium191", "Iridium193"}. g = Graph@Union@Flatten[Thread[DirectedEdge @@ ##] & /@ Select[{#, IsotopeData[#, "DaughterNuclides"]} & /@ IsotopeData[], ...

17

I think that this question is too localized as it concerns the physics of a specific scientific instrument. Nonetheless, it is upvoted, so here I provide an answer for the benefit of the voters. I would still be happy to discuss this in the chat. The mathematics of the quadrupole mass filter is more complicated than you might think. Basically, your ...

17

Bob Hanlon's answer works very well, but in some ways it is the hard way of doing things. If you have v9 or v10, then it is arguably easier to use the legend constructs within it. Similar to his answer, we get the image and element names: img = Import["ExampleData/1PPT.pdb", "Rendering" -> "BallAndStick", ImageSize -> 500]; elements = ...

16

Maybe this will help a little (adapting documentation exaple for Slider2D): DynamicModule[{p = {2 π, 0}}, Row @ {Slider2D[Dynamic[p], {{2 Pi, 0}, {0, Pi}}], Plot3D[Exp[-(x^2 + y^2)], {x, -3, 3}, {y, -3, 3}, ImageSize -> {700, 700}, PlotRange -> All, ViewAngle -> .0015, ViewPoint -> Dynamic[1200 {Cos[p[[1]]] ...

14

A quick way of showing how the two structures can be positioned relative to each other in a single Graphics3D is as follows: With[{rMax = 500}, Manipulate[ Graphics3D[ {First@ChemicalData["Acetone", "MoleculePlot"], GeometricTransformation[ First@ChemicalData["Chloroform", "MoleculePlot"], Composition[ ...

13

I know you said you didn't want to reinvent the wheel, but sometimes, it's fun to do so. The code below creates a palette with a Periodic Table and a few buttons to make useful tool tips. It shows how one might change the colors based on properties grabbed from ElementData. Note that this code was written for version 9, and if you wish to use it in ...

13

One can use the (undocumented?) option ColorRules: Import["ExampleData/caffeine.xyz", ColorRules -> {"H" -> Red, "C" -> Black, "N" -> Darker@Green, "O" -> White}] Addendum: Other options may be found here: Options[GraphicsMoleculePlotDumpiMoleculePlot3D]. Note: The option ColorFunction seems to be unimplemented.

12

A convenient resource for the Miller Indices can be found here. This ref provides sufficient information for us to draw the (111) and (110) planes. First, reproduce the graphic from the demonstration. I just made the necessary changes to make it run outside of a Manipulate and did not try to optimize it. tet = PolyhedronData["Tetrahedron", "Faces"]; tetv ...

11

bas = Import["ExampleData/1PPT.pdb", "Rendering" -> "BallAndStick", ImageSize -> 500]; elements = Import["ExampleData/1PPT.pdb", "ResidueAtoms"] // Flatten // Union; legend = GraphicsColumn[{ {Graphics[{#[[1]], Disk[{0, 0}, 1]}, ImageSize -> 10], #[[2]]} & /@ Thread[{ ElementData[#, "IconColor"] & /@ elements, ...

11

I will show a simple and fast approach to computing the pair correlation function (radial distribution function) for a 2D system of point particles.: radialDistributionFunction2D[pts_?MatrixQ, boxLength_Real, nBins_: 350] := Module[{gr, r, binWidth = boxLength/(2 nBins), npts = Length@pts, rho}, rho = npts/boxLength^2; (* area number density *) {r, gr} ...

10

Try this: t = Import["c:\\work\\temp\\1.xyz"]; allColors = {}; (*get all colors from Graphics3D*) Scan[If[MatchQ[#, RGBColor[__]], AppendTo[allColors, #]] &, t, Infinity]; allColors = DeleteDuplicates[allColors] (*{RGBColor[0.65, 0.7, 0.7], RGBColor[0.4, 0.4, 0.4]}*) (*replace all obtained colors with any another*) replaceRules = MapThread[Rule, ...

10

The way to go about solving this problem is: In the Documentation Center, type "atomic mass" into the search field. The 2nd hit on the search results will ElementData. Click on it. The 1st example under Basic Examples is ElementData["Carbon", "AtomicWeight"] Quantity[12.0107, "AtomicMassUnit"] this gives the hint one needs to get started. It turns ...

9

To answer the question about accessing the function that does the plotting: the hints are here and in the SystemFiles/Formats/XYZ directory. In[20]:= stream = OpenRead["ExampleData/caffeine.xyz"] Out[20]= InputStream["ExampleData/caffeine.xyz", 194] In[22]:= data = SystemConvertXYZDump`ImportXYZ[stream] Out[22]= {"VertexTypes" -> {"H", "N", "C", ...

9

I think the only way to do this is by dynamically reseting the ViewMatrix to be an orthographic projection. It was beyond my ability, patience, or inclination to figure how to decompose the ViewMatrix that is created when the graphic is moved into the components ViewPoint, ViewVertical, etc. It seemed to me that the front end usually make a discontinuous ...

9

There is a space between every data pair which Mathematica apparently interprets as a multiplication. I assume these spaces should have been returns. The following code imports the file as a string, replaces the offensive space with a return and imports the result as JCAMP-DX. ImportString[ StringReplace[ ...

9

One can colorize bonds by finding 5-cycles in the bounding graph pts = QuantityMagnitude@ChemicalData["FullereneC60", "AtomPositions"]; graph = UndirectedGraph@Graph@ChemicalData["FullereneC60", "EdgeRules"]; ring5 = List @@@ Flatten@FindCycle[graph, {5}, 12]; remain = Complement[List @@@ EdgeList[graph], ring5, ring5[[All, {2, 1}]]]; ...

9

Well, I guess the only way is to build up a rule to do the conversion for you. I've done just that, so here it is: abb = {"A" -> "L-Alanine", "R" -> "L-Arginine", "N" -> "LAsparagine", "D" -> "LAsparticAcid", "C" -> "LCysteine", "E" -> "L-GlutamicAcid", "Q" -> "L-Glutamine", "G" -> "Glycine", "H" -> "L-Histidine", ...

8

Text should work. For example {g, n, p} = Import["ExampleData/caffeine.xyz", {{"Graphics3D", "VertexTypes", "VertexCoordinates"}}]; Show[g, Graphics3D[MapThread[Text, {n, p}]]]

8

Here is an example of how to work with chemicals the Mathematica way. First we retrieve the entity corresponding to the chemical: Then, if we don't know them by heart, we check out the available properties for chemicals: EntityProperties["Chemical"] This returns a long list of properties. There is one called "element counts" that seems interesting. We ...

7

Here is a less impressive take on the question. positionsA = ChemicalData["Acetone", "AtomPositions"] /. {x_, y_, z_} -> {x + 400, y + 400, z + 400}; positionsC = ChemicalData["Chloroform", "AtomPositions"]; {atomsA, atomsC} = {ChemicalData["Acetone", "VertexTypes"], ChemicalData["Chloroform", "VertexTypes"]}; {colorsA, colorsC} ...

7

With the new Association data structure introduced in the Wolfram Language/Mathematica 10 (you can try it now on the Raspberry Pi), this becomes extremely very simple to write and lookups are highly efficient as well. property = AssociationThread[elements -> chemistry] property["Ni"] (* 0.06 *)

Only top voted, non community-wiki answers of a minimum length are eligible