gpridge._observers¶
ASE-optimizer-style observers for the GP drivers.
GPNEB and GPDimer run
their whole outer loop in C++, so there is no Python step at which an
ASE Optimizer would call its observers. The one Python event the
loop has is the oracle evaluation: every true energy and force call
passes through the calculator bridge in gpridge.ase_bridge.
The drivers therefore count one step per oracle call, and
attach, logfile and trajectory act on those steps the way
they act on optimizer steps in ASE:
attach(function, interval=1, *args, **kwargs)callsfunction(*args, **kwargs)after everyinterval-th oracle call;logfilereceives one line per oracle call ("-"is stdout);trajectoryreceives the evaluated geometry with its energy and forces. A path is a readcon trajectory, one frame per oracle call, readable by readcon, eOn and the drivers. An object withwriteis used as is.
GP-predicted geometries are never reported: they cost no oracle call and are not ground truth.
Classes¶
Append evaluated geometries to a |
|
Observer list, log and trajectory driven by oracle evaluations. |
|
|
Module Contents¶
- class gpridge._observers.ConTrajectoryWriter(path: str)¶
Append evaluated geometries to a
.confile through readcon.Each
writeadds one frame with the positions, the cell, the fixed flags, the energy and the forces of anAtomswhose calculator holds them, and flushes it, so the file is complete after every call.- path¶
- class gpridge._observers.OracleObservers(name: str, logfile: Any = None, trajectory: Any = None)¶
Observer list, log and trajectory driven by oracle evaluations.
- Parameters:
name (
str) – Label written at the start of each log line.logfile (
str,os.PathLike,file-likeorNone) –"-"writes to stdout, a string or path-like object opens that path for writing, an object withwriteis used as is,Nonedisables logging.trajectory (
strorNone) – A path opens a readcon trajectory. An object withwriteis used as is.
- name = ''¶
- nsteps = 0¶
- last_atoms: Any = None¶
- logfile = None¶
- trajectory = None¶
- attach(function: Callable[Ellipsis, Any], interval: int = 1, *args, **kwargs) None¶
Call
function(*args, **kwargs)everyintervaloracle calls.As in ASE, an object with a
writemethod may stand in for the function. Itswriteis called with the evaluatedAtoms(energy and forces attached) followed byargs, because the drivers do not move the caller’sAtomsduring a run. Plain callables read the same geometry fromlast_atoms.
- notify(atoms: Any, energy: float, forces: numpy.ndarray) None¶
Record one oracle evaluation of
atoms.
- class gpridge._observers.ObservableDriver¶
attach/logfile/trajectorysurface for a GP driver.Subclasses call
_init_observersin__init__and passobserversto the calculator bridge.- observers: OracleObservers¶
- property last_atoms¶
The most recent oracle-evaluated geometry, or
None.
- attach(function: Callable[Ellipsis, Any], interval: int = 1, *args, **kwargs) None¶
Attach an observer; see
OracleObservers.attach().