45 lines
1.3 KiB
Python
Executable File
45 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
from importlib.resources import files
|
|
import configparser
|
|
|
|
|
|
# --- Core function ---
|
|
def innitialize_simulation_dir(directory: Path):
|
|
os.chdir(directory)
|
|
|
|
params = configparser.ConfigParser()
|
|
params = params.read('params.ini')
|
|
|
|
template_path = files("polyamorphism_optimization.templates") / f"topology_{params['model']}.top"
|
|
TOPOLOGY = template_path.read_text()
|
|
template_path = files("polyamorphism_optimization.templates") / "mdp_parameters.mdp"
|
|
MDP_PARAMETERS = template_path.read_text()
|
|
|
|
# Write files
|
|
Path("mdp_parameters.mdp").write_text(MDP_PARAMETERS)
|
|
Path("topology.top").write_text(TOPOLOGY)
|
|
|
|
script_dir = Path(__file__).parent
|
|
subprocess.run([script_dir / "create_emin.sh"], check=True)
|
|
subprocess.run([script_dir / "create_annealing1.sh"], check=True)
|
|
|
|
print(f"finished and simulation directory {directory} created and filled")
|
|
for f in os.listdir(directory):
|
|
print(f)
|
|
|
|
# --- CLI entry point ---
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Create simulation input files.")
|
|
parser.add_argument("-d", "--directory", default=".", help="Base directory")
|
|
args = parser.parse_args()
|
|
|
|
create_simulation_dir(Path(args.directory))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|