Tag Info

Hot answers tagged

25

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_, ...


24

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 ...


22

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 ...


21

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 = ...


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

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

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_, ...


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[ ...


12

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 ...


12

In the version 10.2, there is a builtin DensityPlot3D function, which can be used to visualize orbitals. a0=1; 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], ArcTan[z, Sqrt[x^2 + ...


11

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]]] ...


11

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 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 ...


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 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[Graphics`MoleculePlotDump`iMoleculePlot3D]. Note: The option ColorFunction seems to be unimplemented.


8

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 = System`Convert`XYZDump`ImportXYZ[stream] Out[22]= {"VertexTypes" -> {"H", "N", "C", ...


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

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 ...


7

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}]]]; ...


7

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, ...


6

The question has changed so much since the last time I read it that what I had worked out hardly seems relevant anymore -- esp. to someone who doesn't understand chemistry jargon. Many website data servers can provide their data in JSON or XML format. These formats are easily parsed. The WebBook site seems not to, but I couldn't even find a description of ...


6

I've tried to do some scrubbing of web pages with chemical information and even when I think that a website has some consistent structure I find that there are always special cases or the web site provider chooses that particular time to revamp the website! Nonetheless, here's a way to get at some of your information. casno = "19431-79-9" ...


6

It seems to me that there are two natural approaches: (1) modifying color rules before the panel is created or (2) post-processing the output to replace recognizable colors. belisarius already showed a method for the second so I shall address the first. This method is more robust than the post-processing one. See the final example below. Modifying the ...


6

This example picks the colors according to atomic weight, which are loaded from ElementData[]. Like belisarius's answer, it generates a list of rules to replace colors which is then applied to the pane. Rule @@@ Transpose[{ColorData["Atoms", "ColorList"] , ColorData["NeonColors"][QuantityMagnitude@ElementData[#,"AtomicMass"]/200] & /@ ...


6

You can also use ReadList which is usually much faster than Import for large files: readJCAMP[filename_String] := Module[{data, file = OpenRead[filename]}, ReadList[file, String, 25]; data = ReadList[file, {Record, Record}, RecordSeparators -> {" ", ",", "\n"}]; Close[file]; ToExpression[ data[[1 ;; -2]] ] ] Usage: ...


6

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