Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
96ca977
Use restart forces when annealing.
mewall May 15, 2026
11565e7
Set initial force to zero during annealing
mewall Jun 1, 2026
4b86196
Added water input file for testing.
suemni Apr 15, 2026
da80ee0
Added diff changes that did not use si.
suemni Apr 15, 2026
86b4c9e
Added lines for substeps (si) in gpmdcov_mdloop.
suemni Apr 20, 2026
cb25db2
Added "si" lines for testing.
suemni Apr 22, 2026
a54b157
Commented out "if" and "endif" inside of si loop.
suemni Apr 23, 2026
87f3e1d
REmoved si code.
suemni Apr 29, 2026
8f085fe
Added new print output for mdsteps.
suemni May 4, 2026
fd8dd31
More print changes.
suemni May 5, 2026
be1897d
Make adaptive time step compatible with minimization
mewall May 5, 2026
0dc37ba
Added message to output when 2 half steps are taken.
suemni May 6, 2026
0773561
Changed message for 2 half steps.Checking criteria for mdsteps greate…
suemni May 19, 2026
096cf95
Use sedacs neighborlist
mewall May 21, 2026
9873078
Debug print_mdstep
mewall Jun 1, 2026
47ba959
Fix timestep for .pdb trajectory output
mewall Jun 1, 2026
7f62eec
Fix kappa scaling for variable timesteps
mewall Jul 1, 2026
c8d56ff
Make MDSteps control output steps at user timestep
mewall Jul 1, 2026
de4a1b4
Add script to compare energy outputs using different branches.
mewall Jul 1, 2026
7cbaf78
Implement Lagrange interpolation for XLBO with variable timesteps
mewall Jul 1, 2026
2073a7c
Merge branch 'master' into split_step
mewall Jul 1, 2026
6381508
Add script to compare gpmdk in different branches
mewall Jul 6, 2026
844b950
scripts/build_mac.sh
mewall Jul 6, 2026
23beb95
Fix dt_base bug in XLBO integration routines
mewall Jul 6, 2026
4c2f9f5
Add AdaptiveTimeStep input option to control timestep splitting
mewall Jul 6, 2026
e1daea9
Fix K=10 XLBO kappa scaling bug with adaptive timestep
mewall Jul 6, 2026
8cefc3f
Fix missing dt parameter in XLBO integration call
mewall Jul 7, 2026
82b4a9e
Prevent adaptive timesteps until XLBO history is fully built
mewall Jul 7, 2026
588af7a
Fix kappa scaling bug with interpolation
mewall Jul 7, 2026
78e32e8
Replace Lagrange with cubic spline interpolation for XLBO with fixed …
mewall Jul 7, 2026
d1f67e1
Add K=5 variable timestep coefficients for XLBO with alpha scaling
mewall Jul 7, 2026
2cbae24
Fix missing C4 and C5 coefficient lookups in K=5 variable timestep XLBO
mewall Jul 8, 2026
f590f70
Implement variable timestep Verlet integration for XLBO
mewall Jul 9, 2026
c6b5f15
Add check for early steps when dt_prev is zero
mewall Jul 9, 2026
3f266d3
Replace min-norm K=5 coefficients with fixed c_4=4.0, c_5=-1.0 normal…
mewall Jul 9, 2026
c9a8873
Merge verlet_fix: Add variable timestep Verlet integration
mewall Jul 9, 2026
1d89026
Add pattern-specific alpha values for XLBO K=5 variable timesteps
mewall Jul 9, 2026
38439a3
Use conservative alpha scaling for better stability on large systems
mewall Jul 9, 2026
61cbe1d
FIX: Remove incorrect kappa_alpha_scale from alpha dissipation term
mewall Jul 9, 2026
939cf69
Revert to d_K scaling for alpha and fix C4/C5 coefficient usage
mewall Jul 9, 2026
49e2af1
FIX: Apply d_K alpha scaling during warmup phase (steps 1-6)
mewall Jul 9, 2026
7b2152b
FIX: Use current timestep (dt) for Verlet coefficients, not xl%dt_his…
mewall Jul 9, 2026
67a98ce
FIX: Synchronize XLBO charges across MPI ranks to prevent divergence
mewall Jul 10, 2026
d650a55
DEBUG: Add rank-specific diagnostic output for MPI debugging
mewall Jul 10, 2026
32be3f8
FIX: Update print_mdstep on all MPI ranks, not just rank 1
mewall Jul 10, 2026
a279420
Use pattern-specific alpha table instead of d_K scaling formula
mewall Jul 10, 2026
ff0be2b
Clean up gpmdcov_mdloop
mewall Jul 11, 2026
3c7e989
Remove interpolation method
mewall Jul 11, 2026
259e75f
Remove extended history option, but leave K=10 coefficients for futur…
mewall Jul 11, 2026
0a616a7
Restore gpmdcov_vars from master
mewall Jul 11, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

