Esempio n. 1
0
def check_atoms_type(atoms: ase.Atoms) -> None:
    """Check that the passed atoms object is in fact an Atoms object.
    Raises CalculatorSetupError.
    """
    if not isinstance(atoms, ase.Atoms):
        raise calculator.CalculatorSetupError(
            ('Expected an Atoms object, '
             'instead got object of type {}'.format(type(atoms))))
Esempio n. 2
0
def check_pbc(atoms: ase.Atoms) -> None:
    """Check if any boundaries are not PBC, as VASP
    cannot handle non-PBC.
    Raises CalculatorSetupError.
    """
    if not atoms.pbc.all():
        raise calculator.CalculatorSetupError(
            "Vasp cannot handle non-periodic boundaries. "
            "Please enable all PBC, e.g. atoms.pbc=True")
Esempio n. 3
0
def check_cell(atoms: ase.Atoms) -> None:
    """Check if there is a zero unit cell.
    Raises CalculatorSetupError if the cell is wrong.
    """
    if atoms.cell.rank < 3:
        raise calculator.CalculatorSetupError(
            "The lattice vectors are zero! "
            "This is the default value - please specify a "
            "unit cell.")
Esempio n. 4
0
 def make_command(self, command=None):
     """Return command if one is passed, otherwise try to find
     ASE_VASP_COMMAND, VASP_COMMAND or VASP_SCRIPT.
     If none are set, a CalculatorSetupError is raised"""
     if command:
         cmd = command
     else:
         # Search for the environment commands
         for env in self.env_commands:
             if env in os.environ:
                 cmd = os.environ[env].replace('PREFIX', self.prefix)
                 if env == 'VASP_SCRIPT':
                     # Make the system python exe run $VASP_SCRIPT
                     exe = sys.executable
                     cmd = ' '.join([exe, cmd])
                 break
         else:
             msg = ('Please set either command in calculator'
                    ' or one of the following environment '
                    'variables (prioritized as follows): {}').format(
                        ', '.join(self.env_commands))
             raise calculator.CalculatorSetupError(msg)
     return cmd