From b3f6234bd2b561a4f6dca687303297c043699735 Mon Sep 17 00:00:00 2001 From: Jiri Janos Date: Mon, 9 Mar 2026 12:40:55 +0100 Subject: [PATCH 1/2] OPENQP Landau-Zener interface Created by Katarina Vosovicova and JJ --- interfaces/OPENQP-LZ/openqp.inp | 34 +++++++++ interfaces/OPENQP-LZ/r.openqp-lz | 126 +++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+) create mode 100644 interfaces/OPENQP-LZ/openqp.inp create mode 100644 interfaces/OPENQP-LZ/r.openqp-lz diff --git a/interfaces/OPENQP-LZ/openqp.inp b/interfaces/OPENQP-LZ/openqp.inp new file mode 100644 index 00000000..a736211c --- /dev/null +++ b/interfaces/OPENQP-LZ/openqp.inp @@ -0,0 +1,34 @@ +################################################################################## +#####################PARAMETERS FOR OPENQP-LZ DYNAMICS############################ +################################################################################## +charge=0 +basis=6-31+g* +functional=DTCAM-VAEE + +method=tdhf # hf or tdhf +type_tdhf=mrsf # type of tdhf: mrsf, sf, rpa + +type_guess=huckel # type of guess orbital: huckel, hcore +multiplicity=3 # for mrsf keep 3 +type_scf=rohf # scf type: rhf, uhf, rohf; for mrsf keep rohf + +################################################################################## +###########################ADVANCED OPTIONS####################################### +################################################################################## +# Everything is at the default value +conv=1e-6 # energy convergence criteria +init_scf=no # initial scf iteration (Hartree-Fock/Kohn-Sham): rhf, uhf, rohf, rks, uks, roks, no +maxit_scf=300 # recommendation 200+ +maxdiis=7 # maximum dimensions for DIIS converger + +mom=False # Maximum Overlap Method +mom_switch=0.003 + +vshift=0.0 + +pfon=True # Pseudo-Fractional Occupation Number Method +pfon_start_temp=2000 # initial temperature +pfon_cooling_rate=50 # temperature reduction per iteration +pfon_nsmear=5 # number of orbitals for smearing + + diff --git a/interfaces/OPENQP-LZ/r.openqp-lz b/interfaces/OPENQP-LZ/r.openqp-lz new file mode 100644 index 00000000..478afbfe --- /dev/null +++ b/interfaces/OPENQP-LZ/r.openqp-lz @@ -0,0 +1,126 @@ +#!/bin/bash + +# OPEN-QP/Landau-Zener Surface Hopping Interface for ABIN +# Created by K. Vosovicova, J. Janos +# Set parameters in 'openqp.inp' file + +cd OPENQP-LZ + +# ------------------ LOADING VARIABLES --------------------- + +source openqp.inp + +timestep=$1 +ibead=$2 +input=input$ibead.inp +geom=../geom.dat.$ibead +natom=$(wc -l < $geom) +output=input$ibead.log + +sed -i "1i ${natom}\n" "$geom" +rm -f ../engrad.dat.$ibead + +# -------------- DETERMINING CURRENT STATE ----------------- + +# Reading from state.dat +# Number of states and state we are on +read -t 2 -a nstate +read -t 2 -a tocalc +read -t 1 -a nsinglet # or doublet, just multiplicity of ground state +read -t 1 -a ntriplet # (not used) + + +# ---------------------- OPENQP INPUT ------------------------ + +cat > $input << EOF +[input] +system=$geom +charge=$charge +runtype=grad +basis=$basis +functional=$functional +method=$method + +EOF + +if [[ $timestep -eq 0 ]]; then + +cat >> $input << EOF +[guess] +type=$type_guess +save_mol=True + +[scf] +multiplicity=$multiplicity +type=$type_scf +maxit=$maxit_scf +maxdiis=$maxdiis +conv=$conv +init_scf=$init_scf +init_it=20 +init_converger=1 +vshift=$vshift +mom=$mom +mom_switch=$mom_switch + +EOF + +else + +cat >> $input << EOF +[guess] +type=json +file=input$ibead.json + +[scf] +multiplicity=$multiplicity +type=$type_scf +maxit=$maxit_scf +maxdiis=$maxdiis +conv=$conv +vshift=$vshift +mom=$mom +mom_switch=$mom_switch + +EOF + +fi + +cat >> $input << EOF +[tdhf] +type=$type_tdhf +nstate=$nstate + +[properties] +grad=$tocalc +export=True + +EOF + +# ---------------------- JOB LAUNCH ------------------------ + +export OPENQP_ROOT=/home/janos/Programs/OpenQP/openqp +export OMP_NUM_THREADS=1 +export LD_LIBRARY_PATH=$OPENQP_ROOT/lib:$LD_LIBRARY_PATH + +OPENQPEXE=/home/janos/Programs/Mambaforge/miniforge3/envs/openqp/bin/openqp + +$OPENQPEXE $input > output_file + + +# --------------------- ERROR CHECK ------------------------ + +if [[ $? -ne 0 ]] || ! $(grep -q "SCF convergence achieved" "$output") ;then + echo "WARNING from r.openqp: OPENQP calculation probably failed." + echo "See $output.error" + cp $output $output.error + exit 2 +fi + +# ------------------- DATA EXTRACTION ---------------------- + + +tail -n $nstate energies >> ../engrad.dat.$ibead +cat grad_$tocalc >> ../engrad.dat.$ibead + + From d037486cd731958c471e05402e00299c5e66d26c Mon Sep 17 00:00:00 2001 From: Jiri Janos Date: Fri, 13 Mar 2026 20:15:13 +0100 Subject: [PATCH 2/2] Modifications after revision --- interfaces/OPENQP-LZ/openqp.inp | 34 --------- interfaces/OPENQP-LZ/openqp.inp.template | 38 ++++++++++ interfaces/OPENQP-LZ/r.openqp-lz | 93 +++++------------------- 3 files changed, 57 insertions(+), 108 deletions(-) delete mode 100644 interfaces/OPENQP-LZ/openqp.inp create mode 100644 interfaces/OPENQP-LZ/openqp.inp.template diff --git a/interfaces/OPENQP-LZ/openqp.inp b/interfaces/OPENQP-LZ/openqp.inp deleted file mode 100644 index a736211c..00000000 --- a/interfaces/OPENQP-LZ/openqp.inp +++ /dev/null @@ -1,34 +0,0 @@ -################################################################################## -#####################PARAMETERS FOR OPENQP-LZ DYNAMICS############################ -################################################################################## -charge=0 -basis=6-31+g* -functional=DTCAM-VAEE - -method=tdhf # hf or tdhf -type_tdhf=mrsf # type of tdhf: mrsf, sf, rpa - -type_guess=huckel # type of guess orbital: huckel, hcore -multiplicity=3 # for mrsf keep 3 -type_scf=rohf # scf type: rhf, uhf, rohf; for mrsf keep rohf - -################################################################################## -###########################ADVANCED OPTIONS####################################### -################################################################################## -# Everything is at the default value -conv=1e-6 # energy convergence criteria -init_scf=no # initial scf iteration (Hartree-Fock/Kohn-Sham): rhf, uhf, rohf, rks, uks, roks, no -maxit_scf=300 # recommendation 200+ -maxdiis=7 # maximum dimensions for DIIS converger - -mom=False # Maximum Overlap Method -mom_switch=0.003 - -vshift=0.0 - -pfon=True # Pseudo-Fractional Occupation Number Method -pfon_start_temp=2000 # initial temperature -pfon_cooling_rate=50 # temperature reduction per iteration -pfon_nsmear=5 # number of orbitals for smearing - - diff --git a/interfaces/OPENQP-LZ/openqp.inp.template b/interfaces/OPENQP-LZ/openqp.inp.template new file mode 100644 index 00000000..5cd39252 --- /dev/null +++ b/interfaces/OPENQP-LZ/openqp.inp.template @@ -0,0 +1,38 @@ +[input] +system=geom.dat.001 +charge=0 +runtype=grad +basis=6-31+g* +functional=CAM-B3LYP +method=tdhf + +[guess] +type=huckel +save_mol=True + +[scf] +multiplicity=3 +type=rohf +maxit=300 +maxdiis=6 +conv=1e-6 +init_scf=rohf +init_it=50 +init_converger=0 +vshift=0.0 +mom=False +mom_switch=0.003 +soscf_type=0 +pfon=True +pfon_start_temp=2000 +pfon_cooling_rate=50 +pfon_nsmear=5 + +[tdhf] +type=mrsf +nstate=4 + +[properties] +grad=2 +export=True + diff --git a/interfaces/OPENQP-LZ/r.openqp-lz b/interfaces/OPENQP-LZ/r.openqp-lz index 478afbfe..842c62b5 100644 --- a/interfaces/OPENQP-LZ/r.openqp-lz +++ b/interfaces/OPENQP-LZ/r.openqp-lz @@ -2,22 +2,21 @@ # OPEN-QP/Landau-Zener Surface Hopping Interface for ABIN # Created by K. Vosovicova, J. Janos -# Set parameters in 'openqp.inp' file +# Set parameters in 'openqp.inp.template' file cd OPENQP-LZ # ------------------ LOADING VARIABLES --------------------- -source openqp.inp - timestep=$1 ibead=$2 input=input$ibead.inp -geom=../geom.dat.$ibead -natom=$(wc -l < $geom) +geom=geom.dat.$ibead +natom=$(wc -l < ../$geom) output=input$ibead.log +template=openqp.inp.template -sed -i "1i ${natom}\n" "$geom" +sed "1i ${natom}\n" "../$geom" > $geom rm -f ../engrad.dat.$ibead # -------------- DETERMINING CURRENT STATE ----------------- @@ -32,86 +31,32 @@ read -t 1 -a ntriplet # (not used) # ---------------------- OPENQP INPUT ------------------------ -cat > $input << EOF -[input] -system=$geom -charge=$charge -runtype=grad -basis=$basis -functional=$functional -method=$method - -EOF - -if [[ $timestep -eq 0 ]]; then - -cat >> $input << EOF -[guess] -type=$type_guess -save_mol=True - -[scf] -multiplicity=$multiplicity -type=$type_scf -maxit=$maxit_scf -maxdiis=$maxdiis -conv=$conv -init_scf=$init_scf -init_it=20 -init_converger=1 -vshift=$vshift -mom=$mom -mom_switch=$mom_switch - -EOF - -else - -cat >> $input << EOF -[guess] -type=json -file=input$ibead.json - -[scf] -multiplicity=$multiplicity -type=$type_scf -maxit=$maxit_scf -maxdiis=$maxdiis -conv=$conv -vshift=$vshift -mom=$mom -mom_switch=$mom_switch - -EOF +cp $template $input +if [[ $timestep -ne 0 ]]; then + sed -i '/^\[guess\]/,/^\[scf\]/c\ +[guess]\ +type=json\ +file=input001.json\ +\ +[scf]' "$input" fi -cat >> $input << EOF -[tdhf] -type=$type_tdhf -nstate=$nstate - -[properties] -grad=$tocalc -export=True +sed -i "/^\[tdhf\]/,/^\[/ s/^nstate=.*/nstate=$nstate/" "$input" -EOF +sed -i "/^\[properties\]/,/^\[/ s/^grad=.*/grad=$tocalc/" "$input" # ---------------------- JOB LAUNCH ------------------------ -export OPENQP_ROOT=/home/janos/Programs/OpenQP/openqp -export OMP_NUM_THREADS=1 -export LD_LIBRARY_PATH=$OPENQP_ROOT/lib:$LD_LIBRARY_PATH - -OPENQPEXE=/home/janos/Programs/Mambaforge/miniforge3/envs/openqp/bin/openqp +source SetEnvironment.sh OPENQ -$OPENQPEXE $input > output_file +$OPENQPEXE $input &> output_file # --------------------- ERROR CHECK ------------------------ -if [[ $? -ne 0 ]] || ! $(grep -q "SCF convergence achieved" "$output") ;then - echo "WARNING from r.openqp: OPENQP calculation probably failed." +if [[ $? -ne 0 ]] || ! grep -q "SCF convergence achieved" "$output"; then + echo "ERROR from r.openqp: OPENQP calculation probably failed." echo "See $output.error" cp $output $output.error exit 2