TOP_DIR=$(readlink --canonicalize $(dirname $0))
TOP_DIR=$(readlink -f $(dirname $0))

: ${BUILD_DIR:=${TOP_DIR}/build}
: ${INSTALL_DIR:=${TOP_DIR}/install}
Expand Down
9 changes: 8 additions & 1 deletion build_scaling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ else
export CXX=${CXX:=g++}
fi

#export FFLAGS="-I$CONDA_PREFIX/lib"
#export FCFLAGS="-I$CONDA_PREFIX/lib"
#export LD_LIBRARY_FLAGS=$LD_LIBRARY_FLAGS:"$CONDA_PREFIX/lib"

export PROGRESS_MPI=no
export BML_DIR=${BML_DIR:=/Users/mewall/packages/gpmd/bml/install}
export PROGRESS_OPENMP=${PROGRESS_OPENMP:=yes}
export PROGRESS_GRAPHLIB=${PROGRESS_GRAPHLIB:=yes}
export PROGRESS_GRAPHLIB=${PROGRESS_GRAPHLIB:=no}
export PROGRESS_TESTING=${PROGRESS_TESTING:=yes}
export PROGRESS_EXAMPLES=${PROGRESS_EXAMPLES:=yes}
export CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:=Release}
export CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}:${BML_DIR}
export VERBOSE_MAKEFILE=${VERBOSE_MAKEFILE:=yes}
export COMMAND=${1:-compile}

Expand Down
311 changes: 311 additions & 0 deletions examples/gpmdk/compare_branches.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,311 @@
#!/bin/bash
#
# Compare MD simulation behavior between two branches
#
# Usage: ./compare_branches.sh <branch1> <branch2> <mdsteps> <timestep> [run_dir]
#
# Example: ./compare_branches.sh split_step xlbo_adapt 50 0.4 run/water
#

set -e

# Check arguments
if [ "$#" -lt 4 ] || [ "$#" -gt 5 ]; then
echo "Usage: $0 <branch1> <branch2> <mdsteps> <timestep> [run_dir]"
echo "Example: $0 split_step xlbo_adapt 50 0.4 run/water"
echo ""
echo "Arguments:"
echo " branch1, branch2: Git branch names to compare"
echo " mdsteps: Number of MD steps to run"
echo " timestep: Timestep in femtoseconds"
echo " run_dir: Directory containing input.in (default: run/water)"
exit 1
fi

BRANCH1="$1"
BRANCH2="$2"
MDSTEPS="$3"
TIMESTEP="$4"
RUN_SUBDIR="${5:-run/water}"

# Script is in examples/gpmdk/, so repo root is ../..
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
BUILD_DIR="${REPO_ROOT}/build"
RUN_DIR="${SCRIPT_DIR}/${RUN_SUBDIR}"
INPUT_FILE="${RUN_DIR}/input.in"

# Check that run directory exists
if [ ! -d "${RUN_DIR}" ]; then
echo "ERROR: Run directory not found: ${RUN_DIR}"
exit 1
fi

if [ ! -f "${INPUT_FILE}" ]; then
echo "ERROR: input.in not found in: ${RUN_DIR}"
exit 1
fi

# Save original branch
ORIGINAL_BRANCH=$(git rev-parse --abbrev-ref HEAD)

echo "=========================================="
echo " Branch Comparison Tool"
echo "=========================================="
echo "Branch 1: ${BRANCH1}"
echo "Branch 2: ${BRANCH2}"
echo "MD Steps: ${MDSTEPS}"
echo "TimeStep: ${TIMESTEP} fs"
echo "Run Dir: ${RUN_SUBDIR}"
echo ""

# Function to run simulation on a branch
run_branch() {
local BRANCH="$1"
local OUTPUT_FILE="$2"

echo "=========================================="
echo "Running ${BRANCH}"
echo "=========================================="

# Checkout branch
echo "Checking out ${BRANCH}..."
cd "${REPO_ROOT}"
git checkout "${BRANCH}" 2>&1 | grep -v "^M\s" || true

# Build
echo "Building ${BRANCH}..."
cd "${BUILD_DIR}"
make -j4 install > /dev/null 2>&1 || {
echo "ERROR: Build failed on ${BRANCH}"
cd "${REPO_ROOT}"
git checkout "${ORIGINAL_BRANCH}" 2>&1 | grep -v "^M\s" || true
exit 1
}

# Modify input.in
echo "Setting TimeStep=${TIMESTEP} and MDSteps=${MDSTEPS} in input.in..."
cd "${RUN_DIR}"

# Backup original input.in if not already backed up
if [ ! -f input.in.backup ]; then
cp input.in input.in.backup
fi

# Restore from backup and modify
cp input.in.backup input.in
sed -i.tmp "s/TimeStep=.*/TimeStep= ${TIMESTEP}/" input.in
sed -i.tmp "s/MDSteps=.*/MDSteps= ${MDSTEPS}/" input.in
rm -f input.in.tmp

# Run simulation
echo "Running simulation on ${BRANCH}..."
OMP_NUM_THREADS=4 "${BUILD_DIR}/gpmdk" input.in > "${OUTPUT_FILE}" 2>&1 || {
echo "ERROR: Simulation failed on ${BRANCH}"
cd "${REPO_ROOT}"
git checkout "${ORIGINAL_BRANCH}" 2>&1 | grep -v "^M\s" || true
exit 1
}

echo "${BRANCH} complete!"
echo ""
}

