Display external forces

Dear Avogadro community,

I would like to be able to use Avogadro to plot atomic forces, since I could
not find anything about this in the archives or on the wiki I thought I
would ask it here.

There is already the ability in Avogadro to visualise forces (of the
internal force fields) during geometry optimisation.
However, I would like to be able to plot forces from an external calculation
(e.g. some other geometry optimisation or perhaps some molecular dynamics
run).
Ideally I would take some file with atoms and forces, perhaps like the
xyz-format, for example for benzene (CPMD output in a.u.)

ATOM COORDINATES GRADIENTS (-FORCES)

1 C 8.0928 7.1721 9.4669 -2.615E-05 -2.365E-05 -4.308E-07
2 C 10.7329 7.1815 9.4673 1.622E-05 -1.182E-05 -6.480E-06
3 C 12.0445 9.4724 9.4646 2.381E-05 -2.595E-05 7.109E-07
4 C 10.7165 11.7538 9.4612 -3.304E-06 4.943E-05 9.874E-07
5 C 8.0766 11.7446 9.4611 1.678E-05 -6.206E-05 6.322E-06
6 C 6.7649 9.4537 9.4639 3.416E-06 2.201E-05 1.319E-05
7 H 7.0700 5.3850 9.4693 2.226E-05 1.444E-05 5.035E-06
8 H 7.0408 13.5245 9.4587 -2.785E-05 3.492E-05 -6.664E-07
9 H 11.7687 5.4017 9.4705 9.805E-06 5.655E-07 1.481E-05
10 H 4.7053 9.4462 9.4638 1.488E-06 -9.189E-06 1.782E-06
11 H 14.1040 9.4798 9.4652 -1.552E-05 -9.837E-07 4.701E-06
12 H 11.7396 13.5409 9.4587 -1.460E-05 -2.542E-05 -6.205E-06

Then after opening the file with Avogadro I would select forces and the
forces arrows would appear!
I would like to be able to choose a color and scale for the arrows.
This way I could plot different force fields and make comparisons for
example.

Currently I plot this (if saved as ‘geo.xyz’) simply with gnuplot

gnuplot> scale=1E4

gnuplot> spl ‘geo.xyz’ u 3:4:5 w p lt 0 pt 7 t ‘atoms’, ‘’ u

3:4:5:(scale*$6):(scale*$7):(scale*$8) w vec lt 1 t ‘forces’

But of course this is quite ugly and tedious, since it lacks bonds or other
visualisation options and I cannot visualise any dynamical processes.
So my questions are the following:

  • Is there any way to do this in Avogadro already?
  • If so, what did I miss? (file-format, Avogadro version, etc.)
  • If not;
    • Could someone point me in the right direction for adding this
      feature?
      Perhaps commenting on the best (/easiest) way to implement this.
    • Is there anyone else interested in this feature??

Best regards,
Jaap

However, I would like to be able to plot forces from an external calculation (e.g. some other geometry optimisation or perhaps some molecular dynamics run).

Several file formats already support this. The code lives in Open Babel, which is responsible for reading/writing files for Avogadro.

Ideally I would take some file with atoms and forces, perhaps like the xyz-format, for example for benzene (CPMD output in a.u.)

I’m currently adding support for more solid-state computational codes to Open Babel (e.g., Abinit). Several others (VASP, DMol3) already exist. If you can send me some CPMD or other formats, I’ll see what I can do – supporting coordinates and forces is easy.

Then after opening the file with Avogadro I would select forces and the forces arrows would appear!
I would like to be able to choose a color and scale for the arrows.

Color should already be an option, but scale is a good idea. Right now, it’s part of the vibration code, but it would be easy to add to the force display too.

+ Could someone point me in the right direction for adding this feature? 
   Perhaps commenting on the best (/easiest) way to implement this.

Well, if you want to add it yourself, all you need to do is write a new format for Open Babel and add OBConformerData, which stores forces and other things for each coordinate “frame.”

Hope that helps,
-Geoff


Prof. Geoffrey Hutchison
Assistant Professor, Department of Chemistry
University of Pittsburgh


Office: (412) 648-0492

Dear prof. Hutchison,

Thank you for your response.
I have tried to add a new format following
http://openbabel.org/docs/2.3.0/WritePlugins/AddFileFormat.html
But I am stuck with perhaps a stupid question, the format is compiled but
somehow not recognized.

build$ make | grep qweformat
Scanning dependencies of target qweformat
Building CXX object src/formats/CMakeFiles/qweformat.dir/qweformat.o
Linking CXX shared module …/…/lib/qweformat.so
[100%] Built target qweformat
build$ touch test.qwe
build$ bin/babel test.qwe test.xyz

*** Open Babel Error in OpenAndSetFormat
Cannot read input format “.qwe” for file "test.qwe"
0 molecules converted
1 errors

Even though I have registered the format I think (in
src/formats/qweformat.cpp)
OBConversion::RegisterFormat(“qwe”,this);
And added a line with “qweformat” for cmake to src/formats/CMakeLists.txt.

