Ejemplo n.º 1
0
    def _toatoms(self, include_results=False):
        if not include_results:
            return ase.atoms.Atoms(
                self.numbers,
                self.positions,
                cell=self.cell,
                pbc=(self.pbc & np.array([1, 2, 4])).astype(bool),
            )

        if self.constraints:
            constraints = json.loads(self.constraints)
            if len(constraints[0]['kwargs']['indices']) > 0:
                constraints = [dict2constraint(d) for d in constraints]
        else:
            constraints = None
        atoms = ase.atoms.Atoms(self.numbers,
                                self.positions,
                                cell=self.cell,
                                pbc=(self.pbc
                                     & np.array([1, 2, 4])).astype(bool),
                                magmoms=self.magmoms,
                                charges=self.charges,
                                tags=self.tags,
                                masses=self.masses,
                                momenta=self.momenta,
                                constraint=constraints)

        if not self.calculator == "unknown":
            params = self.get('calculator_parameters', {})
            atoms.calc = get_calculator(self.calculator)(**params)
        else:
            all_properties = [
                'energy', 'forces', 'stress', 'dipole', 'charges', 'magmom',
                'magmoms', 'free_energy'
            ]
            results = {}
            #print(getattr(self, 'energy'))
            for prop in all_properties:
                result = getattr(self, prop, None)
                if result is not None:
                    results[prop] = result
            # print(results)
            if results:
                atoms.calc = SinglePointCalculator(atoms, **results)
                atoms.calc.name = getattr(self, 'calculator', 'unknown')

        atoms.info = {}
        atoms.info['unique_id'] = self.unique_id
        atoms.info['key_value_pairs'] = self.key_value_pairs

        data = self.data
        if data:
            atoms.info['data'] = data

        return atoms
Ejemplo n.º 2
0
 def process_result_value(self, value, dialect):
     return json.loads(value)
Ejemplo n.º 3
0
 def _dft_code(self):
     return json.loads(self.key_value_pairs).get('dft_code', '')
Ejemplo n.º 4
0
 def _dft_functional(self):
     return json.loads(self.key_value_pairs).get('dft_functional', '')
Ejemplo n.º 5
0
 def _facet(self):
     return json.loads(self.key_value_pairs).get('facet', '').strip("()")
Ejemplo n.º 6
0
 def _substrate(self):
     return json.loads(self.key_value_pairs).get('substrate', '')
Ejemplo n.º 7
0
 def _adsorbate(self):
     return json.loads(self.key_value_pairs).get('adsorbate', '')
Ejemplo n.º 8
0
 def _username(self):
     return json.loads(self.key_value_pairs).get('username', '')
Ejemplo n.º 9
0
 def _reaction(self):
     reaction = json.loads(self.key_value_pairs).get('reaction', '')
     reaction = reaction.replace('__', '->').replace('_', '+')
     return reaction