Thursday, June 11, 2009

It takes a village to solve a Jmol puzzle


(Click-drag on the image to rotate the molecule!)

The past few days I have been trying to put Jmol animation into the blog. I knew this was possible because of the pioneering efforts of Felix over at Chemical Quantum Images.

His post on vibrations in p-cresole has been a long-time inspiration. I found the entry through google because I was interested in animating vibrations with Jmol, and it taught me a lot about that.

But more importantly, it was the first blog I came across where someone talked about the details of their computations and showed images resulting from the computations simply because they were beautiful. So Chemical Quantum Images was a major inspiration for this blog. Thanks, Felix!

And now, through the comments to that post, and some very helpful suggestions by Noel over at Noel O'Blog (thanks, Noel!), I now also know how to embed Jmol within this blog. Noel pointed me to another way of doing it, via a Microjmol Widget application written by Jeffrey Moore and that provided me with the penultimate piece of the puzzle.

Anyway, just in case anyone else is interested in doing this: the text I put into this blog window to generate the Jmol window can be found below. Note that this will not show up in Preview, only when you post (and that was the final piece of he puzzle).

<script src="http://propka.ki.ku.dk/~jhjensen/Jmol.js" type="text/javascript"></script> <script type="text/javascript"> jmolInitialize("http://propka.ki.ku.dk/~jhjensen"); jmolApplet(300, "load http://propka.ki.ku.dk/~jhjensen/cyclohexane_movie.xyz;");jmolBr();jmolButton("spin y" ,"spin y");jmolButton("spin off" ,"spin off");<br /></script>

6 comments:

Felix said...

alright, I see you made it!

actually what I wanted to say is that I would use jmol in blogspot with caution. the problem is that if you have two posts with jmol applets then the browser has problems handling that. that is because you have the jmolInitialize command twice on the same page. i tried some things to avoid that like putting the jmolInitialize command into the template. but it was not really satisfying

so i would actually suggest putting only a link into the blog and have the jmol applet on a regular html page (http://chemical-quantum-images.blogspot.com/2009/01/normal-modes-3.html, http://chemical-quantum-images.blogspot.com/2007/11/erythromycin.html). this also has the advantage that the blog loads faster

let me know if you have any problems
Felix

Jan Jensen said...

Thanks for getting back to me, Felix. Yes, I am already noticing a slight decrease in the loading speed of the blog. So it is probably not good to go overboard with Jmol applets, just for that reason.

Jan Jensen said...

Follow up:

Steven Bachrach over at Computational Organic Chemistry does something clever:

1. defines a function involving JmolApplet.jar early on the page. I think this avoids jmolInitialize altogether?

2. links this function to a static image of the structure, so that you only get the Jmol application upon clicking. This should help the loading speed?

I haven't tried it on the Blog yet, but I made a small html code that works on my server.

I think everything in the header should go in the gadget.

Jan Jensen said...

Follow up to the follow up:

It works! as the subsequent posting attests to.

Felix said...

oh, that's very nice
I should remember that

Angel said...

If I reckon correctly, two instances of jmolInitialize() in a page are no longer a problem with recent versions of Jmol.js
I tried that with the Jmol MediaWiki Extension in the Jmol Wiki some time ago.