5
$\begingroup$

How can I visualize the geometry optimization? I want to see the plot of potential energy through various iterations to reach the minimum value. I would also like to see the animation of the atoms being moved. I have here an example code for geometry optimization. Can someone help me with the visualization?

import ase.io
import ase.build
from ase.visualize import view
from ase.optimize import BFGS
import numpy as np
from ase.calculators.emt import EMT

water = ase.build.molecule('H2O',calculator=EMT())
opt = BFGS(water,trajectory ='H2O.traj')
opt.run(fmax=0.05)

And this was the result:

     Step     Time          Energy         fmax

BFGS:    0 12:18:19        2.619811        7.7384
BFGS:    1 12:18:19        1.912906        1.3454
BFGS:    2 12:18:19        1.882033        0.4035
BFGS:    3 12:18:19        1.879275        0.0317

In the documentation i read that ase gui can do this. But i tried it in this way:

ase gui H2O.traj

However i am getting an error: Invalid syntax

$\endgroup$
4
  • 1
    $\begingroup$ Where do you type that line: "ase gui H2O.traj" ? Could you attach the whole error message with the command that couses it? $\endgroup$
    – user36313
    Commented Jan 1 at 18:59
  • $\begingroup$ @user36313 I typed it in the command prompt. This line 'ase gui H2O.traj' i typed right after the calculation in the command prompt. Is it wrong? $\endgroup$ Commented Jan 1 at 19:18
  • $\begingroup$ Was it a Python or a shell prompt? Because the error doesn't look like a shell error $\endgroup$
    – user36313
    Commented Jan 1 at 19:32
  • $\begingroup$ I am new to python. So i opened command prompt using cmd. And then i typed python and hit enter and did the above mentioned activities. So i am assuming this is python now and not shell prompt. $\endgroup$ Commented Jan 1 at 20:45

1 Answer 1

4
$\begingroup$

The ase gui command is a shell command. So you should type it not to the Python prompt (usually looks like >>> ), but to the shell prompt (may look like C:\> ). If you prefer to run visualizer directly from Python, then you should add to your code something like this:

traj = ase.io.read('H2O.traj', index=':')
view(traj)

$\endgroup$
1
  • $\begingroup$ Thank you very much. It works now! $\endgroup$ Commented Jan 2 at 8:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .