Пример #1
0
def getSpeciesListCIF(inputFile):
    ''' inputFile is the name of an input file 
        use ASE at this point to quickly parse file 
        DOES NOTHING ABOUT FRACTIONAL OCCUPANCY '''

    from ase.io.cif import parse_cif
    aseParser = parse_cif(inputFile)

    for name, c in aseParser:
        scaled_positions = np.array([
            c['_atom_site_fract_x'], c['_atom_site_fract_y'],
            c['_atom_site_fract_z']
        ]).T
        crys = crystal(c['_atom_site_type_symbol'],
                       basis=scaled_positions,
                       cellpar=[
                           c['_cell_length_a'], c['_cell_length_b'],
                           c['_cell_length_c'], c['_cell_angle_alpha'],
                           c['_cell_angle_beta'], c['_cell_angle_gamma']
                       ],
                       spacegroup=c['_symmetry_int_tables_number'])
        atoms = Atoms(symbols=c['_atom_site_type_symbol'],
                      scaled_positions=scaled_positions,
                      cell=[
                          c['_cell_length_a'], c['_cell_length_b'],
                          c['_cell_length_c'], c['_cell_angle_alpha'],
                          c['_cell_angle_beta'], c['_cell_angle_gamma']
                      ],
                      info={
                          'spacegroup':
                          ASESpacegroup(c['_symmetry_int_tables_number'])
                      })

        print 'pbc=False', len(crys), len(atoms)
        yield atoms
Пример #2
0
def test_empty_or_atomless_cifblock():
    ciffile = io.BytesIO(b'data_dummy')
    blocks = list(parse_cif(ciffile))

    assert len(blocks) == 1
    assert not blocks[0].has_structure()
    with pytest.raises(NoStructureData):
        blocks[0].get_atoms()
Пример #3
0
def test_symbols_questionmark():
    ciffile = io.BytesIO(b'data_dummy\n'
                         b'loop_\n'
                         b'_atom_site_label\n'
                         b'?\n')
    blocks = list(parse_cif(ciffile))
    assert not blocks[0].has_structure()
    with pytest.raises(NoStructureData, match='undetermined'):
        blocks[0].get_atoms()
Пример #4
0
def test_spacegroup_named_setting(setting_name, ref_setting):
    """The rhombohedral crystal system signifies setting=2"""
    ciffile = io.BytesIO("""\
data_test
_space_group_crystal_system {}
_symmetry_space_group_name_H-M         'R-3m'
""".format(setting_name).encode('ascii'))

    blocks = list(parse_cif(ciffile))
    assert len(blocks) == 1
    spg = blocks[0].get_spacegroup(False)
    assert int(spg) == 166
    assert spg.setting == ref_setting
Пример #5
0
def test_loop_with_space():
    # Regression test for https://gitlab.com/ase/ase/-/issues/859 .
    buf = io.BytesIO(cif_with_whitespace_after_loop)
    blocks = list(parse_cif(buf))
    assert len(blocks) == 1
    assert blocks[0]['_potato'] == 42
Пример #6
0
import sys;
from ase.io.cif import parse_cif; 
cif = parse_cif( 'CeO2.cif' )
for key,value in cif[0][1].items():
    print( "{0} -> {1} {2}".format( type( value ), key, value ) )