Compare commits
	
		
			7 Commits
		
	
	
		
			22e12c05d2
			...
			3c9edcfa74
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 3c9edcfa74 | |||
| 870dd224fc | |||
| 
						 | 
					5342dd197f | ||
| 
						 | 
					076b8d090c | ||
| 
						 | 
					2bed210ed8 | ||
| 
						 | 
					4fe2ad61a3 | ||
| 
						 | 
					3090c38694 | 
@@ -1,40 +0,0 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
get_ini_value() {
 | 
			
		||||
    local file=$1
 | 
			
		||||
    local section=$2
 | 
			
		||||
    local key=$3
 | 
			
		||||
 | 
			
		||||
    awk -F '=' -v section="$section" -v key="$key" '
 | 
			
		||||
    $0 ~ "\\[" section "\\]" { in_section = 1; next }
 | 
			
		||||
    in_section && $1 ~ "^" key"[[:space:]]*$" {
 | 
			
		||||
        gsub(/[[:space:]]+/, "", $2)
 | 
			
		||||
        print $2
 | 
			
		||||
        exit
 | 
			
		||||
    }
 | 
			
		||||
    $0 ~ /^\[/ { in_section = 0 }
 | 
			
		||||
    ' "$file"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
simdir="01_an1"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
rm -r "$simdir" 2>/dev/null
 | 
			
		||||
mkdir "$simdir"
 | 
			
		||||
 | 
			
		||||
cp topology.top "$simdir/"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini topology.top --output "$simdir/topology.top"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params_an1.ini mdp_parameters.mdp --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini "$simdir/mdp_parameters.mdp" --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
cp "$(dirname $0)/run.sh" "$simdir/"
 | 
			
		||||
cp "00_em/out/out.gro" "$simdir/gro_start.gro"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
annealing=$($(dirname $0)/generate_annealing.py -d 50 -l 50 -u 1000 -s 50 -e 2000)
 | 
			
		||||
 | 
			
		||||
#annealing=$($(dirname $0)/generate_annealing.py -d 30 -l 400 -u 950 -s 50 -e 2000)
 | 
			
		||||
 | 
			
		||||
echo "" >> "$simdir/mdp_parameters.mdp"
 | 
			
		||||
echo "$annealing" >> "$simdir/mdp_parameters.mdp"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,39 +0,0 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
get_ini_value() {
 | 
			
		||||
    local file=$1
 | 
			
		||||
    local section=$2
 | 
			
		||||
    local key=$3
 | 
			
		||||
 | 
			
		||||
    awk -F '=' -v section="$section" -v key="$key" '
 | 
			
		||||
    $0 ~ "\\[" section "\\]" { in_section = 1; next }
 | 
			
		||||
    in_section && $1 ~ "^" key"[[:space:]]*$" {
 | 
			
		||||
        gsub(/[[:space:]]+/, "", $2)
 | 
			
		||||
        print $2
 | 
			
		||||
        exit
 | 
			
		||||
    }
 | 
			
		||||
    $0 ~ /^\[/ { in_section = 0 }
 | 
			
		||||
    ' "$file"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
simdir="02_an_cooling"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
rm -r "$simdir" 2>/dev/null
 | 
			
		||||
mkdir "$simdir"
 | 
			
		||||
 | 
			
		||||
cp topology.top "$simdir/"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini topology.top --output "$simdir/topology.top"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params_an1.ini mdp_parameters.mdp --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini "$simdir/mdp_parameters.mdp" --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
cp "$(dirname $0)/run.sh" "$simdir/"
 | 
			
		||||
#cp "00_em/out/out.gro" "$simdir/gro_start.gro"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#annealing=$($(dirname $0)/generate_annealing.py -d 50 -l 180 -u 750 -e 2000 -c)
 | 
			
		||||
annealing=$($(dirname $0)/generate_annealing.py -d 20 -l 750 -u 2100 -s 50 -e 10000 -c)
 | 
			
		||||
 | 
			
		||||
echo "" >> "$simdir/mdp_parameters.mdp"
 | 
			
		||||
echo "$annealing" >> "$simdir/mdp_parameters.mdp"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1,35 +0,0 @@
 | 
			
		||||
#!/bin/bash
 | 
			
		||||
 | 
			
		||||
get_ini_value() {
 | 
			
		||||
    local file=$1
 | 
			
		||||
    local section=$2
 | 
			
		||||
    local key=$3
 | 
			
		||||
 | 
			
		||||
    awk -F '=' -v section="$section" -v key="$key" '
 | 
			
		||||
    $0 ~ "\\[" section "\\]" { in_section = 1; next }
 | 
			
		||||
    in_section && $1 ~ "^" key"[[:space:]]*$" {
 | 
			
		||||
        gsub(/[[:space:]]+/, "", $2)
 | 
			
		||||
        print $2
 | 
			
		||||
        exit
 | 
			
		||||
    }
 | 
			
		||||
    $0 ~ /^\[/ { in_section = 0 }
 | 
			
		||||
    ' "$file"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
simdir="00_em"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
rm -r "$simdir" 2>/dev/null
 | 
			
		||||
mkdir "$simdir"
 | 
			
		||||
 | 
			
		||||
cp topology.top "$simdir/"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini topology.top --output "$simdir/topology.top"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params_emin.ini mdp_parameters.mdp --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
"$(dirname $0)/replace_params.sh" params.ini "$simdir/mdp_parameters.mdp" --output "$simdir/mdp_parameters.mdp"
 | 
			
		||||
cp "$(dirname $0)/run.sh" "$simdir/"
 | 
			
		||||
cp "$(dirname $0)/templates/gro_$(get_ini_value params.ini params model).gro" "$simdir/gro_start.gro"
 | 
			
		||||
 | 
			
		||||
echo "emstep                   = 0.001" >> $simdir/mdp_parameters.mdp
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										0
									
								
								polyamorphism_optimization/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								polyamorphism_optimization/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										40
									
								
								polyamorphism_optimization/annealing.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										40
									
								
								polyamorphism_optimization/annealing.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
import shutil
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from generate_annealing import generate_annealing
 | 
			
		||||
from replace_params import replace_params
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main(root_dir: Path):
 | 
			
		||||
    simdir = root_dir / "01_an1"
 | 
			
		||||
 | 
			
		||||
    if simdir.exists():
 | 
			
		||||
        shutil.rmtree(simdir)
 | 
			
		||||
    simdir.mkdir()
 | 
			
		||||
 | 
			
		||||
    # Copy topology and replace parameters
 | 
			
		||||
    shutil.copy(root_dir / "topology.top", simdir / "topology.top")
 | 
			
		||||
    replace_params(root_dir / "params.ini", root_dir / "topology.top", simdir / "topology.top")
 | 
			
		||||
    replace_params(root_dir / "params_an1.ini", root_dir / "mdp_parameters.mdp", simdir / "mdp_parameters.mdp")
 | 
			
		||||
    replace_params(root_dir / "params.ini", simdir / "mdp_parameters.mdp", simdir / "mdp_parameters.mdp")
 | 
			
		||||
 | 
			
		||||
    # Copy run.sh
 | 
			
		||||
    shutil.copy(root_dir / "run.sh", simdir / "run.sh")
 | 
			
		||||
 | 
			
		||||
    # Generate annealing section
 | 
			
		||||
    annealing = generate_annealing(d=50, l=50, u=1000, s=50, e=2000)
 | 
			
		||||
    # -d 20 -l 750 -u 2100 -s 50 -e 10000 -c
 | 
			
		||||
    with (simdir / "mdp_parameters.mdp").open("a") as f:
 | 
			
		||||
        f.write("\n")
 | 
			
		||||
        f.write(annealing)
 | 
			
		||||
 | 
			
		||||
    print(f"Annealing directory {simdir} created and filled.")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    import sys
 | 
			
		||||
    if len(sys.argv) != 2:
 | 
			
		||||
        print(f"Usage: {sys.argv[0]} ROOT_DIRECTORY")
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    main(Path(sys.argv[1]))
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										36
									
								
								polyamorphism_optimization/emin.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										36
									
								
								polyamorphism_optimization/emin.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,36 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
import shutil
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from replace_params import replace_params
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main(root_dir: Path):
 | 
			
		||||
    simdir = root_dir / "00_em"
 | 
			
		||||
 | 
			
		||||
    if simdir.exists():
 | 
			
		||||
        shutil.rmtree(simdir)
 | 
			
		||||
    simdir.mkdir()
 | 
			
		||||
 | 
			
		||||
    # Copy topology and replace parameters
 | 
			
		||||
    shutil.copy(root_dir / "topology.top", simdir / "topology.top")
 | 
			
		||||
    replace_params(root_dir / "params.ini", root_dir / "topology.top", simdir / "topology.top")
 | 
			
		||||
    replace_params(root_dir / "params_emin.ini", root_dir / "mdp_parameters.mdp", simdir / "mdp_parameters.mdp")
 | 
			
		||||
    replace_params(root_dir / "params.ini", simdir / "mdp_parameters.mdp", simdir / "mdp_parameters.mdp")
 | 
			
		||||
 | 
			
		||||
    # Copy run.sh
 | 
			
		||||
    shutil.copy(root_dir / "run.sh", simdir / "run.sh")
 | 
			
		||||
 | 
			
		||||
    # Add finer emstep
 | 
			
		||||
    with (simdir / "mdp_parameters.mdp").open("a") as f:
 | 
			
		||||
        f.write("\n")
 | 
			
		||||
        f.write("emstep                   = 0.001")
 | 
			
		||||
 | 
			
		||||
    print(f"Energy minimization directory {simdir} created and filled.")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    import sys
 | 
			
		||||
    if len(sys.argv) != 2:
 | 
			
		||||
        print(f"Usage: {sys.argv[0]} ROOT_DIRECTORY")
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
    main(Path(sys.argv[1]))
 | 
			
		||||
							
								
								
									
										46
									
								
								polyamorphism_optimization/initialize_sim.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								polyamorphism_optimization/initialize_sim.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,46 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
import argparse
 | 
			
		||||
import os
 | 
			
		||||
import subprocess
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from importlib.resources import files
 | 
			
		||||
import configparser
 | 
			
		||||
 | 
			
		||||
from annealing import main as annealing
 | 
			
		||||
from emin import main as emin
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# --- Core function ---
 | 
			
		||||
def initialize_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)
 | 
			
		||||
 | 
			
		||||
    emin(directory)
 | 
			
		||||
    annealing(directory)
 | 
			
		||||
 | 
			
		||||
    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()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										41
									
								
								polyamorphism_optimization/replace_params.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										41
									
								
								polyamorphism_optimization/replace_params.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,41 @@
 | 
			
		||||
#!/usr/bin/env python3
 | 
			
		||||
import sys
 | 
			
		||||
import configparser
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def replace_params(param_file: Path, template_file: Path, output_file: Path):
 | 
			
		||||
    """Replace placeholders in template_file with values from an INI file."""
 | 
			
		||||
    config = configparser.ConfigParser()
 | 
			
		||||
    config.optionxform = str  # keep case sensitivity
 | 
			
		||||
    config.read(param_file)
 | 
			
		||||
 | 
			
		||||
    # Flatten into a simple dict {KEY: VALUE}
 | 
			
		||||
    params = {}
 | 
			
		||||
    for section in config.sections():
 | 
			
		||||
        for key, value in config.items(section):
 | 
			
		||||
            params[key] = value
 | 
			
		||||
 | 
			
		||||
    content = template_file.read_text()
 | 
			
		||||
 | 
			
		||||
    for key, value in params.items():
 | 
			
		||||
        content = content.replace(key, value)
 | 
			
		||||
 | 
			
		||||
    output_file.write_text(content)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def main():
 | 
			
		||||
    if len(sys.argv) != 4:
 | 
			
		||||
        print(f"Usage: {sys.argv[0]} PARAM_FILE TEMPLATE_FILE OUTPUT_FILE")
 | 
			
		||||
        sys.exit(1)
 | 
			
		||||
 | 
			
		||||
    param_file = Path(sys.argv[1])
 | 
			
		||||
    template_file = Path(sys.argv[2])
 | 
			
		||||
    output_file = Path(sys.argv[3])
 | 
			
		||||
 | 
			
		||||
    replace_params(param_file, template_file, output_file)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    main()
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								polyamorphism_optimization/templates/NPT.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								polyamorphism_optimization/templates/NPT.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
INTEGRATOR = md
 | 
			
		||||
NSTEPS = 2000000
 | 
			
		||||
NLOG = 1000
 | 
			
		||||
NENERGY = 100
 | 
			
		||||
NSTXOUT = 1000
 | 
			
		||||
TCOUPL = v-rescale
 | 
			
		||||
TAUT = 1.0
 | 
			
		||||
PCOUPL = c-rescale
 | 
			
		||||
TAUP = 1.0
 | 
			
		||||
							
								
								
									
										9
									
								
								polyamorphism_optimization/templates/NVT.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								polyamorphism_optimization/templates/NVT.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
INTEGRATOR = md
 | 
			
		||||
NSTEPS = 2000000
 | 
			
		||||
NLOG = 1000
 | 
			
		||||
NENERGY = 100
 | 
			
		||||
NSTXOUT = 1000
 | 
			
		||||
TCOUPL = v-rescale
 | 
			
		||||
TAUT = 1.0
 | 
			
		||||
PCOUPL = no
 | 
			
		||||
TAUP = 1.0
 | 
			
		||||
							
								
								
									
										31
									
								
								polyamorphism_optimization/templates/mdp_parameters.mdp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								polyamorphism_optimization/templates/mdp_parameters.mdp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										10
									
								
								polyamorphism_optimization/templates/params/annealing1.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								polyamorphism_optimization/templates/params/annealing1.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
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
 | 
			
		||||
							
								
								
									
										10
									
								
								polyamorphism_optimization/templates/params/annealing2.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								polyamorphism_optimization/templates/params/annealing2.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
INTEGRATOR = md
 | 
			
		||||
NSTEPS = 5000000
 | 
			
		||||
NLOG = 1000
 | 
			
		||||
NENERGY = 100
 | 
			
		||||
NSTXOUT = 1000
 | 
			
		||||
TCOUPL = v-rescale
 | 
			
		||||
TAUT = 0.5
 | 
			
		||||
TEMP = 10.0
 | 
			
		||||
PCOUPL = c-rescale
 | 
			
		||||
TAUP = 1.0
 | 
			
		||||
							
								
								
									
										10
									
								
								polyamorphism_optimization/templates/params/emin.ini
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								polyamorphism_optimization/templates/params/emin.ini
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,10 @@
 | 
			
		||||
INTEGRATOR = steep
 | 
			
		||||
NSTEPS = 10000
 | 
			
		||||
NLOG = 100
 | 
			
		||||
NENERGY = 100
 | 
			
		||||
NSTXOUT = 100
 | 
			
		||||
TAUT = 1.0
 | 
			
		||||
TEMP = 300
 | 
			
		||||
PCOUPL = no
 | 
			
		||||
TCOUPL = no
 | 
			
		||||
TAUP = 1.0
 | 
			
		||||
@@ -4,17 +4,18 @@
 | 
			
		||||
#SBATCH --ntasks=1
 | 
			
		||||
#SBATCH --cpus-per-task=8
 | 
			
		||||
#SBATCH --gres=gpu:1
 | 
			
		||||
#SBATCH --exclude=linux-05,linux-08,linux-02,linux-03,linux-04,linux-07
 | 
			
		||||
##SBATCH --exclude=linux-05,linux-06,linux-07,linux-08
 | 
			
		||||
 | 
			
		||||
#if [ "$(gmx --version | grep "GROMACS version")" != GROMACS*2025.2* ] ; then
 | 
			
		||||
#    echo "Version loaded is not 2025.2! Exiting!"
 | 
			
		||||
#if [ "$(gmx --version | grep "GROMACS version")" != GROMACS*2023.3* ] ; then
 | 
			
		||||
#    echo "Version loaded is not 2023.3! Exiting!"
 | 
			
		||||
#    exit 1
 | 
			
		||||
#fi
 | 
			
		||||
 | 
			
		||||
PHYS_CORES=$(lscpu | awk -F: '/Core\(s\) per socket/ {print $2+0}')
 | 
			
		||||
if [ -n "$SLURM_CPUS_PER_TASK" ]; then
 | 
			
		||||
    NT="-nt $SLURM_CPUS_PER_TASK"
 | 
			
		||||
elif [ $(nproc) -lt 9 ] ; then
 | 
			
		||||
    NT="-nt $(nproc)"
 | 
			
		||||
elif [ "$PHYS_CORES" -lt 9 ] ; then
 | 
			
		||||
    NT="-nt $PHYS_CORES"
 | 
			
		||||
else
 | 
			
		||||
    NT="-nt 8"
 | 
			
		||||
fi
 | 
			
		||||
@@ -29,7 +30,7 @@ mkdir -p "$WORKDIR/out"
 | 
			
		||||
export GMX_MAXCONSTRWARN=-1;
 | 
			
		||||
gmx -nobackup grompp \
 | 
			
		||||
    -f $WORKDIR/mdp_parameters.mdp \
 | 
			
		||||
    -o $WORKDIR/tpr_run.tpr \
 | 
			
		||||
    -o $WORKDIR/out/tpr_run.tpr \
 | 
			
		||||
    -c $WORKDIR/gro_start.gro \
 | 
			
		||||
    -r $WORKDIR/gro_start.gro \
 | 
			
		||||
    -p $WORKDIR/topology.top \
 | 
			
		||||
@@ -42,7 +43,7 @@ if [ $? != 0 ] ; then
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
gmx mdrun \
 | 
			
		||||
    -s $WORKDIR/tpr_run.tpr \
 | 
			
		||||
    -s $WORKDIR/out/tpr_run.tpr \
 | 
			
		||||
    -o $WORKDIR/out/trr_traj.trr \
 | 
			
		||||
    -c $WORKDIR/out/out.gro \
 | 
			
		||||
    -x $WORKDIR/out/xtc_traj.xtc \
 | 
			
		||||
							
								
								
									
										33
									
								
								polyamorphism_optimization/templates/top_3point.top
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								polyamorphism_optimization/templates/top_3point.top
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
[ 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
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
L  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     A   1     L  A    1    CHARGE_A      MASS 
 | 
			
		||||
2     B   1     L  B1   1    CHARGE_B      MASS 
 | 
			
		||||
3     B   1     L  B2   1    CHARGE_B      MASS 
 | 
			
		||||
 | 
			
		||||
[settles]
 | 
			
		||||
;i      funct   doh     dhh
 | 
			
		||||
1       1       D_AB     D_BB 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[exclusions]
 | 
			
		||||
1       2       3
 | 
			
		||||
2       1       3
 | 
			
		||||
3       1       2
 | 
			
		||||
 | 
			
		||||
[system]
 | 
			
		||||
 MODEL 
 | 
			
		||||
 | 
			
		||||
[molecules]
 | 
			
		||||
L                 NMOL 
 | 
			
		||||
							
								
								
									
										40
									
								
								polyamorphism_optimization/templates/top_4point.top
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								polyamorphism_optimization/templates/top_4point.top
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,40 @@
 | 
			
		||||
[ 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
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
L  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     A   1     L  A    1     0        MASS 
 | 
			
		||||
2     B   1     L  B1   1    CHARGE_B      MASS 
 | 
			
		||||
3     B   1     L  B2   1    CHARGE_B      MASS 
 | 
			
		||||
4     D   1     L  D    1    CHARGE_A      0.0
 | 
			
		||||
 | 
			
		||||
[settles]
 | 
			
		||||
;i      funct   doh     dhh
 | 
			
		||||
1       1       D_AB     D_BB 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[dummies3]
 | 
			
		||||
; Dummy from                            funct       a        b
 | 
			
		||||
4       1       2       3       1       DUMMY_AB      DUMMY_AB 
 | 
			
		||||
 | 
			
		||||
[exclusions]
 | 
			
		||||
1       2       3       4
 | 
			
		||||
2       1       3       4
 | 
			
		||||
3       1       2       4
 | 
			
		||||
4       1       2       3
 | 
			
		||||
 | 
			
		||||
[system]
 | 
			
		||||
 MODEL 
 | 
			
		||||
 | 
			
		||||
[molecules]
 | 
			
		||||
L                 NMOL 
 | 
			
		||||
							
								
								
									
										31
									
								
								polyamorphism_optimization/templates/top_atomistic.top
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								polyamorphism_optimization/templates/top_atomistic.top
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
			
		||||
[ 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 
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
A  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     A   1     L  A   1    CHARGE_A      MASS 
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
B  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     B   1     L  B   1    CHARGE_B      MASS 
 | 
			
		||||
 | 
			
		||||
[system]
 | 
			
		||||
 MODEL 
 | 
			
		||||
 | 
			
		||||
[molecules]
 | 
			
		||||
A                NMOL
 | 
			
		||||
B                NMOLB
 | 
			
		||||
							
								
								
									
										24
									
								
								pyproject.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								pyproject.toml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
			
		||||
[build-system]
 | 
			
		||||
requires = ["setuptools>=80.0"]
 | 
			
		||||
build-backend = "setuptools.build_meta"
 | 
			
		||||
 | 
			
		||||
[project]
 | 
			
		||||
name = "polyamorphism_optimization"
 | 
			
		||||
version = "0.2.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_init_sim = "polyamorphism_optimization.initialize_sim:main"
 | 
			
		||||
 | 
			
		||||
[tool.setuptools.package-data]
 | 
			
		||||
polyamorphism_optimization = ["templates/*"]
 | 
			
		||||
 | 
			
		||||
@@ -1,47 +0,0 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
set -e
 | 
			
		||||
 | 
			
		||||
if [[ $# -lt 2 ]]; then
 | 
			
		||||
    echo "Usage: $0 <params.ini> <template> [--output <output_file>]"
 | 
			
		||||
    exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
PARAMS_FILE="$1"
 | 
			
		||||
TEMPLATE_FILE="$2"
 | 
			
		||||
OUTPUT_FILE="${TEMPLATE_FILE}.out"
 | 
			
		||||
 | 
			
		||||
# Optional --output <filename>
 | 
			
		||||
if [[ "$3" == "--output" && -n "$4" ]]; then
 | 
			
		||||
    OUTPUT_FILE="$4"
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
declare -A PARAMS
 | 
			
		||||
 | 
			
		||||
# Load params.ini (ignore [section] headers)
 | 
			
		||||
while IFS='=' read -r key value; do
 | 
			
		||||
    # Trim whitespace and ignore comments/sections
 | 
			
		||||
    key="${key%%\#*}"   # remove inline comments
 | 
			
		||||
    value="${value%%\#*}"
 | 
			
		||||
    key="$(echo "$key" | xargs)"     # trim leading/trailing whitespace
 | 
			
		||||
    value="$(echo "$value" | xargs)"
 | 
			
		||||
    [[ -z "$key" || "$key" =~ ^\[.*\]$ ]] && continue
 | 
			
		||||
 | 
			
		||||
    key_upper=$(echo "$key" | tr '[:lower:]' '[:upper:]')
 | 
			
		||||
    PARAMS["$key_upper"]="$value"
 | 
			
		||||
done < "$PARAMS_FILE"
 | 
			
		||||
 | 
			
		||||
# Read template into a variable
 | 
			
		||||
template=$(<"$TEMPLATE_FILE")
 | 
			
		||||
 | 
			
		||||
# Replace placeholders (only when surrounded by spaces)
 | 
			
		||||
for key in "${!PARAMS[@]}"; do
 | 
			
		||||
    val="${PARAMS[$key]}"
 | 
			
		||||
    # Use sed to do space-surrounded substitution
 | 
			
		||||
    template=$(echo "$template" | sed -E "s/([[:space:]])$key([[:space:]])/$val/g")
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
# Save to output file
 | 
			
		||||
echo "$template" > "$OUTPUT_FILE"
 | 
			
		||||
echo "Wrote output to $OUTPUT_FILE"
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										6
									
								
								setup_env.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								setup_env.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
			
		||||
python3.12 -m venv .venv
 | 
			
		||||
source .venv/bin/activate
 | 
			
		||||
pip install -e .
 | 
			
		||||
rm -r *egg-info
 | 
			
		||||
# pip install --upgrade --force-reinstall .
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										182
									
								
								setup_sim.sh
									
									
									
									
									
								
							
							
						
						
									
										182
									
								
								setup_sim.sh
									
									
									
									
									
								
							@@ -1,182 +0,0 @@
 | 
			
		||||
#!/bin/bash -l
 | 
			
		||||
 | 
			
		||||
usage() { echo "Usage: $0 [-d basedirectory ]" 1>&2; exit 1; }
 | 
			
		||||
 | 
			
		||||
DIRECTORY="."
 | 
			
		||||
 | 
			
		||||
while getopts "d:" opt; do
 | 
			
		||||
  case $opt in
 | 
			
		||||
    d )
 | 
			
		||||
        DIRECTORY=$OPTARG
 | 
			
		||||
        ;;
 | 
			
		||||
    h )
 | 
			
		||||
        usage
 | 
			
		||||
        ;;
 | 
			
		||||
   \? )
 | 
			
		||||
        usage
 | 
			
		||||
        ;;
 | 
			
		||||
  esac
 | 
			
		||||
done
 | 
			
		||||
 | 
			
		||||
cd $DIRECTORY
 | 
			
		||||
 | 
			
		||||
#=====================================================================================
 | 
			
		||||
cat > mdp_parameters.mdp << EOF
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
#=====================================================================================
 | 
			
		||||
cat > params_emin.ini << EOF
 | 
			
		||||
INTEGRATOR = steep
 | 
			
		||||
NSTEPS = 10000
 | 
			
		||||
NLOG = 100
 | 
			
		||||
NENERGY = 100
 | 
			
		||||
NSTXOUT = 100
 | 
			
		||||
TAUT = 1.0
 | 
			
		||||
TEMP = 300
 | 
			
		||||
PCOUPL = no
 | 
			
		||||
TCOUPL = no
 | 
			
		||||
TAUP = 1.0
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
cat > params_an1.ini << EOF
 | 
			
		||||
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
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
#=====================================================================================
 | 
			
		||||
 | 
			
		||||
cat > topology.top << EOF
 | 
			
		||||
[ 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
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
L  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     A   1     L  A    1     0        MASS 
 | 
			
		||||
2     B   1     L  B1   1    CHARGE_B      MASS 
 | 
			
		||||
3     B   1     L  B2   1    CHARGE_B      MASS 
 | 
			
		||||
4     D   1     L  D    1    CHARGE_A      0.0
 | 
			
		||||
 | 
			
		||||
[settles]
 | 
			
		||||
;i      funct   doh     dhh
 | 
			
		||||
1       1       D_AB     D_BB 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
[dummies3]
 | 
			
		||||
; Dummy from                            funct       a        b
 | 
			
		||||
4       1       2       3       1       DUMMY_AB      DUMMY_AB 
 | 
			
		||||
 | 
			
		||||
[exclusions]
 | 
			
		||||
1       2       3       4
 | 
			
		||||
2       1       3       4
 | 
			
		||||
3       1       2       4
 | 
			
		||||
4       1       2       3
 | 
			
		||||
 | 
			
		||||
[system]
 | 
			
		||||
 MODEL 
 | 
			
		||||
 | 
			
		||||
[molecules]
 | 
			
		||||
L                 NMOL 
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
cat > topology.top << EOF
 | 
			
		||||
[ 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 
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
A  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     A   1     L  A   1    CHARGE_A      MASS 
 | 
			
		||||
 | 
			
		||||
[moleculetype]
 | 
			
		||||
; name nrexcl
 | 
			
		||||
B  1
 | 
			
		||||
 | 
			
		||||
[atoms]
 | 
			
		||||
; nr type resnr residu atom cgnr charge
 | 
			
		||||
1     B   1     L  B   1    CHARGE_B      MASS 
 | 
			
		||||
 | 
			
		||||
[system]
 | 
			
		||||
 MODEL 
 | 
			
		||||
 | 
			
		||||
[molecules]
 | 
			
		||||
A                1000
 | 
			
		||||
B                2000
 | 
			
		||||
EOF
 | 
			
		||||
 | 
			
		||||
#=====================================================================================
 | 
			
		||||
echo $(dirname $0)
 | 
			
		||||
bash ".$(dirname $0)/create_emin.sh"
 | 
			
		||||
bash ".$(dirname $0)/create_annealing1.sh"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#=====================================================================================
 | 
			
		||||
 | 
			
		||||
echo "finished and simulation directory $DIRECTORY created and filled"
 | 
			
		||||
ls
 | 
			
		||||
exit 0
 | 
			
		||||
		Reference in New Issue
	
	Block a user