The point where it goes wrong is "src/obconversion.cpp, line 1450"
pInFormat = FormatFromExt(InFilename.c_str());
Which returns NULL because the extension “.qwe” is apparently still not
recognized.

Is there another place where I have to ‘register’ the format?

Many thanks,
Jaap

On 23 May 2011 16:03, Geoffrey Hutchison geoff.hutchison@gmail.com wrote:

However, I would like to be able to plot forces from an external
calculation (e.g. some other geometry optimisation or perhaps some molecular
dynamics run).

Several file formats already support this. The code lives in Open Babel,
which is responsible for reading/writing files for Avogadro.

Ideally I would take some file with atoms and forces, perhaps like the
xyz-format, for example for benzene (CPMD output in a.u.)

I’m currently adding support for more solid-state computational codes to
Open Babel (e.g., Abinit). Several others (VASP, DMol3) already exist. If
you can send me some CPMD or other formats, I’ll see what I can do –
supporting coordinates and forces is easy.

Then after opening the file with Avogadro I would select forces and the
forces arrows would appear!

I would like to be able to choose a color and scale for the arrows.

Color should already be an option, but scale is a good idea. Right now,
it’s part of the vibration code, but it would be easy to add to the force
display too.

+ Could someone point me in the right direction for adding this

feature?

   Perhaps commenting on the best (/easiest) way to implement this.

Well, if you want to add it yourself, all you need to do is write a new
format for Open Babel and add OBConformerData, which stores forces and other
things for each coordinate “frame.”

Hope that helps,
-Geoff


Prof. Geoffrey Hutchison
Assistant Professor, Department of Chemistry
University of Pittsburgh
http://hutchison.chem.pitt.edu/
Office: (412) 648-0492

You should “make install” before attempting to use Open Babel. You can
do this locally if you configure CMake with
"-DCMAKE_INSTALL_PREFIX=/home/user/whatever", and then set
LD_LIBRARY_PATH appropriately.

  • Noel

On 24 May 2011 11:02, Jaap Kroes jaap.kroes@epfl.ch wrote:

Dear prof. Hutchison,

Thank you for your response.
I have tried to add a new format following
http://openbabel.org/docs/2.3.0/WritePlugins/AddFileFormat.html
But I am stuck with perhaps a stupid question, the format is compiled but
somehow not recognized.
build$ make | grep qweformat
Scanning dependencies of target qweformat
Building CXX object src/formats/CMakeFiles/qweformat.dir/qweformat.o
Linking CXX shared module …/…/lib/qweformat.so
[100%] Built target qweformat
build$ touch test.qwe
build$ bin/babel test.qwe test.xyz

*** Open Babel Error in OpenAndSetFormat
Cannot read input format “.qwe” for file "test.qwe"
0 molecules converted
1 errors
Even though I have registered the format I think (in
src/formats/qweformat.cpp)
OBConversion::RegisterFormat(“qwe”,this);
And added a line with “qweformat” for cmake to src/formats/CMakeLists.txt.
The point where it goes wrong is "src/obconversion.cpp, line 1450"
pInFormat = FormatFromExt(InFilename.c_str());
Which returns NULL because the extension “.qwe” is apparently still not
recognized.

Is there another place where I have to ‘register’ the format?

Many thanks,
Jaap

On 23 May 2011 16:03, Geoffrey Hutchison geoff.hutchison@gmail.com wrote:

However, I would like to be able to plot forces from an external
calculation (e.g. some other geometry optimisation or perhaps some molecular
dynamics run).

Several file formats already support this. The code lives in Open Babel,
which is responsible for reading/writing files for Avogadro.

Ideally I would take some file with atoms and forces, perhaps like the
xyz-format, for example for benzene (CPMD output in a.u.)

I’m currently adding support for more solid-state computational codes to
Open Babel (e.g., Abinit). Several others (VASP, DMol3) already exist. If
you can send me some CPMD or other formats, I’ll see what I can do –
supporting coordinates and forces is easy.

Then after opening the file with Avogadro I would select forces and the
forces arrows would appear!
I would like to be able to choose a color and scale for the arrows.

Color should already be an option, but scale is a good idea. Right now,
it’s part of the vibration code, but it would be easy to add to the force
display too.

+ Could someone point me in the right direction for adding this

feature?
Perhaps commenting on the best (/easiest) way to implement this.

Well, if you want to add it yourself, all you need to do is write a new
format for Open Babel and add OBConformerData, which stores forces and other
things for each coordinate “frame.”

Hope that helps,
-Geoff


Prof. Geoffrey Hutchison
Assistant Professor, Department of Chemistry
University of Pittsburgh
http://hutchison.chem.pitt.edu/
Office: (412) 648-0492


vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1


Avogadro-Discuss mailing list
Avogadro-Discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/avogadro-discuss

Even though I have registered the format I think (in src/formats/qweformat.cpp)
OBConversion::RegisterFormat(“qwe”,this);
And added a line with “qweformat” for cmake to src/formats/CMakeLists.txt.

Well, Open Babel still needs to find the compiled qweformat.so itself. You can either run “make install” to do that, or set the BABEL_LIBDIR environment variable to look at the directory with all the *format.so files.

Hope that helps,
-Geoff