[ase-users] [ase-developers] ASE calculator interface proposal

John Kitchin jkitchin at andrew.cmu.edu
Fri Feb 1 18:35:45 CET 2013


>
> I'm not sure about this example:
>
> >>> atoms = ...
> >>> calc = ABC('si.abc', atoms, xc='LDA')
> >>> atoms.get_potential_energy()
> -1.2
>
> What is the purpose of specifying an Atoms object to the calculator if
> a new Atoms object is read from the file?


The point here is the choice (in my opinion) between:
Case 1:
>>> atoms = ...
>>> calc = ABC('si.abc', atoms, xc='LDA')
>>> atoms.get_potential_energy()

which can be typed as many times as you want, and a calculation is only
ever run once, and you always get the result from the file.  (to change the
atoms after creating the calculator you would have to do this:

>>> atoms = ...                                           # this may be a
hard-coded initial guess
>>> calc = ABC('si.abc', atoms, xc='LDA')     # the updates atoms with what
is in teh file
>>> atoms[0].x = new_value                         # now atoms and
calculator are out of sync
>>> atoms.get_potential_energy()                 # so a new calculation is
run here.


and  Case 2:
run script:
 >>> atoms = ...
>>> calc = ABC('si.abc', atoms, xc='LDA')
>>> atoms.get_potential_energy()

Now, if atoms is not updated from 'si.abc' every time you run this script,
it will rerun the calculation, so a separate analysis script is needed.

and separate analysis script
>>> calc = read('si.abc')
>>> atoms = calc.get_atoms()
>>> atoms.get_potential_energy()

I like Case1 behavior better, because it eliminates the need to write a
second script, and fits my workflow especially nicely. These are two
different workflows with various merits and demerits. In favor of case 1 is
the elimination of extra scripting and keeping it all together in one
place. In favor of Case 2 is the significantly reduced code behind the
scenes to do the right thing all the time, and reduced possibilities of
triggering a calculation on rerunning the script (since it should only be
reading data).

j




>
> 2013/2/1 Jens Jørgen Mortensen <jensj at fysik.dtu.dk>:
> > Den 01-02-2013 12:20, Max Hoffmann skrev:
> >> Dear All,
> >>
> >> I have a question regarding [1], where is says "The read_atoms()
> >> method is equivalent to:"
> >> Can you clarify, where this 'read_atoms' is precisely located? More
> >> specifically, what is 'ABC'  in :
> >>
> >>>>> atoms = ABC.read_atoms('si.abc')
> >> Because: Following the text above 'ABC' would be the uninstantiated
> >> calculator class.
> >
> > Yes, that is correct ABC is the uninstantiated class.  read_atoms is a
> > so-called class-method.  You can see the implementation here:
> >
> >
> https://trac.fysik.dtu.dk/projects/ase/browser/branches/aep1/ase/calculators/calculator.py#L198
> >    http://docs.python.org/2/library/functions.html#classmethod
> >
> > Jens Jørgen
> >
> >> Though I think such a constructor is uncommon in python. As a python
> user
> >> I would expect to either have a read_atoms function as  in
> >> ase.io.ABC.read_atoms('...') or
> >> alternatively use the constructor like
> >> ase.calculators.abc.ABC(read_atoms='si.abc').
> >>
> >> Best,
> >> Max.
> >>
> >>
> >> [1]
> https://wiki.fysik.dtu.dk/ase/development/proposals/calculators.html
> >>
> >>
> >> 2013/1/28 John Kitchin <jkitchin at andrew.cmu.edu>:
> >>>> * Restart
> >>>>>> There is another use mode worth discussing. In the following
> example:
> >>>>>>
> >>>>>> myatoms = Atoms(..., ideal positions)
> >>>>>>
> >>>>>> calc = MyCalculator(arg1, atoms=myatoms, kwargs)
> >>>>>> # I greatly prefer this to myatoms.set_calculator(calc)
> >>>>>> atoms.get_potential_energy()
> >>>>>
> >>>>> I like that way of attaching the calculator to the atoms.  I'll put
> that
> >>>>> idea in the proposal.
> >>>>>> 1. The first time you run this, a calculation get run.
> >>>> As a personal preference :-), I do not like that heavy calculations
> get
> >>>> run when one creates an object (even though some GPAW functionality
> behaves
> >>>> this way), but that user has to explicitly request calculation by
> calling a
> >>>> function.
> >>>
> >>> Maybe something above was unclear. No calculation is done until
> >>> atoms.get_potential_energy() is called.
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> ase-users mailing list
> >>> ase-users at listserv.fysik.dtu.dk
> >>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
> >>
> >>
> >
> > _______________________________________________
> > ase-users mailing list
> > ase-users at listserv.fysik.dtu.dk
> > https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>
> _______________________________________________
> ase-developers mailing list
> ase-developers at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-developers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20130201/712be2f6/attachment.html>


More information about the ase-users mailing list