31
$\begingroup$

If I put some viscosity (or density, ...) lookups in my notebook, such as:

muMercury = ChemicalData["Mercury", "Viscosity"] ;
muWater = ChemicalData["Water", "Viscosity"] ;

Then these are fetched each time the notebook is loaded, which is kind of slow (a little window pops up showing "Initializing Chemical Data Indices" while it does this lookup). Is there a way to cache these, without doing a kludge like manually copying the numeric values obtained from an initial call?

I've got two reasons for asking. The first is just the slowness aspect, and the second is functional. I've got a Manipulate control that depends indirectly on these values, and when I start up the notebook for the very first time, it appears that my Manipulate executes before the preceding ChemicalData functions are evaluated. The "Initializing ChemicalData indices" doesn't occur until after an explicit evaluation.

$\endgroup$

1 Answer 1

28
$\begingroup$

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 while to download all the data from their servers.

$\endgroup$
5
  • 1
    $\begingroup$ Thanks, I was able to execute those commands (although I had to switch to a wired connection to do so), and verified that I was able to do an offline execution of the notebook. The values, however, are still not cached. I've got to hit shift-enter twice to get my Manipulate slider to pick up the values (the first time through produces errors because my viscosity values aren't yet loaded). $\endgroup$ Commented Mar 27, 2012 at 3:27
  • $\begingroup$ In one of the other answers to a question I previously asked, I found out how to deal with the sequencing issue: mathematica.stackexchange.com/questions/1669/… $\endgroup$ Commented Mar 27, 2012 at 3:39
  • 1
    $\begingroup$ @PeeterJoot Re: your edit, have you tried using an initialization cell? $\endgroup$
    – rm -rf
    Commented Mar 27, 2012 at 4:49
  • $\begingroup$ An initialization cell was exactly the construct required here. Thanks! $\endgroup$ Commented Mar 28, 2012 at 12:46
  • $\begingroup$ Hi, @R.M. In the article you referenced, the second step is CityData[All, "Install"], do we need this? I kind of don't understand what does install do? $\endgroup$
    – matheorem
    Commented Sep 2, 2016 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.