added setup and toml file; first preliminary script; moved templates

This commit is contained in:
Robin
2025-08-12 14:13:53 +02:00
parent 22e12c05d2
commit 3090c38694
18 changed files with 140 additions and 1 deletions

View File

View File

@@ -0,0 +1,110 @@
#!/usr/bin/env python3
import argparse
import os
import subprocess
from pathlib import Path
# --- Template definitions ---
MDP_PARAMETERS = """\
integrator = INTEGRATOR
dt = 0.001
nsteps = NSTEPS
nstcomm = 10
nstlog = NLOG
nstcalcenergy = 10
nstenergy = NENERGY
nstxout-compressed = NSTXOUT
compressed-x-precision = 1000
energygrps = system
rlist = 1.2
nstlist = 10
coulombtype = pme
rcoulomb = 1.2
coulomb-modifier = potential-shift-verlet
vdwtype = pme
rvdw = 1.2
vdw-modifier = potential-shift-verlet
fourierspacing = 0.144
tcoupl = v-rescale
tau_t = TAUT
gen_vel = yes
gen_temp = TEMP
ref_t = TEMP
tc-grps = system
pcoupl = PCOUPL
tau_p = TAUP
ref_p = PRESSURE
compressibility = 4.5e-5
nstpcouple = 10
nsttcouple = 10
"""
PARAMS_EMIN = """\
INTEGRATOR = steep
NSTEPS = 10000
NLOG = 100
NENERGY = 100
NSTXOUT = 100
TAUT = 1.0
TEMP = 300
PCOUPL = no
TCOUPL = no
TAUP = 1.0
"""
PARAMS_AN1 = """\
INTEGRATOR = md
NSTEPS = 2000000
NLOG = 1000
NENERGY = 100
NSTXOUT = 1000
TCOUPL = v-rescale
TAUT = 0.5
TEMP = 10.0
PCOUPL = c-rescale
TAUP = 1.0
"""
TOPOLOGY = """\
[ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 2 yes 1.0 1.0
[atomtypes]
;name mass charge ptype sigma epsilon
A MASS 0.000 A SIGMA_A EPSILON_A
B MASS 0.000 A SIGMA_B EPSILON_B
D 0 0.000 D 0.0 0.0
...
"""
# --- Core function ---
def create_simulation_dir(directory: Path):
directory.mkdir(parents=True, exist_ok=True)
os.chdir(directory)
# Write files
(directory / "mdp_parameters.mdp").write_text(MDP_PARAMETERS)
(directory / "params_emin.ini").write_text(PARAMS_EMIN)
(directory / "params_an1.ini").write_text(PARAMS_AN1)
(directory / "topology.top").write_text(TOPOLOGY)
# ... add the rest of your templates here ...
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()

View File

@@ -135,7 +135,7 @@ L 1
L NMOL L NMOL
EOF EOF
cat > topology.top << EOF cat > topology_atomistic.top << EOF
[ defaults ] [ defaults ]
; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ ; nbfunc comb-rule gen-pairs fudgeLJ fudgeQQ
1 2 yes 1.0 1.0 1 2 yes 1.0 1.0

24
pyproject.toml Normal file
View File

@@ -0,0 +1,24 @@
[build-system]
requires = ["setuptools>=80.0"]
build-backend = "setuptools.build_meta"
[project]
name = "polyamorphism_optimization"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = [
"pip>=25",
"wheel>=0.45",
"numpy>=2.3",
"scipy>=1.16",
"pandas>=2.3",
"mdevaluate @ git+ssh://git@gitea.pkm.physik.tu-darmstadt.de/IPKM/mdevaluate.git@feature/compatibility_robin",
]
[project.scripts]
po_setup_sim = "polyamorphism_optimization.setup_sim:main"
[tool.setuptools.package-data]
polyamorphism_optimization = ["templates/*"]

5
setup_env.sh Normal file
View File

@@ -0,0 +1,5 @@
python3.12 -m venv .venv
source .venv/bin/activate
pip install -e .
# pip install --upgrade --force-reinstall .