# [molpro-user] complex expressions

Kirk Peterson kipeters at wsu.edu
Tue May 29 20:46:09 BST 2012

Another option would be to try using the general function optimizer to optimize the geometry, i.e., see the minimize directive in Sec. 45 of the manual. This program will just minimize the energy (or other expression) using numerical derivatives of any variables you specify.

-Kirk

On May 29, 2012, at 10:37 AM, Peter Knowles wrote:

>> Dear Molpro users,
>>
>> I am trying to enter a complex expression as a geometrical parameter in my input for the CH3F system. It is well known that the angles of a C3V symmetric top are related by cos(b) = 1 - 3/2 sin^2(a), where in this case b is the HCH angle and a is the FCH angle.
>>
> I'm afraid that the observed behaviour is intentional.  The exact story is...
>
> 1. In the geometry optimiser, the code is able to convert the gradient of the energy with respect to cartesian coordinates into gradients with respect to variables used in the geometry definition, but only if the Z-matrix parameters are linear functions of these variables.
>
> 2. In principle, a non-linear dependence could also be detected and processed, but to do so in a completely general way with numerical stability is not so easy and has not been implemented.
>
> 3. Given that gradients are not available with respect to non-linear parameters, there is always a work around in circumstances where they are intended. The present example could be rewritten as
>
> angstrom
>
> rch = 1.087
> !!!!    ach = 110.2   -->   acos(1-1.5*(sin(108.73))^2) evaluates to 110.20
> rcf = 1.383
> acf = 108.73
> ach = acos(1-1.5*(sin(108.73))^2) ! evaluates to 110.20
>
> geometry={
> c1,
> h1,  c1,  rch;
> f1,  c1,  rcf,  h1, acf;
> ! h2,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 120.000;
> ! h3,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 240.000
> h2,  c1,  rch,  h1, ach, f1, 120.000;
> h3,  c1,  rch,  h1, ach, f1, 240.000
> }
>
> rhf
>
> It's admittedly not as elegant (you have to make sure you update ach if acf is later changed), but it works.
>
> Peter
>
> On 28 May 2012, at 16:30, LUTZ J. wrote:
>
>> My z-matrix is as follows:
>>
>> ----------------------------------------------------------------
>>
>> ***,
>> memory,100,m
>> angstrom
>>
>> geometry={
>> c1,
>> h1,  c1,  rch;
>> f1,  c1,  rcf,  h1, acf;
>> h2,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 120.000;
>> h3,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 240.000}
>>
>> rch = 1.087
>> !!!!    ach = 110.2   -->   acos(1-1.5*(sin(108.73))^2) evaluates to 110.20
>> rcf = 1.383
>> acf = 108.73
>>
>> rhf
>>
>> ----------------------------------------------------------------
>>
>> Molpro outputs the following
>>
>> ----------------------------------------------------------------
>>  ***,
>> memory,100,m
>> angstrom
>>
>> geometry={
>> c1,
>> h1,  c1,  rch;
>> f1,  c1,  rcf,  h1, acf;
>> h2,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 120.000;
>> h3,  c1,  rch,  h1, acos(1-1.5*(sin(acf))^2), f1, 240.000}
>>
>> rch = 1.087
>>                                                        !!!!    ach = 110.2    ZUNIT=ANG
>>
>> SETTING RCH            =         1.08700000
>> SETTING RCF            =         1.38300000
>> SETTING ACF            =       108.73000000
>>
>> Variable memory set to  100000000 words,  buffer space   230000 words
>>
>>
>>
>> Recomputing integrals since basis changed
>>
>>
>> Using spherical harmonics
>>
>> ? Possible error in Z matrix
>> Line                        4  connection                        2  expr=
>> ACOS(1-1.5*(SIN(ACF))^2)
>> ? Apparently depends on a variable, but not one that is yet defined
>>
>> Z matrix     Current Z-matrix
>> ========
>>
>> Records:   700.0   700.0
>> Maximum, total, and current numbers of geometry points 100   0   0
>> Orientation using atomic masses
>> Rotational constants:       0.0000000      0.0000000      0.0000000 GHz  (calculated with average atomic masses)
>> Unique atoms/degeneracy:
>>
>>   #     Tag     N1 Distance  N2 Angle     N3 Angle        J
>>   Grp   Chg     Distance     Angle        Angle                  x            y            z
>>
>>   1  1   C1
>>      1  6.0    0.0000000    0.0000000    0.0000000              0.0000000    0.0000000    0.0000000
>>   2  2   H1      1 RCH
>>      2  1.0    1.0870000    0.0000000    0.0000000              0.0000000    0.0000000    0.0000000
>>   3  3   F1      1 RCF        2 ACF
>>      3  9.0    1.3830000  108.7300000    0.0000000              0.0000000    0.0000000    0.0000000
>>   4  4   H2      1 RCH        2 ACOS(1-1   3 120.000      0
>>      2  1.0    1.0870000  110.2021617  120.0000000              0.0000000    0.0000000    0.0000000
>>   5  5   H3      1 RCH        2 ACOS(1-1   3 240.000      0
>>      2  1.0    1.0870000  110.2021617  240.0000000              0.0000000    0.0000000    0.0000000
>>
>> Variables on which Z-matrix depends:
>> Name:                RCH             RCF             ACF             RCH                                             RCF             ACF
>> Value:         0.0000000 A     0.0000000 A     0.0000000 D     0.0000000 A     0.0000000       0.0000000       0.0000000 A     0.0000000 D
>> Name:                ACF             RCH                                             RCH
>> Value:         0.0000000 D     0.0000000 A     0.0000000       0.0000000       0.0000000 A     0.0000000       0.0000000
>> ? Error
>> ? Error in Z matrix
>> ? The problem occurs in zmatrix.f:zmat_evaluate
>>
>> ERROR EXIT
>> CURRENT STACK:      MAIN
>>
>> ----------------------------------------------------------------------------------------
>>
>> When I run the job I get four command line errors:
>>
>> ERROR in 'sin(expr)' operand type mismatch
>> ERROR in 'sin(expr)' operand type mismatch
>> ERROR in 'sin(expr)' operand type mismatch
>> ERROR in 'sin(expr)' operand type mismatch
>>
>> However, it can be read from the z-matrix output above (the output, not the echo of the input) that Molpro evaluates the complex expression correctly. It seems to complain about the complex expression entry, but then evaluates it correctly!  I have no idea what could be the source of the error causing the program to abort.
>>
>> Can anyone offer a suggestion so I can proceed?
>>
>> _______________________________________________
>> Molpro-user mailing list
>> Molpro-user at molpro.net
>> http://www.molpro.net/mailman/listinfo/molpro-user
>
> --
> Prof. Peter J. Knowles
> School of Chemistry, Cardiff University, Main Building, Park Place, Cardiff CF10 3AT, UK
> Email KnowlesPJ at Cardiff.ac.uk