"""
Test for data of plugin
"""
from __future__ import absolute_import
from aiida.manage.tests.unittest_classes import PluginTestCase
[docs]class TestStructureSet(PluginTestCase):
"""
Test data type StructureSet.
"""
[docs] def setUp(self):
from aiida.orm import StructureData
from aiida.plugins import DataFactory
from icet.tools import enumerate_structures
from ase.build import bulk
# Create the samples for test (totally 10, but only use even index structures):
# Atoms(symbols='Pd', pbc=True, cell=[[0.0, 2.04, 2.04], [2.04, 0.0, 2.04], [2.04, 2.04, 0.0]]),
# Atoms(symbols='PdAu', pbc=True, cell=[[0.0, -2.04, -2.04], [-2.04, 0.0, -2.04], [2.04, 2.04, -4.08]]),
# Atoms(symbols='Pd2Au', pbc=True, cell=[[0.0, 2.04, 2.04], [-2.04, 0.0, -2.04], [-4.08, -4.08, 4.08]]),
# Atoms(symbols='Pd2Au', pbc=True, cell=[[0.0, -2.04, -2.04], [-4.08, 0.0, 0.0], [2.04, 4.08, -2.04]]),
# Atoms(symbols='Pd2Au', pbc=True, cell=[[0.0, 2.04, 2.04], [0.0, 2.04, -2.04], [-6.12, -2.04, 0.0]])
primitive_structure = bulk('Au')
structurelist = []
for structure in enumerate_structures(primitive_structure,
range(1, 4),
['Pd', 'Au']):
# generator of structure, convert it to StructureData
# and store it in the aiida db
aiida_structure = StructureData(ase=structure)
aiida_structure.store()
structurelist.append(aiida_structure)
structurelist = [s for i,s in enumerate(structurelist) if i%2 ==0]
StructureSet = DataFactory('ce.StructureSet')
self.structure_set_bcc = StructureSet(structurelist=structurelist)
# TODO: Add test for spinel
[docs] def test_structure_set_shape(self):
cells = self.structure_set_bcc.get_cells()
self.assertEqual(cells.shape, (5, 3, 3))
positions = self.structure_set_bcc.get_positions()
self.assertEqual(positions.shape, (12, 1, 3))
atomic_numbers = self.structure_set_bcc.get_atomic_numbers()
self.assertEqual(atomic_numbers.shape, (12, 1))