def test_iter_states(): l = list(iter_states("1-3", 2, 2, True)) assert l == [ (1, -2, 2), (1, -1, 1), (1, 0, 2), (2, -2, 1), (2, -1, 2), (2, 0, 1), (2, 1, 2), (3, -2, 2), (3, -1, 1), (3, 0, 2), (3, 1, 1), (3, 2, 2), ] l = list(iter_states("1, 6-8", 3, 1, False)) assert l == [ (1, -1, 1), (1, -1, 3), (1, 0, 2), (6, -1, 4), (6, -1, 2), (6, 0, 3), (6, 0, 5), (6, 0, 1), (6, 1, 2), (6, 1, 4), (6, 2, 1), (6, 2, 3), (6, 3, 2), (6, 3, 4), (7, -1, 3), (7, -1, 1), (7, 0, 4), (7, 0, 2), (7, 1, 3), (7, 1, 5), (7, 1, 1), (7, 2, 2), (7, 2, 4), (7, 3, 1), (7, 3, 3), (8, -1, 2), (8, 0, 3), (8, 0, 1), (8, 1, 4), (8, 1, 2), (8, 2, 3), (8, 2, 5), (8, 2, 1), (8, 3, 2), (8, 3, 4), ]
def test_iter_states(): l = list(iter_states('1-3', 2, 2, True)) assert l == [(1, -2, 2), (1, -1, 1), (1, 0, 2), (2, -2, 1), (2, -1, 2), (2, 0, 1), (2, 1, 2), (3, -2, 2), (3, -1, 1), (3, 0, 2), (3, 1, 1), (3, 2, 2)] l = list(iter_states('1, 6-8', 3, 1, False)) assert l == [(1, -1, 1), (1, -1, 3), (1, 0, 2), (6, -1, 4), (6, -1, 2), (6, 0, 3), (6, 0, 5), (6, 0, 1), (6, 1, 2), (6, 1, 4), (6, 2, 1), (6, 2, 3), (6, 3, 2), (6, 3, 4), (7, -1, 3), (7, -1, 1), (7, 0, 4), (7, 0, 2), (7, 1, 3), (7, 1, 5), (7, 1, 1), (7, 2, 2), (7, 2, 4), (7, 3, 1), (7, 3, 3), (8, -1, 2), (8, 0, 3), (8, 0, 1), (8, 1, 4), (8, 1, 2), (8, 2, 3), (8, 2, 5), (8, 2, 1), (8, 3, 2), (8, 3, 4)]
def main_input(args): # Load the template file with open(args.template) as f: template = Template(f.read()) # Loop over all atomic states and make input files for number, charge, mult in iter_states(args.elements, args.max_cation, args.max_anion, args.hund): args.program.write_input(number, charge, mult, template, args.overwrite) # Write a script that will run all computations (also those created previously) args.program.write_run_script()