# Run both branches
cd "${REPO_ROOT}"
OUTPUT1="${RUN_DIR}/out_${BRANCH1}_comparison"
OUTPUT2="${RUN_DIR}/out_${BRANCH2}_comparison"

run_branch "${BRANCH1}" "${OUTPUT1}"
run_branch "${BRANCH2}" "${OUTPUT2}"

# Return to original branch
echo "Returning to ${ORIGINAL_BRANCH}..."
cd "${REPO_ROOT}"
git checkout "${ORIGINAL_BRANCH}" 2>&1 | grep -v "^M\s" || true

# Restore original input.in
if [ -f "${INPUT_FILE}.backup" ]; then
cp "${INPUT_FILE}.backup" "${INPUT_FILE}"
fi

# Analyze results
echo "=========================================="
echo " Analyzing Results"
echo "=========================================="
echo ""

cd "${RUN_DIR}"

# Export variables for Python
export BRANCH1="${BRANCH1}"
export BRANCH2="${BRANCH2}"
export TIMESTEP="${TIMESTEP}"
export MDSTEPS="${MDSTEPS}"

python << PYTHON_ANALYSIS
import numpy as np
import sys
import os

def analyze_with_splits(filename, label):
"""Analyze energy data and split-steps from output file"""
energies = []
split_steps = []

if not os.path.exists(filename):
print(f"ERROR: Output file not found: {filename}")
sys.exit(1)

with open(filename, 'r') as f:
for line in f:
if line.startswith("Mdstep, Energy"):
parts = line.split()
step = int(parts[5])
energy = float(parts[6])
energies.append((step, energy))
elif "Splitting mdstep" in line:
split_step = int(line.split()[-1])
split_steps.append(split_step)

if len(energies) == 0:
print(f"ERROR: No energy data found in {filename}")
sys.exit(1)

energy_arr = np.array([e[1] for e in energies])

e_mean = np.mean(energy_arr)
e_std = np.std(energy_arr)
e_min = np.min(energy_arr)
e_max = np.max(energy_arr)
e_drift = e_max - e_min
e_drift_pct = (e_drift / abs(e_mean)) * 100

timesteps = np.arange(len(energy_arr))
coeffs = np.polyfit(timesteps, energy_arr, 1)
slope = coeffs[0]

return {
'label': label,
'steps': len(energy_arr),
'mean': e_mean,
'std': e_std,
'drift': e_drift,
'drift_pct': e_drift_pct,
'slope': slope,
'energies': energy_arr,
'split_count': len(split_steps),
'split_range': (min(split_steps), max(split_steps)) if split_steps else (None, None)
}

# Get branch names from environment
branch1 = os.environ.get('BRANCH1', 'branch1')
branch2 = os.environ.get('BRANCH2', 'branch2')
timestep = os.environ.get('TIMESTEP', '?')
mdsteps = os.environ.get('MDSTEPS', '?')

# Analyze both outputs
data1 = analyze_with_splits(f'out_{branch1}_comparison', branch1)
data2 = analyze_with_splits(f'out_{branch2}_comparison', branch2)

# Print comparison table
print("="*75)
print(f" COMPARISON at TimeStep={timestep} fs, MDSteps={mdsteps}")
print("="*75)
print("")
print(f"{'Metric':<35} {branch1:>18} {branch2:>18}")
print("-"*75)
print(f"{'Total MD Steps':<35} {data1['steps']:>18} {data2['steps']:>18}")
print(f"{'Split-steps triggered':<35} {data1['split_count']:>18} {data2['split_count']:>18}")
if data1['split_count'] > 0:
range1 = f"{data1['split_range'][0]}-{data1['split_range'][1]}"
range2 = f"{data2['split_range'][0]}-{data2['split_range'][1]}"
print(f"{'Split-step range':<35} {range1:>18} {range2:>18}")
print("")
print(f"{'Mean Energy (eV)':<35} {data1['mean']:>18.6f} {data2['mean']:>18.6f}")
print(f"{'Std Dev (eV)':<35} {data1['std']:>18.6f} {data2['std']:>18.6f}")
print(f"{'Total Drift (eV)':<35} {data1['drift']:>18.6f} {data2['drift']:>18.6f}")
print(f"{'Drift (% of E)':<35} {data1['drift_pct']:>18.4f} {data2['drift_pct']:>18.4f}")
print(f"{'Linear Drift (eV/step)':<35} {data1['slope']:>18.6e} {data2['slope']:>18.6e}")
print("")

