この文書の現在のバージョンと選択したバージョンの差分を表示します。
ab_initio:波動関数 2009/02/01 00:58 | — 現在 | ||
---|---|---|---|
ライン 1: | ライン 1: | ||
- | ====== 波動関数 ====== | ||
- | |||
- | <code> | ||
- | [kimi@ssp1 ncfiles]$ ./getwfs | ||
- | usage: getwfs [-w] input_nc_file output_file_prefix | ||
- | |||
- | options: | ||
- | -h, --help show this help message and exit | ||
- | -w, --wavefunction create xyz format files for all wavefunctions | ||
- | |||
- | [kimi@ssp1 ncfiles]$ cat ./getdensity ./getwfs | ||
- | #!/usr/bin/env python | ||
- | from math import log10 | ||
- | from optparse import OptionParser | ||
- | |||
- | from Dacapo import Dacapo | ||
- | from ASE.IO.Cube import WriteCube | ||
- | |||
- | cmd = OptionParser(usage = '%prog [-w] input_nc_file output_file_prefix') | ||
- | cmd.add_option('-w', '--wavefunction', action = "store_true", default = False, | ||
- | help = 'create xyz format files for all wavefunctions') | ||
- | |||
- | |||
- | (opt, argv) = cmd.parse_args() | ||
- | |||
- | if len(argv) != 2: | ||
- | cmd.print_help() | ||
- | raise SystemExit | ||
- | |||
- | ncfile = argv[0] | ||
- | cubefileprefix = argv[1] | ||
- | |||
- | model = Dacapo.ReadAtoms(ncfile) | ||
- | calculator = model.GetCalculator() | ||
- | |||
- | if opt.wavefunction is not True: | ||
- | density = calculator.GetDensityArray() | ||
- | cubefile = '%s.xyz' % cubefileprefix | ||
- | WriteCube(model, density, cubefile) | ||
- | else: | ||
- | NumberOfBands = calculator.GetNumberOfBands() | ||
- | NumberOfKpoints = len(calculator.GetIBZKPoints()) | ||
- | isSpinPolarized = calculator.GetSpinPolarized() | ||
- | if (isSpinPolarized): | ||
- | NumberOfSpins = 2 | ||
- | else: | ||
- | NumberOfSpins = 1 | ||
- | |||
- | for nband in range(NumberOfBands): | ||
- | for nkpt in range(NumberOfKpoints): | ||
- | for nspin in range(NumberOfSpins): | ||
- | cubefile = '%s' % cubefileprefix | ||
- | fmts = '%%0%dd' % (log10(NumberOfBands) + 1) | ||
- | cubefile += fmts % nband | ||
- | if (NumberOfKpoints > 1): | ||
- | fmts = 'k%%0%dd' % (log10(NumberOfKpoints) + 1) | ||
- | cubefile += fmts % nkpt | ||
- | if (NumberOfSpins > 1): | ||
- | cubefile += 's%1d' % nspin | ||
- | cubefile += '.cube' | ||
- | print cubefile | ||
- | wf = calculator.GetWaveFunctionArray(band = nband, | ||
- | kpt = nkpt, | ||
- | spin = nspin) | ||
- | WriteCube(model, wf, cubefile) | ||
- | |||
- | |||
- | [kimi@ssp1 ncfiles]$ | ||
- | </code> | ||