def test_write_incar(tmpdir, incar_dict): """Test writing and INCAR file from an IncarIo object.""" incar_io = IncarIo(incar_dict=incar_dict) tempfile = str(tmpdir.join('INCAR')) incar_io.write(tempfile) assert read_file(path=tempfile) == str(incar_io)
def test_from_string(): """Test reading from string.""" test_str = 'TRUE = .True\nFALSE=.f.' incar_io = IncarIo() incar_io.read_string(test_str) incar_dict = incar_io.get_dict() assert incar_dict.pop('true') is True assert incar_dict.pop('false') is False assert not incar_dict
def test_read_incar(): """Read an INCAR file and test that some of the keys are read correctly.""" incar_path = data_path('phonondb', 'INCAR') incar_io = IncarIo(file_path=incar_path) incar_dict = incar_io.get_dict() assert incar_dict['prec'] == 'Accurate' assert incar_dict['ibrion'] == -1 assert incar_dict['encut'] == 359.7399 assert incar_dict['lreal'] is False
def vasp_params(aiida_env): incar_io = IncarIo( incar_dict={ 'gga': 'PE', 'gga_compat': False, 'lorbit': 11, 'sigma': 0.5, 'magmom': '30 * 2*0.' }) return incar_io.get_param_node()
def write_incar(self, inputdict, dst): # pylint: disable=unused-argument """ Converts from parameters node (ParameterData) to INCAR format and writes to dst. Unless otherwise specified, the values specified in _DEFAULT_PARAMETERS are also written to the INCAR file. :param inputdict: required by baseclass :param dst: absolute path of the file to write to """ incar_dict = ChainMap(self.inp.parameters.get_dict(), self._DEFAULT_PARAMETERS) incar_io = IncarIo(incar_dict=incar_dict) incar_io.write(dst)
def test_from_dict(incar_dict): incar_io = IncarIo(incar_dict=incar_dict) ref_str = '\n'.join( sorted([ 'ENCUT = 350', 'SIGMA = 0.05', 'LREAL = .False.', 'PREC = Accurate' ])) assert str(incar_io) == ref_str
def test_write_incar(self): """Check that INCAR is written correctly""" calc = self._get_calc('s', 'm') inp = calc.get_inputs_dict() calc.write_incar(inp, self.tmpf) icp = IncarIo(self.tmpf) for key, value in calc.inp.parameters.get_dict().iteritems(): self.assertIn(str(value), icp.incar_dict[key])
def test_example_incar(): """Read a pathological case of an INCAR file (top level example from VASP docs).""" incar_path = data_path('incar_set', 'INCAR.copper_srf') incar_io = IncarIo(file_path=incar_path) incar_dict = incar_io.get_dict() assert incar_dict['system'] == 'Copper surface calculation' assert incar_dict['istart'] == 0 assert isinstance(incar_dict['istart'], int) assert incar_dict['encut'] == 200.01 assert isinstance(incar_dict['encut'], float) assert incar_dict['bmix'] == 2.0 assert isinstance(incar_dict['bmix'], float) assert incar_dict['nelmin'] == 0 assert incar_dict['nelmdl'] == 3