Coder Social home page Coder Social logo

jjgoings / two-component_cubes Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 4.0 25.77 MB

Python script to prepare complex, two-component Gaussian cube files to be read by GaussView or Pymol, etc.

Python 100.00%
cube-files gaussian magnetization ghf plot

two-component_cubes's Introduction

Cubes

Basic use

This is a python class to read and write out Gaussian cube files, with a particular emphasisis on extracting complex and two-component molecular orbitals.

Example:

Say you have a complex 2c MO cube called twoc.cube. If you have cube.py in the same directory, you could write a script like

from cube import Cube
twoc = Cube('twoc.cube')
twoc.write_out('twoc_ra.cube',data='RA')
twoc.write_out('twoc_ia.cube',data='IA')
twoc.write_out('twoc_rb.cube',data='RB')
twoc.write_out('twoc_ib.cube',data='IB')

Or, if you just cloned the whole directory you can run cube.py as-is

$ python cube.py

(You can modify the behavior of cube.py underneath the if__name__ == '__main__()':)

This would create an object called twoc, which you could then dump out new cube files that are readable by GaussView corresponding to the real alpha (data='RA'), real beta (data='RB'), imaginary alpha (data='IA'), and imaginary beta (data='IB'). The default for write_out is real alpha.

The code should be smart enough to distinguish between MO and density cube files.

Usually there is no problem using GaussView for RHF and UHF anyway, so the code isn't yet generalized to all cases, but I'll work that out when I have time.

Vector quantities: Getting magnetization densities and electrostatic field gradients

If you generated your GHF cubes using the VSPIN (in the development version only of cubegen, I believe), you can also write out magnetization densities.

So, for example you ran the following:

cubegen 0 vspin ghf-vspin-example.fchk ghf-vspin-example.cube 40 h

Then you could do, e.g.

magnetization = Cube('ghf-vspin-example.cube',vspin=True)
magnetization.write_out('Mz.cube',data='Mz')

This would dump the z-component of the magnetization density to a new cube called Mz.cube. You can do this for the norm of the magnetization data='N', as well as the x and y components of the magnetization (data='Mx' and data='My', respectively). Densitites are always real.

There is also a new function to plot some vector quantities, if you have Mayavi installed. These are handled through the plot_property method. So continuing the example above,

magnetization = Cube('ghf-vspin-example.cube',vspin=True)
magnetization.plot_property('MAG')

would plot the magnetization vector at different points in 3D space. It's in beta, so you may need to fiddle around with the source to get it to do what you want.

Similarly, if you have an electrostatic potential generated by, for example,

cubegen 0 potential=scf esp-example.fchk esp-example.cube 80 h

Then you can do

ESP = Cube('esp-example.cube')
ESP.plot_property('ESP')

which will plot the gradient (a vector) of your electrostatic potential. This is helpful for visualizing the electric field generated by a molecule with a dipole moment, for example.

two-component_cubes's People

Contributors

jjgoings avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.