Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color-Mapped PES using ngl.js #973

Open
Mike-Devereux opened this issue Apr 14, 2021 · 1 comment
Open

Color-Mapped PES using ngl.js #973

Mike-Devereux opened this issue Apr 14, 2021 · 1 comment

Comments

@Mike-Devereux
Copy link

  • Version report
    v.2.0.0.dev.39

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 handlerr 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
Copy link
Collaborator

hainm commented Apr 14, 2021

Ping @fredludlow since it's NGL issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants