Example #1
0
def test_recip_cell():
    # reciprocal cell
    cell = rand(3, 3)
    rcell = crys.recip_cell(cell)
    vol = crys.volume_cell(cell)
    try:
        assert np.allclose(crys.recip_cell(rcell), cell)
    except AssertionError:
        assert np.allclose(crys.recip_cell(rcell), -1.0 * cell)
    assert np.allclose(crys.volume_cell(rcell), (2 * pi)**3.0 / vol)
Example #2
0
def test_recip_cell():
    # reciprocal cell
    cell = rand(3,3)
    rcell = crys.recip_cell(cell)
    vol = crys.volume_cell(cell)
    try:
        assert np.allclose(crys.recip_cell(rcell), cell)
    except AssertionError:        
        assert np.allclose(crys.recip_cell(rcell), -1.0 * cell)
    assert np.allclose(crys.volume_cell(rcell), (2*pi)**3.0 / vol)
    [0,0,0],
    [.5,0,0],
    [1/2., 1/2., 0],
    [0,0.5,0],
    [0,0,0],
    [0,0,.5],
    [0.5,0,.5],
    [0.5,0.5,.5],
    [0.0,0.5,.5],
    [0,0,.5],
    ])

# recip. cell in 2*pi/alat units, need this to make QE happy, q-points in
# matdyn.in and matdyn.freq output file are cartesian in 2*pi/alat
st = io.read_pw_scf('pw.out')
rcell_reduced = crys.recip_cell(st.cell) / 2.0 / np.pi * st.cryst_const[0]
sp_points = np.dot(sp_points_frac, rcell_reduced)

# fine path: use N=500 for nice LO-TO split jumps [see below for more comments
# on that] 
ks_path = kpath.kpath(sp_points, N=50)

# call matdyn.x
templ_txt = """
&input
    asr='crystal',
XXXMASS    
    flfrc='q2r.fc',
    flfrq='XXXFNFREQ'
/
XXXNKS
    [0,0,0],
    [.5,0,0],
    [1/2., 1/2., 0],
    [0,0.5,0],
    [0,0,0],
    [0,0,.5],
    [0.5,0,.5],
    [0.5,0.5,.5],
    [0.0,0.5,.5],
    [0,0,.5],
    ])

# recip. cell in 2*pi/alat units, need this to make QE happy, q-points in
# matdyn.in and matdyn.freq output file are cartesian in 2*pi/alat
st = io.read_pw_scf('pw.out')
rcell_reduced = crys.recip_cell(st.cell) / 2.0 / np.pi * st.cryst_const[0]
sp_points = np.dot(sp_points_frac, rcell_reduced)

# fine path: use N=500 for nice LO-TO split jumps [see below for more comments
# on that]
ks_path = kpath.kpath(sp_points, N=50)

# call matdyn.x
templ_txt = """
&input
    asr='crystal',
XXXMASS    
    flfrc='q2r.fc',
    flfrq='XXXFNFREQ'
/
XXXNKS
Example #5
0
import sys
import numpy as np

from pwtools import crys, atomic_data, pwscf, io
from pwtools.common import str_arr, seq2str
from pwtools.constants import Bohr, Angstrom

def indent(txt, num=4):
    """Indent text block by `num` white spaces."""
    space = " "*num
    return '\n'.join(space + line for line in txt.splitlines())


# All lengths in Bohr
struct = io.read_cif(sys.argv[1], units={'length': Angstrom/Bohr})
rcell = crys.recip_cell(struct.cell)
norms = np.sqrt((rcell**2.0).sum(axis=1))
bar = '-'*78
mass_unique = [atomic_data.pt[sym]['mass'] for sym in struct.symbols_unique]                 
atspec = pwscf.atspec_str(struct.symbols_unique, 
                          mass_unique, 
                          [sym + '.UPF' for sym in struct.symbols_unique])
celldm = crys.cc2celldm(struct.cryst_const)
atpos_frac = pwscf.atpos_str(struct.symbols, struct.coords_frac)

print("""\
Notes
-----
The .cif file is assumed to contain NO symmetry information:
    _symmetry_space_group_name_H-M          'P 1'
    _symmetry_Int_Tables_number             1
Example #6
0
import numpy as np

from pwtools import crys, atomic_data, pwscf, io
from pwtools.common import str_arr, seq2str
from pwtools.constants import Bohr, Angstrom


def indent(txt, num=4):
    """Indent text block by `num` white spaces."""
    space = " " * num
    return '\n'.join(space + line for line in txt.splitlines())


# All lengths in Bohr
struct = io.read_cif(sys.argv[1], units={'length': Angstrom / Bohr})
rcell = crys.recip_cell(struct.cell)
norms = np.sqrt((rcell**2.0).sum(axis=1))
bar = '-' * 78
mass_unique = [atomic_data.pt[sym]['mass'] for sym in struct.symbols_unique]
atspec = pwscf.atspec_str(struct.symbols_unique, mass_unique,
                          [sym + '.UPF' for sym in struct.symbols_unique])
celldm = crys.cc2celldm(struct.cryst_const)
atpos_frac = pwscf.atpos_str(struct.symbols, struct.coords_frac)

print("""\
Notes
-----
The .cif file is assumed to contain NO symmetry information:
    _symmetry_space_group_name_H-M          'P 1'
    _symmetry_Int_Tables_number             1
    loop_