Tag Info

Hot answers tagged

21

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


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


16

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


14

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

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

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


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

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


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


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

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


6

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


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


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


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


4

Only NMinimize method can be used for constrained problems. {r,t}={8.31,0.002}; data={{1244,0.90237},{1289,0.83072},{1306,0.76147},{1360,0.6094},{1388,0.40952}, {1428,0.29419},{1488,0.15592},{1494,0.11718},{1527,0.09192},{1537,0.07757}, {1590,0.04546},{1594,0.04563},{1654,0.03229},{1737,0.01976},{1740,0.01949}}; ...


4

Import the data and filenames, cull the datasets of information that is not useful: data = Import /@ FileNames["*.csv"]; filenames = FileNames["*.csv"]; data = data[[All, 2 ;;, {1, 2}]]; ListLinePlot[data, PlotLegends -> filenames] Looks like PT data was either incorrectly collected or is effectively transparent in the region of interest. The ...


4

Perhaps: BarChart[stackData, ChartLabels -> {Placed[Style[#, FontSize->Scaled[.025]]&/@ newElementsSmall, Above]}, PlotLabel -> Style["6M1@32Ag", Bold, 50], ChartLegends -> {"eV"}]


4

ff = FindFit[normalized, {fitEquation2}, {y0, a, k}, t] Show[ListLinePlot@normalized, Plot[fitEquation2 /. ff, {t, 0, 20}, Evaluated -> True]]


4

Here is some preprocessing that might be useful. We will get rid of radicals "by hand", and eliminate variables using GroebnerBasis. The end result will be a single (complicated) expression in several variables. eqns = {x == (Etot - M - MI)/( Etot + 1/4 (Kd - Sqrt[Kd] Sqrt[8 Etot + Kd])), Etot == 2 Di + M + Inh M, Itot == Inh + MI, Kd == M^2/Di, ...


3

Take a look to the documentation page of Translate > NeatExamples. This example involves also Rotate. In order to use it on "MoleculePlot" you have to extract the graphics first part, graphics primitives, and the result wrapp with Graphics3D again: p1 = ProteinData["A2M", "MoleculePlot"]; p2 = ProteinData["SERPINA1", "MoleculePlot"]; Show[ p1, ...



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