Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 22 down vote accepted

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.

share|improve this answer
1  
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). –  Peeter Joot Mar 27 '12 at 3:27
    
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/… –  Peeter Joot Mar 27 '12 at 3:39
1  
@PeeterJoot Re: your edit, have you tried using an initialization cell? –  rm -rf Mar 27 '12 at 4:49
    
An initialization cell was exactly the construct required here. Thanks! –  Peeter Joot Mar 28 '12 at 12:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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