def test_from_dict(self):

        d = self.propertied_structure.as_dict()
        s = IStructure.from_dict(d)
        self.assertEqual(s[0].magmom, 5)
        d = self.propertied_structure.as_dict(0)
        s2 = IStructure.from_dict(d)
        self.assertEqual(s, s2)

        d = {'lattice': {'a': 3.8401979337, 'volume': 40.044794644251596,
                         'c': 3.8401979337177736, 'b': 3.840198994344244,
                         'matrix': [[3.8401979337, 0.0, 0.0],
                                    [1.9200989668, 3.3257101909, 0.0],
                                    [0.0, -2.2171384943, 3.1355090603]],
                         'alpha': 119.9999908639842, 'beta': 90.0,
                         'gamma': 60.000009137322195},
             'sites': [{'properties': {'magmom': 5}, 'abc': [0.0, 0.0, 0.0],
                        'occu': 1.0, 'species': [{'occu': 1.0,
                                                  'oxidation_state': -2,
                                                  'properties': {'spin': 3},
                                                  'element': 'O'}],
                        'label': 'O2-', 'xyz': [0.0, 0.0, 0.0]},
                       {'properties': {'magmom': -5},
                        'abc': [0.75, 0.5, 0.75],
                        'occu': 0.8, 'species': [{'occu': 0.8,
                                                  'oxidation_state': 2,
                                                  'properties': {'spin': 2},
                                                  'element': 'Mg'}],
                        'label': 'Mg2+:0.800',
                        'xyz': [3.8401979336749994, 1.2247250003039056e-06,
                                2.351631795225]}]}
        s = IStructure.from_dict(d)
        self.assertEqual(s[0].magmom, 5)
        self.assertEqual(s[0].specie.spin, 3)
        self.assertEqual(type(s), IStructure)
 def test_from_dict(self):
     d = self.propertied_structure.to_dict
     s = IStructure.from_dict(d)
     self.assertEqual(s[0].magmom, 5)
     d = {
         "lattice": {
             "a": 3.8401979337,
             "volume": 40.044794644251596,
             "c": 3.8401979337177736,
             "b": 3.840198994344244,
             "matrix": [
                 [3.8401979337, 0.0, 0.0],
                 [1.9200989668, 3.3257101909, 0.0],
                 [0.0, -2.2171384943, 3.1355090603],
             ],
             "alpha": 119.9999908639842,
             "beta": 90.0,
             "gamma": 60.000009137322195,
         },
         "sites": [
             {
                 "properties": {"magmom": 5},
                 "abc": [0.0, 0.0, 0.0],
                 "occu": 1.0,
                 "species": [{"occu": 1.0, "oxidation_state": -2, "properties": {"spin": 3}, "element": "O"}],
                 "label": "O2-",
                 "xyz": [0.0, 0.0, 0.0],
             },
             {
                 "properties": {"magmom": -5},
                 "abc": [0.75, 0.5, 0.75],
                 "occu": 0.8,
                 "species": [{"occu": 0.8, "oxidation_state": 2, "properties": {"spin": 2}, "element": "Mg"}],
                 "label": "Mg2+:0.800",
                 "xyz": [3.8401979336749994, 1.2247250003039056e-06, 2.351631795225],
             },
         ],
     }
     s = IStructure.from_dict(d)
     self.assertEqual(s[0].magmom, 5)
     self.assertEqual(s[0].specie.spin, 3)
     self.assertEqual(type(s), IStructure)
Exemple #3
0
 def get_input(data):
     couples = []
     for item in data:
         structure = IStructure.from_dict(item)
         try:
             raman = torch.FloatTensor(item["raman"])
             graph = CrystalEmbedding(structure, max_atoms=30)
         except ValueError:
             continue
         except RuntimeError:
             continue
         except TypeError:
             continue
         encoded_graph = graph.convert_to_model_input()
         couples.append((encoded_graph, raman))
     return couples
Exemple #4
0
 def test_from_dict(self):
     d = self.propertied_structure.to_dict
     s = IStructure.from_dict(d)
     self.assertEqual(s[0].magmom, 5)
     d = {
         'lattice': {
             'a':
             3.8401979337,
             'volume':
             40.044794644251596,
             'c':
             3.8401979337177736,
             'b':
             3.840198994344244,
             'matrix': [[3.8401979337, 0.0, 0.0],
                        [1.9200989668, 3.3257101909, 0.0],
                        [0.0, -2.2171384943, 3.1355090603]],
             'alpha':
             119.9999908639842,
             'beta':
             90.0,
             'gamma':
             60.000009137322195
         },
         'sites': [{
             'properties': {
                 'magmom': 5
             },
             'abc': [0.0, 0.0, 0.0],
             'occu':
             1.0,
             'species': [{
                 'occu': 1.0,
                 'oxidation_state': -2,
                 'properties': {
                     'spin': 3
                 },
                 'element': 'O'
             }],
             'label':
             'O2-',
             'xyz': [0.0, 0.0, 0.0]
         }, {
             'properties': {
                 'magmom': -5
             },
             'abc': [0.75, 0.5, 0.75],
             'occu':
             0.8,
             'species': [{
                 'occu': 0.8,
                 'oxidation_state': 2,
                 'properties': {
                     'spin': 2
                 },
                 'element': 'Mg'
             }],
             'label':
             'Mg2+:0.800',
             'xyz':
             [3.8401979336749994, 1.2247250003039056e-06, 2.351631795225]
         }]
     }
     s = IStructure.from_dict(d)
     self.assertEqual(s[0].magmom, 5)
     self.assertEqual(s[0].specie.spin, 3)
     self.assertEqual(type(s), IStructure)
Exemple #5
0
 def convert(item):
     structure = IStructure.from_dict(item["structure"])
     graph = CrystalEmbedding(structure)
     raman_modes = graph.get_raman_modes()
     encoded_graph = graph.convert_to_model_input()
     return encoded_graph, raman_modes