def make_supercell(args): if args.matrix: matrix = sanitize_matrix(args.matrix) maker = SupercellMaker(args.unitcell, matrix) else: kwargs = {} if args.min_num_atoms: kwargs["min_num_atoms"] = args.min_num_atoms if args.max_num_atoms: kwargs["max_num_atoms"] = args.max_num_atoms maker = SupercellMaker(args.unitcell, **kwargs) maker.supercell.structure.to(filename="SPOSCAR") maker.supercell_info.to_json_file()
def test_sanitize_matrix_9_input_values(): actual = sanitize_matrix(list(range(9))) expected = [[0, 1, 2], [3, 4, 5], [6, 7, 8]] assert actual == expected
def test_sanitize_matrix_raise_error_for_improper_matrix_element_length(): with pytest.raises(ValueError): sanitize_matrix([1, 4])
def test_sanitize_matrix_1_input_value(): actual = sanitize_matrix([4]) expected = [[4, 0, 0], [0, 4, 0], [0, 0, 4]] assert actual == expected
def test_sanitize_matrix_3_input_values(): actual = sanitize_matrix(list(range(1, 4))) expected = [[1, 0, 0], [0, 2, 0], [0, 0, 3]] assert actual == expected