## molden2qmc

General discussion of the Cambridge quantum Monte Carlo code CASINO; how to install and setup; how to use it; what it does; applications.
Kevin_Gasperich
Posts: 7
Joined: Wed Mar 18, 2015 7:46 am

### Re: molden2qmc

...transformation of f-orbitals from cartesian to spherical still unclear...
Vladimir,

It is possible that the Cartesian LCAO-MO coefficients you import have already been scaled by some factor that makes your transformation incorrect. From your github:

Code: Select all

``````        xxx, yyy, zzz, xyy, xxy, xxz, xzz, yzz, yyz, xyz = cartesian

xr2 = xxx + xyy + xzz
yr2 = xxy + yyy + yzz
zr2 = xxz + yyz + zzz

zero = (5.0 * zzz - 3.0 * zr2) / 2.0
plus_1 = (15.0 * xzz - 3.0 * xr2)
minus_1 = (15.0 * yzz - 3.0 * yr2)
plus_2 = (xxz - yyz)
minus_2 = 2.0 * xyz
plus_3 = (xxx - 3.0 * xyy)
minus_3 = (3.0 * xxy - yyy)``````
This would be the correct transformation (to within an m,l-dependent factor) if you had imported the correctly-scaled Cartesian coefficients.

In GAMESS-US (and, I suspect, in many other programs), Cartesians within a shell will be scaled by different factors (e.g. the xy is scaled by sqrt(3) relative to x^2, xxy by sqrt(5) relative to x^3, xyz by sqrt(15) relative to x^3, etc). You will need to rescale these coefficients before performing your transformation.

You could also choose to perform the rescaling and the transformation simultaneously (as I've done in the gamess2qmc converter, shown below for f-functions), but this makes the code a bit harder to read. This lumped-together rescaling & transformation is produced by the procedure outlined here.

Code: Select all

``````#                                                            corresponding basis functions
\$f0=(2/sqrt(5)*\$zzz-\$xxz-\$yyz)/sqrt(5);          #z(5z2-3r2)
\$f1c=(4*\$zzx-3/sqrt(5)*\$xxx-\$yyx)/(6*sqrt(5));   #x(5z2-r2)
\$f1s=(4*\$zzy-3/sqrt(5)*\$yyy-\$xxy)/(6*sqrt(5));   #y(5z2-r2)
\$f2c=(\$xxz-\$yyz)/(6*sqrt(5));                    #z(x2-y2)
\$f2s=\$xyz/sqrt(60);                              #xyz
\$f3c=(\$xxx/sqrt(5)-\$yyx)/(12*sqrt(5));           #x(x2-3y2)
\$f3s=(\$xxy-\$yyy/sqrt(5))/(12*sqrt(5));           #y(3x2-y2)``````
Vladimir_Konjkov
Posts: 138
Joined: Wed Apr 15, 2015 3:14 pm

### Re: molden2qmc

Katharina Doblhoff wrote:Your conversion for the d-orbitals is working? Could you post your transformation matrix?
Thanks,
Katharina
If you know python, here is a conversion functions:
https://github.com/Konjkov/molden2qmc/b ... mc.py#L666 (works like hell )

Code: Select all

``````    def d_to_spherical(self, cartesian):
"""
Convert cartesian representation of d-orbital to spherical
http://theochem.github.io/horton/tut_gaussian_basis.html
The following order of D functions is expected:
5D: D 0, D+1, D-1, D+2, D-2
6D: xx, yy, zz, xy, xz, yz
"""
xx, yy, zz, xy, xz, yz = cartesian

r2 = xx + yy + zz

zero = zz - r2/3.0
plus_1 = 2.0 * xz
minus_1 = 2.0 * yz
plus_2 = xx - yy
minus_2 = 2.0 * xy
return zero, plus_1, minus_1, plus_2, minus_2
``````
this function takes cartesian representation of d-orbital read from MOLDEN file and convert it to spherical representation ready to write to qwfn.data file. No additional conversion ​​with the coefficients were made.
In Soviet Russia Casino plays you.
Katharina Doblhoff
Posts: 84
Joined: Tue Jun 17, 2014 6:50 am

### Re: molden2qmc

Hi Kevin!
Could you explain how you come from the vector d(spherical) to the matrix you state in your file
http://coco.sam.pitt.edu/~defusco/index ... _functions?

I would have guessed that you multiply the columns for the x^2, y^2 and z^2 Cartesians by 1/sqrt(3), which should be their normalization (1/sqrt(2*i-1)!!)*1/sqrt(2*j-1)!!*1/sqrt(2*k-1)!! for a Cartesian x^i*y^j*z^k )

Then I would have thought that you multiply each row by the m-dependent normalization factor sqrt((2-delta_{m,0})(l-abs(m))!/(l+abs(m))!), given by 1, 1/sqrt(3), 1/2/sqrt(3) for m=0, +/-1, +/-2.