# Calculate differences
max_diff = np.max(np.abs(data1['energies'] - data2['energies']))
mean_diff = np.mean(np.abs(data1['energies'] - data2['energies']))
print(f"{'Maximum energy difference':<35} {max_diff:>18.6e} eV")
print(f"{'Mean absolute difference':<35} {mean_diff:>18.6e} eV")
print("")

# Conclusion
print("="*75)
print(" CONCLUSION")
print("="*75)
print("")

if data1['split_count'] > 0:
print(f"Split-steps triggered: {data1['split_count']} times", end="")
if data1['split_range'][0]:
print(f" (steps {data1['split_range'][0]}-{data1['split_range'][1]})")
else:
print()
print("")

if max_diff < 1e-10:
print("✓ Both methods produce IDENTICAL results")
elif max_diff < 1e-6:
print("✓ Both methods produce essentially identical results")
print(f" (max difference {max_diff:.2e} eV - likely numerical noise)")
elif max_diff < 0.001:
print(f"~ Methods show small differences (max {max_diff:.5f} eV)")
print(f" Mean difference: {mean_diff:.2e} eV")
else:
print(f"⚠️ Methods show measurable differences:")
print(f" Max difference: {max_diff:.5f} eV")
print(f" Mean difference: {mean_diff:.5f} eV")

print("")
print(f"Both branches maintain {'excellent' if max(data1['drift_pct'], data2['drift_pct']) < 0.01 else 'good'} energy conservation")
print(f"({branch1}: {data1['drift_pct']:.4f}%, {branch2}: {data2['drift_pct']:.4f}%)")
print("")

# Save results to file
output_file = f"comparison_{branch1}_vs_{branch2}_ts{timestep}_md{mdsteps}.txt"
with open(output_file, 'w') as f:
f.write("="*75 + "\n")
f.write(f" COMPARISON: {branch1} vs {branch2}\n")
f.write("="*75 + "\n")
f.write(f"TimeStep: {timestep} fs\n")
f.write(f"MDSteps: {mdsteps}\n")
f.write(f"Date: {os.popen('date').read().strip()}\n")
f.write("\n")
f.write(f"{'Metric':<35} {branch1:>18} {branch2:>18}\n")
f.write("-"*75 + "\n")
f.write(f"{'Total MD Steps':<35} {data1['steps']:>18} {data2['steps']:>18}\n")
f.write(f"{'Split-steps triggered':<35} {data1['split_count']:>18} {data2['split_count']:>18}\n")
if data1['split_count'] > 0:
range1 = f"{data1['split_range'][0]}-{data1['split_range'][1]}"
range2 = f"{data2['split_range'][0]}-{data2['split_range'][1]}"
f.write(f"{'Split-step range':<35} {range1:>18} {range2:>18}\n")
f.write("\n")
f.write(f"{'Mean Energy (eV)':<35} {data1['mean']:>18.6f} {data2['mean']:>18.6f}\n")
f.write(f"{'Std Dev (eV)':<35} {data1['std']:>18.6f} {data2['std']:>18.6f}\n")
f.write(f"{'Total Drift (eV)':<35} {data1['drift']:>18.6f} {data2['drift']:>18.6f}\n")
f.write(f"{'Drift (% of E)':<35} {data1['drift_pct']:>18.4f} {data2['drift_pct']:>18.4f}\n")
f.write(f"{'Linear Drift (eV/step)':<35} {data1['slope']:>18.6e} {data2['slope']:>18.6e}\n")
f.write("\n")
f.write(f"{'Maximum energy difference':<35} {max_diff:>18.6e} eV\n")
f.write(f"{'Mean absolute difference':<35} {mean_diff:>18.6e} eV\n")

print(f"Results saved to: {output_file}")
print("")
PYTHON_ANALYSIS

echo "=========================================="
echo " Comparison Complete"
echo "=========================================="
echo ""
echo "Output files:"
echo " ${OUTPUT1}"
echo " ${OUTPUT2}"
echo " comparison_${BRANCH1}_vs_${BRANCH2}_ts${TIMESTEP}_md${MDSTEPS}.txt"
echo ""
Loading