Multiwfn forum

Multiwfn official website: http://sobereva.com/multiwfn. Multiwfn forum in Chinese: http://bbs.keinsci.com/wfn

You are not logged in.

#1 2024-10-03 19:51:32

Amin
Member
Registered: 2024-10-03
Posts: 3

Multiwfn gradient question

Hello,

I am a big fan of your work and use it constantly. Thank you for all your hard work!

I have recently come across an issue of my own. I need a compute the gradient components of the electron density (grad_x, grad_y, grad_z) on and input grid I feed into Multiwfn. I am have tried going through the "Modifying source code
of Multiwfn" and am trying to build Multiwfn from source after adding the following userfunc:

case (6000)
    userfunc=fgrad(x,y,z,'x')
case (6001)
    userfunc=fgrad(x,y,z,'y')
case (6002)
    userfunc=fgrad(x,y,z,'z')

However since this is all new to me I am coming across some errors. Hopefully I can figure this out soon. However this would be a little inefficient form my needs as I will potentially be processing thousands of grids at a given instance. I want to avoid creating 3 separate grid files per grid file.
I am a little unclear on how to add my own functions for your pdf. I am trying to figure this out. I have two questions here.

1) Do you have any more tutorials that might go a little more in depth about modifying Multiwfn source code?
2) Is there an already existing function that I am unaware of that can out put the x, y, z, grad_x, grad_y, grad_z?

Thank you for your time

Offline

#2 2024-10-03 19:58:52

sobereva
Tian Lu (Multiwfn developer)
From: Beijing
Registered: 2017-09-11
Posts: 1,830
Website

Re: Multiwfn gradient question

Hello,

I don't exactly know what problem you're having... Your code is correct, after recompiling, Multiwfn will be able to calculate X,Y,Z gradient components of electron density using your user-defined functions 6000, 6001, 6002, respectively.

As for "I want to avoid creating 3 separate grid files per grid file.", I don't know why you do not hope to create three cube files. Gradient is a vector, while cube file normally records scalar functions, so it is very common to record its different components as different cube files.

Offline

#3 2024-10-03 20:17:17

Amin
Member
Registered: 2024-10-03
Posts: 3

Re: Multiwfn gradient question

Hello,

I just cant seem to compile the file. I keep getting errors during the make process. I am trying to figure out how to resolve this.

I want to avoid making three files as I will be doing my own processing on the information. It would simplify my workflow by limiting I/O operations by putting all information into one file per instance of Multiwfn running. If this isn't possible then I will stick to trying to get the previous functions to run.

I am curious if there another way to script getting this information from Main function menu, function 1 where you get  "Components of gradient in x/y/z are:"

Thank you for the quick response last time.

Offline

#4 2024-10-03 20:53:47

Amin
Member
Registered: 2024-10-03
Posts: 3

Re: Multiwfn gradient question

I see what you mean by cube files. I am not dealing with cube files, i am exporting as a .txt file.

Offline

#5 2024-10-03 22:15:36

sobereva
Tian Lu (Multiwfn developer)
From: Beijing
Registered: 2017-09-11
Posts: 1,830
Website

Re: Multiwfn gradient question

If you have large amount of grids to be calculated, I suggest writing a subroutine and call it in proper place (for example, you can add a new option in main menu by modifying Multiwfn.f90 to call it). The content of the subroutine could be, e.g.:

open(11,file="grad.txt",status="replace")
do i=1,ngrid
  write(11,"(6f16.8)") gridx(i),gridy(i),grid(z),fgrad(gridx(i),gridy(i),grid(z),'x'),fgrad(gridx(i),gridy(i),grid(z),'y'),fgrad(gridx(i),gridy(i),grid(z),'z')
end do
close(11)

where gridx(i), gridy(i), gridz(i) are Cartesian coordinate components of grid i in Bohr.

After calling this subroutine, you will obtain grad.txt, which contains coordinate of every grid and gradient components.

Offline

Board footer

Powered by FluxBB