Tag Info

Hot answers tagged

22

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


18

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


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

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


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


15

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


12

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


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

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


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

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


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

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


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

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 *)


6

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


5

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


5

You might use Assumptions in one form or another. Block[{$Assumptions = Liters > 0 && Mols > 0 && Kelvins > 0}, Simplify[Wideal[5 Liters, 10 Liters, 1 Mols, 298 Kelvins]] ] (* -> 298 Kelvins Mols R Log[2] *) One disappointment for me is that the following doesn't work: Block[{$Assumptions = Liters > 0 && Mols ...


5

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


5

I found the problem. Mathematica interprets the input string as a list of all available molecules that contain the input string as a substring. ChemicalData["Alanine"] {"DAlanine", "DLAlanine", "LAlanine"}


5

Let's first pre-process the data you need for the output file to be used in your quantum simulation software: pos = ChemicalData["Fructose", "AtomPositions"][[1]]/100.; atype = ChemicalData["Fructose", "VertexTypes"][[1]]; data = Transpose[{atype, pos}]; Here's a function to give you the output file the way you specified in your question: ...


5

I am not familiar with the specific output format you need but I think I can show you how to proceed. dat = Import["ExampleData/caffeine.xyz", {{"VertexTypes", "VertexCoordinates"}}]; dat2 = {#[[1, 1]], #[[All, 2]]} & /@ GatherBy[dat\[Transpose], First]; dat3 = {#, Length@#2, #2} & @@@ dat2; dat3 has this format: dat3 // TableForm $\left( ...


5

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


4

You can use indexed variables with a shortcut function to define a long list of indices and values, like so: indexedVariable[var_, indicesValues__] := With[{dict = List[indicesValues]}, Scan[(var[#[[1]]] = #[[2]]) &, dict]]; indexedVariable[chemistry, {"C", 0.032`}, {"Mn", 1.2`}, {"S", 0.0259`}]; chemistry["C"]; This will let the engine handle ...


4

By using ViewVector you are rotating the point-of-view about the object, not the object itself. While these are similar, it might be easier to understand what's happening by rotating the object. This can be done: rotAbout={0, 0, 1}; Manipulate[rot = RotationMatrix[a, rotAbout]; Graphics3D[{Specularity[GrayLevel[1], 100], ...



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