# Loop calculation in Gaussian

I want to run multiple jobs on Gaussian using windows. I know it is possible to do so on Linux. But can we perform a loop in Gaussian with Windows?

In my calculation, I need to use the optimized geometry of geom1.log as a starting point for geom2.gjf, but sometimes I need to perform a second optimization on geom1.log and add keywords in the .gjf file to attend the convergence.

• I might be able to add an answer in a bit, but for now I'm narrowing the question down to your initial one. I think my answer will at least partially address these other points, but in general posts should have a single, focused question. A few things I want to clarify: 1. Do you need to do an arbitrary length loop or is it just a sequence of 2-3 calculations? 2. It's not clear to me why you need to do a 2nd geometry optimization (and only sometimes).
– Tyberius
Jan 28, 2022 at 14:20
• @Tyberius Yes, I need to run an arbitrary length loop. For now, I am studying ten molecules in different mediums. For each molecule, I am running a ground-state optimization calculation, which I am using afterward as a starting point for an excited state calculation. But in some cases, I don't have the four convergence criteria, so I do another optimization where I add keywords to have the minimum geometry. Jan 28, 2022 at 18:24
• How do you run the loop calculation on Linux? If the looping is done by Gaussian itself, then it should also work on Windows. However, if you are doing the looping with shell scripts, then you can either translate it to command prompt script, or use a shell emulator on windows such as Cygwin or Git shell. Jan 29, 2022 at 11:41

If the geometry optimization is failing to converge fairly often, it is probably better to not try to run the calculations automatically in sequence and to instead check on the geometry before starting the excited state calculation.

Having said that, there is a way to define a sequence of Gaussian jobs that I think could fit your use case. In a Gaussian input file, you can write multi jobs, separated by a --Link1-- header. These jobs can use information from previous steps through the check point file. So in your case, you could do something like (adding in your specific keywords and actual geometry).

%chk=initial_geom.chk
#p opt

Initial Geom Opt

0 1
H 0.0 0.0 0.0
H 0.0 0.0 1.0

%oldchk=initial_geom.chk
%chk=better_geom.chk
#p opt guess=read geom=check !additional keywords to improve convergence
!Should finish almost immediately if already converged

Better Geometry

0 1

%oldchk=better_geom.chk
%chk=excited.chk
#p guess=read geom=check !Excited state keywords

Excited calc

0 1



This should do the initial geometry optimization, then start another optimization with your keywords to ensure convergence (which should end very quickly if the calculation is already converged), and finally run an excited state calculation on this improved geometry.

If you weren't actually sure that the 2nd step would converge, you could add an arbitrary number of intermediate steps in an effort to get a converged geometry. If you really wanted something that keeps trying the optimization until it is converged, I believe you would need an external shell/python/etc script to manage the Gaussian calculations, parse their output, and determine the need for additional calculations.

However, as I mentioned, I think anything beyond the three step approach I described here would be a worse idea than just submitting all the geometry optimizations separately, manually addressing any issues for failed cases, and then submitting the excited state calculations.