# Plotting electronic orbitals using Mathematica

GROUPS:
1 year ago
9 Replies
 Robert Collyer 2 Votes Have you considered turning ReadCube and WriteCube into an Import/Export filter?
1 year ago
 Jason Biggs 2 Votes Not only have I not considered it, I didn't realize it was an option.  How does one go about writing custom Import and Export filters?
1 year ago
 Robert Collyer 1 Vote Ah, I was using the wrong terminology, Import/Export converter. That should get you started.
1 year ago
 Jason, thank you for posting this, - this is some nice work. I have a question. When I execute this lines:ExtractArchive["cys-MO35cube.gz"];{cubedata,xg,yg,zg,xyz,header}= ReadCube["cys-MO35.cube"];I get some error messages. I do save linked file in the base directory of course preliminary. Can you confirm that these lines run fine on your system?
1 year ago
 It wasn't working because I don't understand how Mathematica extracts archive files, it seems to change the file name.  Since I can't seem to find a better place to host this 3MB file, I'm just linking to my dropbox.It should work now
1 year ago
 Jason Biggs 1 Vote Robert Collyer, I'm trying to implement your suggestion but I've run into a snag.  It seems that if I make a call to ElementData during the Import convertor program, then I cannot use ElementData in another context afterwards.   I get an InputStream error.  Here I've got it down to the simplest example that reproduces the error.Here is where it fails: In[1]:= Export["testfile.txt", "hello"];         ImportExportRegisterImport["TestFormat", TestFormatTestFormatImport];         TestFormatTestFormatImport[filename_String, options___] :=            Module[{temp},(*Do some stuff,all works just fine*)            temp = ElementData["C", "AtomicNumber"];            {"Test" -> temp}];         Import["testfile.txt", {"TestFormat", "Test"}]         ElementData["F", "AtomicNumber"] Out[4]= 6        During evaluation of In[1]:= General::openx: InputStream[C:\Users\myusername\AppData\Roaming\Mathematica\Paclets\Repository\ElementData-7.0.28\Data\ElementData.wdx,126] is not open. >>        During evaluation of In[1]:= BinaryRead::openx: InputStream[C:\Users\myusername\AppData\Roaming\Mathematica\Paclets\Repository\ElementData-7.0.28\Data\ElementData.wdx,126] is not open. >>Out[5]= \$FailedBut if, after I've defined the convertor program but before I invoke it, I call ElementData then I get no error message: In[1]:= Export["testfile.txt", "hello"];         ImportExportRegisterImport["TestFormat", TestFormatTestFormatImport];         TestFormatTestFormatImport[filename_String, options___] :=            Module[{temp},(*Do some stuff,all works just fine*)            temp = ElementData["C", "AtomicNumber"];            {"Test" -> temp}];         ElementData["H", "AtomicNumber"]         Import["testfile.txt", {"TestFormat", "Test"}]         ElementData["F", "AtomicNumber"]Out[4]= 1Out[5]= 6Out[6]= 9Any help would be most appreciated.
1 year ago
 Robert Collyer 1 Vote I can't seem to reproduce that effect. First, have you tried this on a fresh kernel?  Presuming you have, you could try rebuilding the paclets viaRebuildPacletData[]That likely isn't the source of the issue, but it may not hurt to try. Lastly, you could pre-build an index of atomic numbers and use that instead.
1 year ago
 Tal Einav 2 Votes Super cool! I really like this plotting functionality. I have a couple of questions:Can you explain a little more about the format for the cube file (what the columns mean and what the data represents)? Also, what are the specifications for the orbital in "cys-MO35.cube", and what molecule is it?Can you use your WriteCube function to write a cube file for some molecule? For instance, could you reproduce how you would go about writing "cys-MO35.cube"? If this enables you to visualize the orbitals of any molecule that would be insanely awesome!Also, one style-oriented suggestion I can offer is that if you make the orbitals slightly transparent, you will always be able to see the underlying molecule in place throughout your movie:CubePlot[{cubedata, xg, yg, zg, xyz}, vp, ContourStyle -> {{Opacity[0.5],     Texture[ExampleData[{"ColorTexture", "Vavona"}]]}, {Opacity[0.5],     Texture[ExampleData[{"ColorTexture", "Amboyna"}]]}}]
1 year ago
 Vitaliy Kaurov 1 Vote What a coincidence, we just have published a related Demonstration:Some Examples of Molecule Orbitals by Guenther Gsaller and Norbert Mueller from Institute of Organic Chemistry & Johannes Kepler University in Austria. Quoting: Molecule orbitals are formed when atomic orbitals overlap. Mathematically, this is represented by a linear combination of atomic orbitals (as in the LCAO-MO method). Some possible classifications of orbitals are bonding and antibonding and Pi- and Sigma-symmetry.This Demonstration shows the basic characteristics for a set of six molecules: the label, the description, the number of electrons in the chosen molecular orbital, and a 3D view of the probability density (with boundary surface, phase-coloring included) and also a ball and stick model for each example.