<gh_stars>0
#!/usr/bin/env python

import argparse
import itertools
import os
import shutil


def write_reg_input(model_type, order, maxl_list):
    """Write input file for mlptools/mlpgen/regression.py

    Args:
        model_type (str): Type of polynomial model
        order (str): Order of invariants
        maxl_list (list of str): List of maxl for each invariants order
    """
    content = """\
n_type 1
with_force True
with_stress False
reg_method ridge
alpha_min -6.0
alpha_max -2.0
n_alpha 5
des_type gtinv
pair_type gaussian
gaussian_params1 1.0 1.0 1
gaussian_params2 1.0 5.0 10
cutoff 6.0
model_type {model_type}
max_p 2
gtinv_order {order}
gtinv_maxl {maxl_list}
gtinv_sym {gtinv_sym}
train_data vaspruns/train_vasprun_Fe
train_data_force True
train_data_weight 1.0

test_data vaspruns/test_vasprun_Fe
test_data_force True
test_data_weight 1.0

atomic_energy -3.37689
    """.format(
        model_type=model_type,
        order=order,
        maxl_list=" ".join(maxl_list),
        gtinv_sym=" ".join(["False"] * len(maxl_list)),
    )
    return content


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "model_type",
        choices=[str(i + 1) for i in range(4)],
        help="Type of polynomial model",
    )
    args = parser.parse_args()

    home_dir = os.getenv("HOME")
    root_dir = home_dir + "/mlp-Fe/nostress/model{}-2/".format(args.model_type)
    os.makedirs(root_dir)
    os.chdir(root_dir)

    maxl_uppers = [20, 10]
    gtinv_order = "2"
    os.mkdir(gtinv_order)
    os.chdir(gtinv_order)
    for i in map(str, range(maxl_uppers[0] + 1)):
        os.mkdir(i)
        os.chdir(i)
        with open("train.in", "w") as f:
            s = write_reg_input(
                model_type=args.model_type, order=gtinv_order, maxl_list=[i]
            )
            f.write(s)
        shutil.copytree(home_dir + "/mlp-Fe/input/vaspruns/", "./vaspruns/")
        os.chdir("../")
    os.chdir("../")

    gtinv_order = "3"
    os.mkdir(gtinv_order)
    os.chdir(gtinv_order)
    for i in itertools.product(
        map(str, range(maxl_uppers[0] + 1)), map(str, range(maxl_uppers[1] + 1))
    ):
        dir_name = "-".join(i)
        os.mkdir(dir_name)
        os.chdir(dir_name)
        with open("train.in", "w") as f:
            s = write_reg_input(
                model_type=args.model_type, order=gtinv_order, maxl_list=list(i)
            )
            f.write(s)
        shutil.copytree(home_dir + "/mlp-Fe/input/vaspruns/", "./vaspruns/")
        os.chdir("../")
    os.chdir("../")

#!/usr/bin/env python

import argparse
import itertools
import os
import shutil


def write_reg_input(model_type, order, maxl_list):
    """Write input file for mlptools/mlpgen/regression.py

    Args:
        model_type (str): Type of polynomial model
        order (str): Order of invariants
        maxl_list (list of str): List of maxl for each invariants order
    """
    content = """\
n_type 1
with_force True
with_stress False
reg_method ridge
alpha_min -6.0
alpha_max -2.0
n_alpha 5
des_type gtinv
pair_type gaussian
gaussian_params1 1.0 1.0 1
gaussian_params2 1.0 5.0 10
cutoff 6.0
model_type {model_type}
max_p 2
gtinv_order {order}
gtinv_maxl {maxl_list}
gtinv_sym {gtinv_sym}
train_data vaspruns/train_vasprun_Fe
train_data_force True
train_data_weight 1.0

test_data vaspruns/test_vasprun_Fe
test_data_force True
test_data_weight 1.0

atomic_energy -3.37689
    """.format(
        model_type=model_type,
        order=order,
        maxl_list=" ".join(maxl_list),
        gtinv_sym=" ".join(["False"] * len(maxl_list)),
    )
    return content


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "model_type",
        choices=[str(i + 1) for i in range(4)],
        help="Type of polynomial model",
    )
    args = parser.parse_args()

    home_dir = os.getenv("HOME")
    root_dir = home_dir + "/mlp-Fe/nostress/model{}-2/".format(args.model_type)
    os.makedirs(root_dir)
    os.chdir(root_dir)

    maxl_uppers = [20, 10]
    gtinv_order = "2"
    os.mkdir(gtinv_order)
    os.chdir(gtinv_order)
    for i in map(str, range(maxl_uppers[0] + 1)):
        os.mkdir(i)
        os.chdir(i)
        with open("train.in", "w") as f:
            s = write_reg_input(
                model_type=args.model_type, order=gtinv_order, maxl_list=[i]
            )
            f.write(s)
        shutil.copytree(home_dir + "/mlp-Fe/input/vaspruns/", "./vaspruns/")
        os.chdir("../")
    os.chdir("../")

    gtinv_order = "3"
    os.mkdir(gtinv_order)
    os.chdir(gtinv_order)
    for i in itertools.product(
        map(str, range(maxl_uppers[0] + 1)), map(str, range(maxl_uppers[1] + 1))
    ):
        dir_name = "-".join(i)
        os.mkdir(dir_name)
        os.chdir(dir_name)
        with open("train.in", "w") as f:
            s = write_reg_input(
                model_type=args.model_type, order=gtinv_order, maxl_list=list(i)
            )
            f.write(s)
        shutil.copytree(home_dir + "/mlp-Fe/input/vaspruns/", "./vaspruns/")
        os.chdir("../")
    os.chdir("../")
#!/usr/bin/env python Write input file for mlptools/mlpgen/regression.py      Args:         model_type (str): Type of polynomial model         order (str): Order of invariants         maxl_list (list of str): List of maxl for each invariants order \ n_type 1 with_force True with_stress False reg_method ridge alpha_min -6.0 alpha_max -2.0 n_alpha 5 des_type gtinv pair_type gaussian gaussian_params1 1.0 1.0 1 gaussian_params2 1.0 5.0 10 cutoff 6.0 model_type {model_type} max_p 2 gtinv_order {order} gtinv_maxl {maxl_list} gtinv_sym {gtinv_sym} train_data vaspruns/train_vasprun_Fe train_data_force True train_data_weight 1.0  test_data vaspruns/test_vasprun_Fe test_data_force True test_data_weight 1.0  atomic_energy -3.37689