Then for the d-functions I would have guessed that you also multiply each row by the factors 1/2, 3, 3, 3, 6, for m=0, 1, -1, 2, -2 which are the constant facors, which casino wants to have premultiplied to the coefficients.

But this still does not get me to the matrix you used for gamess US. Sorry, but I just do not see where you get your factors from, so I also do not understand where Vladimir gets his matrix from (which is different)

Thanks!
Kevin_Gasperich
Posts: 7
Joined: Wed Mar 18, 2015 7:46 am

### Re: molden2qmc

Hi Katharina,

Since a transformation/projection between bases is a representation of the overlap between basis functions, my thought process was to find the normalized functions in each basis and then to calculate the overlap between pairs of basis functions.

To simplify things, I normalize the same type of function for all shells.
Some programs will normalize the m=0 spherical function with the smallest possible integer coefficients, others will normalize some other Cartesian or spherical function; I thought it simplest to normalize the x^2 Cartesian for the d-shell, x^3 for f, x^4 for g, etc. This may seem strange for calculations in a spherical basis (where this normalization coefficient might not actually normalize any of the simplified basis functions), but it's the most straightforward and unambiguous method I could come up with.

Given this normalization, the normalized Cartesian and spherical functions are as given on the wiki page.

To produce the transformation matrix (i.e. calculate the overlap between functions), first take the outer product (Cij=Ai Bj) of the Cartesian and spherical vectors. This will yield a matrix of polynomials in x,y,z.

Multiply the matrix by the given normalization constant (squared) and multiply by the Gaussian part of the function [exp(-2a(x**2+y**2+z**2))]. Integrate each of these matrix elements over all of space to obtain the overlap between any two functions.

We've already done the tricky bit of scaling the different Cartesian functions appropriately (this was implicit in the normalization procedure above). Now all that remains is to account for m-dependent factors and for the scale factors that CASINO assumes have been multiplied into d-functions.

As you've pointed out, these are [1, 1/sqrt(3), 1/sqrt(3), 1/(2*sqrt(3)), 1/(2*sqrt(3))] and [1/2, 3, 3, 3, 6] for m=[0,1,-1,2,-2]. The transformation matrix should now be equal to the one in the GAMESS-US converters (internal and gamess2qmc).

For the f-shell, the only difference is that CASINO doesn't expect any extra factors to be pre-multiplied into the functions, so the f transformation matrix is simply the overlap matrix scaled by m-dependent factors.

I hope this helps.

Kevin
Katharina Doblhoff
Posts: 84
Joined: Tue Jun 17, 2014 6:50 am

### Re: molden2qmc

Hi Kevin!
Sorry, I still don't get it. I try to reconstruct the first row of the d-transformation matrix.
So I multiply -1/2x^2-^/2y^2*z^2 with x^2, y^2, z^2, sqrt(3)xy, sqrt(3)xz, sqrt(3)yz and integrate over x,y,z.

The integral over x^(2i) y^(2j) z^(2k) is given by (2*alpha/pi)^(3/2)*(4*alpha)^(i+j+k)/(2i-1)!!/(2j-1)!!/(2k-1)!!, correct?!
all other integrals are zero due to symmetry.

So the first row of the outer product is
a a b 0 0 0,
where a=(2*alpha/pi)^(3/2)*(4*alpha)^2*(-1/2*1/3-1/2+1)=(2*alpha/pi)^(3/2)*(4*alpha)^2*1/3
and b=(2*alpha/pi)^(3/2)*(4*alpha)^2*(-1/2-1/2+1/3)=(2*alpha/pi)^(3/2)*(4*alpha)^2*1/3*(-2)

so with you normalization to (2*alpha/pi)^(3/2)*(4*alpha)^2*1/3 this gives
1 1 -2 0 0 0.

So where does the -1/6 come from? (you have -1/6 -1/6 1/3). Am I miscalculating somewhere?
Vladimir_Konjkov
Posts: 138
Joined: Wed Apr 15, 2015 3:14 pm

### Re: molden2qmc

Hi, Katharina.

I'm not saying that the conversion of CFOUR d-orbitals is 100% correct.
I'm trying to come up with a reliable test to check it.

Obviously, the conversion should consist of 3 steps:
1. "Appropriate" denormalization of cartesian coefficients
2. Cartesian to spherical conversion
3. "Appropriate" normalization of spherical coefficients

Appropriate means that we properly take into account m-dependent, m-independent and legacy normalisation coefficients.
For example, I do not know what is the value of m-independent normalisation coefficients in CFOUR output.

I've trying single C atom with only one d-orbital, and I found that ORCA rotate degenerate spherical orbitals somehow.
So direct comparison of MO-cofficients between CFOUR and ORCA fails.
In Soviet Russia Casino plays you.
Kevin_Gasperich
Posts: 7
Joined: Wed Mar 18, 2015 7:46 am

### Re: molden2qmc

Katharina,

I think your problem occurs in the integration.

Let's just consider the first row of the transformation matrix for now. This is the m=0 spherical [1/2(-x^2-y^2+2*z^2)].

