nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
787 stars 132 forks source link

Color-Mapped PES using ngl.js #973

Open Mike-Devereux opened 3 years ago

Mike-Devereux commented 3 years ago

Great tool! Following the example in ngl/examples/scripts/color/volume-esp.js I wrote something similar to show the ESP on an isodensity surface from two Gaussian cube files, one containing electron density and the other the ESP (code is below). This throws:

Uncaught TypeError: e.toPrecision is not a function _makeSurface https://unpkg.com/ngl:1 getSurfaceWorker https://unpkg.com/ngl:1 onmessage https://unpkg.com/ngl:1 za https://unpkg.com/ngl:1 getNextWorker https://unpkg.com/ngl:1 getSurfaceWorker https://unpkg.com/ngl:1 prepare https://unpkg.com/ngl:1 make https://unpkg.com/ngl:1 i https://unpkg.com/ngl:1 r https://unpkg.com/ngl:1 setTimeout handler*r https://unpkg.com/ngl:1 push https://unpkg.com/ngl:1 build https://unpkg.com/ngl:1 init https://unpkg.com/ngl:1 e https://unpkg.com/ngl:1 Ts https://unpkg.com/ngl:1 addRepresentation https://unpkg.com/ngl:1 addRepresentation https://unpkg.com/ngl:1

file:///XXX/refCube.html:23 promise callback* file:///XXX/refCube.html:19 EventListener.handleEvent* file:///XXX/refCube.html:13 If I change e.toPrecision(2),n=new qg(r,"",t) in dist/ngl.js to e,n=new qg(r,"",t) Things work as expected. The problem code loads 2 unmodified cube files generated by the "Gaussian" quantum chemistry program: var densFile = 'http://localhost:8000/naphta.dens.cube' var espFile = 'http://localhost:8000/naphta.pot.cube' document.addEventListener("DOMContentLoaded", function () { var stage = new NGL.Stage("viewport"); Promise.all([ stage.loadFile(densFile), stage.loadFile(espFile) ]).then(function(comp) { var densComp = comp[0] var espComp = comp[1] densComp.addRepresentation("surface",{isolevel: "0.001", isolevelType: 'value', opacity: 0.95, side: 'front', colorScheme: 'volume', colorVolume: espComp.volume, colorScale: [ 0xff0000, 0xffff00, 0x00ff00, 0x00ffff, 0x0000ff ], colorMode: 'rgb', colorDomain: [ -0.03, 0.03 ] }); stage.autoView(); } ); });
hainm commented 3 years ago

Ping @fredludlow since it's NGL issue.