Surface Science and Solid State Theory Laboratory

# @surface

## jmolテスト 0

Posted on 12月 24, 2009 by kimi

The OpenScience projectのサイトを参考にjmolアプレットを仕込んでみた。サンプルはSb吸着Si(111)表面の4×1構造と8×2構造の間の原子位置の変遷をアニメーションにしたもの。ただし、現実には、こんな風に動くことは絶対にありません。リアルなアニメーションはどこかの研究会でお見せできるでしょう。マウスでグリグリ動かしたり、拡大したり、アニメーションしたりできる。是非、いろいろ遊んでみて。（ヒント：マウスの右ボタンとホイール） Read the rest of this entry →

## From NetCDF to CUBE (1) 0

Posted on 11月 10, 2009 by kimi

## Total density of states;

 123456789101112131415161718192021222324252627282930313233343536373839 #!/usr/bin/env python import string from math import log10 from optparse import OptionParser from Dacapo import Dacapo from ASE.IO.Cube import WriteCube cmd = OptionParser(usage = '%prog input_nc_file output_cube_file') (opt, argv) = cmd.parse_args() if len(argv) != 2:   cmd.print_help()   raise SystemExit ncfile = argv[0] cubefile = argv[1] basename = string.split(cubefile, '.cube') model = Dacapo.ReadAtoms(ncfile) calculator = model.GetCalculator() if not calculator.GetSpinPolarized():   filename_total= basename[0] + '.cube' else:   filename_total= basename[0] + '_total.cube'   filename_diff= basename[0] + '_diff.cube'   filename_spin0= basename[0] + '_spin0.cube'   filename_spin1= basename[0] + '_spin1.cube'   density0 = calculator.GetDensityArray(spin = 0)   density1 = calculator.GetDensityArray(spin = 1)   WriteCube(model, density0, filename_spin0)   WriteCube(model, density1, filename_spin1)   diff = density1 - density0   WriteCube(model, diff, filename_diff) density = calculator.GetDensityArray() WriteCube(model, density, filename_total)

## From NetCDF to DOS 0

Posted on 11月 10, 2009 by kimi
 12 #!/usr/bin/env python from optparse import OptionParser
 12 from Dacapo import Dacapo from ASE.Utilities.DOS import DOS
 123456789101112131415 cmd = OptionParser(usage = '%prog [-r] input_nc_file output_text_file') cmd.add_option('-r', '--reverse', action = "store_true", default = False, help = 'reverse out put for minor spin states') (opt, argv) = cmd.parse_args() if len(argv) != 2:   cmd.print_help()   raise SystemExit   ncfile = argv[0]   textfile = argv[1]   sfmt0 = '%-15s %-15s\n'   sfmt1 = '%-15s %-15s %-15s %-15s\n'   efmt0 = '%15.7E %15.7E\n'   efmt1 = '%15.7E %15.7E %15.7E %15.7E\n'
 1234567891011121314151617181920212223242526 atoms = Dacapo.ReadAtoms(ncfile)   calc = atoms.GetCalculator()   isSpinPolarized = calc.GetSpinPolarized()   dos = DOS(calc)   x0 = dos.GetEnergies()   if isSpinPolarized:     y0 = dos.GetDOS(0)     y1 = dos.GetDOS(1)     fp = open(textfile, 'w')     if opt.reverse:       fp.write(sfmt1 % ('Energy', 'DOS0', 'DOS1', 'DIFF'))     else:       fp.write(sfmt1 % ('Energy', 'DOS0', 'DOS1', 'TOTAL'))       for i in range(len(x0)):         if opt.reverse:           fp.write(efmt1 % (x0[i], y0[i], -y1[i], y0[i] - y1[i]))         else:           fp.write(efmt1 % (x0[i], y0[i],  y1[i], y0[i] + y1[i]))       fp.close()   else:     y0 = dos.GetDOS(0)     fp = open(textfile, 'w')     fp.write(sfmt0 % ('Energy', 'DOS'))     for i in range(len(x0)):       fp.write(efmt0 % (x0[i], y0[i]))     fp.close()

## From NetCDF to XYZ 0

Posted on 11月 09, 2009 by kimi
 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 #!/usr/bin/env python import os import tempfile from optparse import OptionParser   from Dacapo import Dacapo from ASE.Trajectories.NetCDFTrajectory import NetCDFTrajectory from ASE.IO.xyz import WriteXYZ   cmd = OptionParser(usage = '%prog [-r R1 R2 R3] input_nc_file output_xyz_file') cmd.add_option('-r', '--repeat', type = 'int', nargs = 3,                help = 'Repeat R1, R2, R3 times along the three axes',                metavar = 'R1 R2 R3')   (opt, argv) = cmd.parse_args()   if len(argv) != 2:     cmd.print_help()     raise SystemExit   ncfile = argv[0] xyzfile = argv[1]   try:   model = Dacapo.ReadAtoms(ncfile, index = 1)   trajectory = True except IndexError:   trajectory = False   if not trajectory:   model = Dacapo.ReadAtoms(ncfile)   WriteXYZ(xyzfile, atoms = model, repeat = opt.repeat, id = ncfile) else:   model = Dacapo.ReadAtoms(ncfile, index = 0)   model.SetCalculator(None)   tmpfile = tempfile.mktemp()   xyzpath = NetCDFTrajectory(tmpfile, model)   xyzpath.Update()     frame = 0   error = False   while not error:     frame += 1     try:         atoms = Dacapo.ReadAtoms(ncfile, index = frame)         model.SetCartesianPositions(atoms.GetCartesianPositions())         xyzpath.Update()     except IndexError:         error = True     xyzpath.Close()       xyzpath = NetCDFTrajectory(tmpfile)   WriteXYZ(xyzfile, trajectory = xyzpath, repeat = opt.repeat, id = ncfile)   os.remove(tmpfile)

↑ Top