The integral for the first element should be N^2 Int[x^2*1/2*(-x^2-y^2+2*z^2)*Exp[-2*a(x^2+y^2+z^2)] dx dy dz].
We can consider this in three parts: the x^4 term, the x^2*y^2, and the x^2*z^2 (the latter two being equivalent)
N already normalizes the x^2 function, so the x^4 integral is equal to 1.
N does not normalize the xy or xz functions, so each of those integrals is equal to 1/3.

This element is equal to 1/2*(-1 - 1/3 + 2/3) = -1/3
The second element in this row will be 1/2*(-1/3 - 1 + 2/3) = -1/3
The third will be 1/2*(-1/3 - 1/3 + 2) = 2/3

This row is now equal to the following:
-1/3 -1/3 2/3 0 0 0

The row must now be multiplied by the m-dependent factor (1) and by the factor that CASINO assumes is pre-multiplied into the m=0 function (1/2)

The row is now equal to the following:
-1/6 -1/6 1/3 0 0 0

This is the first row of the transformation matrix.
Vladimir_Konjkov
Posts: 138
Joined: Wed Apr 15, 2015 3:14 pm

### Re: molden2qmc

Converter for ORCA molden files is ready for RHF all-electron case.

It passed the following tests:
d-ane - check if the conversion of d-orbitals valid up to an arbitrary constant.
f-ane - check if the conversion of f-orbitals valid up to an arbitrary constant.
g-ane - check if the conversion of g-orbitals valid up to an arbitrary constant.
sd-ane, sf-ane, sg-ane - check that the conversion of all MO-coefficients simultaneously
valid up to an arbitrary common constant.

test results are in the repository: https://github.com/Konjkov/molden2qmc/t ... /test/ORCA

For several basis from https://bse.pnl.gov/bse/portal check if GTO contraction coefficients in qwfn.data
normalised for (the whole contraction) * (m-independent part for individual primitives).

Also the differences between the definitions of Orca's solid harmonics and the purple book ones
discussed in https://orcaforum.cec.mpg.de/viewtopic.php?f=8&t=1484

I think that after the completion of the CFOUR, PSI4 and Turbomole parts of molden2qmc, I can write a code for
unrestricted and pseudopotential which to be similar for all of them (IMHO).

with respect, Vladimir.
In Soviet Russia Casino plays you.
Vladimir_Konjkov
Posts: 138
Joined: Wed Apr 15, 2015 3:14 pm

### Re: molden2qmc

There is something strange in MOLDEN file generated in version 2.0 CFOUR.
As mentioned in the http://people.smu.edu/wzou/program/ CFOUR has brocken reorderdf.F procedure.

When g-orbitals present in molecule, all d,f-oribital, except of first atom has wrong order:
(xx, xy, xz, yy, yz, zz) instead of (xx, yy, zz, xy, xz, yz) for d-orbitals and
(xxx, xxy, xxz, xyy, xyz, xzz, yyy, yyz, yzz, zzz) instead of (xxx, yyy, zzz, xyy, xxy, xxz, xzz, yzz, yyz, xyz) for f-orbitals and
g-orbitals always has wrong order (xxxx, xxxy, xxxz, xxyy, xxyz, xxzz, yyyx, yyxz, zzxy, zzzx, yyyy, yyyz, yyzz, zzzy, zzzz).

I'll try to fix it but can not guarantee that it will work in all situations.

P.S.
I think that use of a fixed reorderdf.F is the best solution (it requires recompiling), but I can't create the script that distinguish fixed MOLDEN file from non-fixed one.
http://people.smu.edu/wzou/program/reorderdf.zip

P.P.S.
In any case, if the molecule has no g- orbitals all works fine, or if it has a g-orbitals but no d- and f-...as in g-ane TEST all works fine again.
In Soviet Russia Casino plays you.
Mike Towler
Posts: 237
Joined: Thu May 30, 2013 11:03 pm
Location: Florence
Contact:

### Re: molden2qmc

Hi Vladimir,

OK - to me it sounds that from the CASINO perspective the best way to fix this is as follows:

(1) Make sure that the CASINO documentation (manual plus the stuff on the website) is absolutely clear about the need to
recompile Cfour - having added in the modified reorderedf.f routine - before its output can be used to generate a CASINO wave function file.

(2) We further modify the downloadable modified reorderedf.f routine so that it writes 'THIS FILE HAS BEEN MODIFIED' (or words to that effect) into the Cfour molden output file. We include this 'reorderedf2.f' routine in the utils/wfn_converters/cfour directory of the CASINO distribution. This assumes we can get permission to do so, and I don't see why not as it's only a 47 line bit of Fortran which makes their program give the right answer.

(3) When CASINO's molden2qmc reads a Cfour-produced molden file, it checks for a 'THIS FILE HAS BEEN MODIFIED' string and refuses to run unless it can find one.

The only issue with this is if the error is only in certain versions of Cfour - is that the case? If so, it would be helpful if the Cfour molden output contained version information. I'm guessing it doesn't?

Mike