Skip to content
Open
Changes from all commits
Commits
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
117 changes: 117 additions & 0 deletions GeometryOptimization/spScan.cmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Author: Kfir Kaplan
# Date : January 2026
#
# *************************************** DESCRIPTION ***********************************************
# Iterative Constraint Optimization protocol to perform torsional scans with SP energy evaluation
#
# Step 1. Run a dummy single point to initialize the geometry object (from input file).
#
# Step 2. Loop over scan steps:
# a. Calculate target angle.
# b. Perform Constrained Optimization (Opt) at the target angle using the geometry from the previous step.
# c. Perform High-Level Single Point (SP) calculation using orbitals from the Opt step.
# d. Update the geometry object for the next iteration.
#
# ------ Variables to adjust (e.g. using 'with') -------------------
Variable molecule = "input.xyz";
Variable charge = 0;
Variable mult = 1;

# Optimization Method
Variable method_opt = "UHF def2-SVP";
Variable nprocs_opt = 10;
Variable maxcore_opt = 2000;

# Single Point Method
Variable method_sp = "UHF PBE def2-SVP MORead DEFGRID3";
Variable nprocs_sp = 10;
Variable maxcore_sp = 2000;

# Scan Parameters
Variable n_steps = 30; # Total number of steps (points)
Variable angStart = -180.0;
Variable angRange = 360.0; # Total range to scan

# Dihedral Atoms (0-based indices)
Variable at1 = 2;
Variable at2 = 0;
Variable at3 = 1;
Variable at4 = 6;

Variable myFilename = "xyzInput.xyz";
# ------------------------------------------------------------------
# ------ Rest of variables -------------------
Geometry myGeom;
Variable angStep;
Variable ang;

# -----------------------------------------------------------
# Calculate step size based on n_steps
# Note: If we want to cover angRange in (n_steps-1) intervals, use n_steps-1.
# The original script did 360/44 for 45 points (0 to 44).
# -----------------------------------------------------------
angStep = angRange / (n_steps - 1.0);

# -----------------------------------------------------------
# Perform a dummy single point calculation to initialize
# myGeom from the input file.
# -----------------------------------------------------------
New_Step
! PBE def2-SVP
*xyzfile &{charge} &{mult} &{molecule}
Step_End
myGeom.Read();
myGeom.BohrToAngs();
myGeom.WriteXYZFile(filename=myFilename);

# -----------------------------------------------------------
# Start Loop over scan steps
# -----------------------------------------------------------
For idx From 0 To n_steps-1 Do
ang = angStart + idx*angStep;

# --------------------------------------------
# Optimization Step
# --------------------------------------------
New_Step
! &{method_opt}
! opt
%maxcore &{maxcore_opt}
%pal nprocs &{nprocs_opt} end
%scf MaxIter 1500 end
%geom
MaxIter 100
Constraints
{ D &{at1} &{at2} &{at3} &{at4} &{ang} C }
end
end
*xyzfile &{charge} &{mult} &{myFilename}
Step_End
Alias opt_step;

# --------------------------------------------
# Single Point Step
# --------------------------------------------
ReadMOs(opt_step);
New_Step
! &{method_sp}
%maxcore &{maxcore_sp}
%pal nprocs &{nprocs_sp} end
%scf
MaxIter 1500
# Guess MORead (Implicit via ReadMOs behavior in Compound, or explicit below)
end
# Implicitly uses geometry from previous step (opt_step)
Step_End

# --------------------------------------------
# Update geometry file for next iteration
# --------------------------------------------
myGeom.Read();
myGeom.BohrToAngs();
myGeom.WriteXYZFile(filename=myFilename);

EndFor

End