more scripting difficulties: OPTG

94 views
Skip to first unread message

Irikura, Karl K. Dr. (Fed)

unread,
Jul 8, 2021, 6:35:10 PM7/8/21
to molpro-user

Dear Molpro experts,

 

I am still struggling with scripting.  Maybe I don’t properly understand spaces, semicolons, etc. The following script fails with the error “ERROR IN POSINP: CODE HF                               NOT FOUND” after entering the OPTG command.  If I precede $method(j) with the HF command (commented out below), then the HF optimization is successful but the MP2 optimization fails with “ERROR IN POSINP: CODE MP2                              NOT FOUND.” If I remove the OPTG command, there is no problem.

 

Thanks for all the help so far!  I hope this one is easier.

 

Best regards,

Karl

 

***,scripting example: geometry optimization

 

memory,1,G;

 

$method=[hf,mp2,mp4,ccsd,ccsd(t)]

 

angstrom;

geometry={

O

H 1 oh

H 1 oh 2 a

}

oh=1.

a=104.

 

basis=cc-pvtz

 

DO J=1,#method

    K=K+1

    ! optimize geometry using method

    !hf;

    $method(J);

    optg;

    ROH(K)=OH

    ANGL(K)=A

    E(K)=energy

ENDDO

 

TABLE,METHOD,ROH,ANGL,E

 

-------------------------------------------------------------------

Dr. Karl K. Irikura

National Institute of Standards and Technology

100 Bureau Drive, mail stop 8320

Gaithersburg, MD 20899-8320

voice:  301-975-2510   fax:  301-975-3670

email:  karl.i...@nist.gov

http://www.nist.gov/mml/csd/informatics_research/index.cfm

-------------------------------------------------------------------

 

 

Hans-Joachim Werner

unread,
Jul 9, 2021, 4:06:57 AM7/9/21
to Irikura, Karl K. Dr. (Fed), molpro-user
Dear Karl,
there are 2 problems in your example:

First, you need HF before MP2, MP4, etc., since in each geometry optimization step one needs to compute new orbitals.

Second, the geometry optimizer remembers which previous commands are necessary for each energy calculation, e.g. MP2 implies HF beforehand.
It then searches in the input for these commands and executes them sequentially. However, it does not find MP2 in the input since this comes from a variable, and the program does not evaluate variables in the search. However, rather than using this automatic procedure, one can also specify a command where each energy/gradient calculation starts (startcmd). Then the program executes in each optimization step all commands between startcmd and optg.
The following works:

$method=[hf,mp2,mp4,ccsd,ccsd(t)]
DO J=1,#method
! optimize geometry using method
hf
$method(J)
optg,startcmd=hf !start each energy/gradient calculation at command hf
ROH(J)=OH
ANGL(J)=A
E(J)=energy
ENDDO
TABLE,METHOD,ROH,ANGL,E

One can do the same using:

$method=[hf,mp2,mp4,ccsd,ccsd(t)]
hf;optg;savevars
mp2;optg;savevars
mp4;optg;savevars
ccsd;optg;savevars
ccsd(t);optg;savevars

procedure savevars
j=j+1; e(j)=energy; angl(j)=a; roh(j)=oh
endproc
table,method,rhf,angl,e

In this case, the geometry optimizer remembers e.g. for ccsd(t) that it needs in each optimization step first HF, then CCSD(T), and it skips all other commands in between.

Even simpler is to use predefined procedures (optmp4 does currently not exist)
include,procedures
optscf
optmp2
optccsd
optccsdt

This automatically prints at the end a table with all computed energies. See examples attached. The procedures can be found in directory molpro_xx../lib/include

The very simplest way to run e.g. a ccsd(t) geometry optimization is
geometry=…
basis=...
run,ccsd(t)/opt

but in this case only one run command is possible (see manual, introductory examples).

Best regards
Joachim

P.S: Semicolon separates „lines“, e.g.
hf;optg
is equivalent to
hf
optg
Semicolons at the end of a line do nothing and can be omitted.

Commas separate entries on a line; blanks work as well.

You can see the input as internally used by the program by putting showinp as the very first line in the input

test1.out
test2.out
test3.out
test4.out

Irikura, Karl K. Dr. (Fed)

unread,
Jul 9, 2021, 10:03:20 AM7/9/21
to Hans-Joachim Werner, molpro-user

Dear Joachim,

 

Thank you for the help, and for the multiple solutions!  I am constantly amazed that you take the time to respond to such questions personally.

 

Best regards,

Karl




> Am 09.07.2021 um 00:28 schrieb 'Irikura, Karl K. Dr. (Fed)' via molpro-user <molpr...@googlegroups.com>:
>
> Dear Molpro experts,

> I am still struggling with scripting.  Maybe I don’t properly understand spaces, semicolons, etc. The following script fails with the error “ERROR IN POSINP: CODE HF                               NOT FOUND” after entering the OPTG command.  If I precede $method(j) with the HF command (commented out below), then the HF optimization is successful but the MP2 optimization fails with “ERROR IN POSINP: CODE MP2                              NOT FOUND.” If I remove the OPTG command, there is no problem.

> Thanks for all the help so far!  I hope this one is easier.

> Best regards,

> :qKarl



> ***,scripting example: geometry optimization

> memory,1,G;

> $method=[hf,mp2,mp4,ccsd,ccsd(t)]

> angstrom;
> geometry={
> O
> H 1 oh
> H 1 oh 2 a
> }
> oh=1.
> a=104.

> basis=cc-pvtz

> DO J=1,#method
>     K=K+1

>     ! optimize geometry using method

>     !hf;
>     $method(J);
>     optg;
>     ROH(K)=OH
>     ANGL(K)=A
>     E(K)=energy
> ENDDO

> TABLE,METHOD,ROH,ANGL,E

> -------------------------------------------------------------------
> Dr. Karl K. Irikura
> National Institute of Standards and Technology
> 100 Bureau Drive, mail stop 8320
> Gaithersburg, MD 20899-8320
> voice:  301-975-2510   fax:  301-975-3670
> email:  karl.i...@nist.gov
> http://www.nist.gov/mml/csd/informatics_research/index.cfm
> -------------------------------------------------------------------


>

> --
> You received this message because you are subscribed to the Google Groups "molpro-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to molpro-user...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/molpro-user/SA1PR09MB8688BDD40A77791407629E7EEF199%40SA1PR09MB8688.namprd09.prod.outlook.com.

Reply all
Reply to author
Forward
0 new messages