Estimator#
- class light_pfp_client.estimator.Estimator(model_id: str, book_keeping: bool = True, max_retries: int = 10, address: str = ”)#
-
Bases:
object
Estimator calculates the energy and related values (e.g. atomic forces) of given atomic structure. A single Estimator instance can only be used by at most
one ASECalculator instance.- property application_context: str#
- attach_to_calculator(_: Calculator) None #
- property book_keeping: bool#
- clean_up() None #
- close() None #
- estimate(args: EstimatorSystem) Dict[str, ndarray] #
-
This function receives atomic system information and returns energy, forces and related values.
- Parameters
-
args (EstimatorSystem) – For details, see the document for EstimatorSystem.
- Returns
-
results – Dictionary which contains various calculated properties
- Return type
-
Dict[str, any]
- property estimator_id: str#
- property model_id: str#
- class light_pfp_client.estimator.EstimatorSystem(properties: List[str], coordinates: ndarray, cell: ndarray, species: Optional[ndarray] = None, atomic_numbers: Optional[ndarray] = None, pbc: Optional[ndarray] = None)#
-
Bases:
object
Input argument of Estimator.estimate function.
- Parameters
-
-
properties (List[str]) – What properties should be calculated. Current implemented properties are “energy”, “forces”, and “virial”. If gradient-based parameters (forces, virial) are not requested, the estimator does not calculate them.
-
coordinates (np.ndarray (dtype=np.float32 or np.float64)) – Coordination of atoms. The shape is (n_atoms, 3).
-
cell (np.ndarray (dtype=np.float32 or np.float64)) – Simulation cell of the system. The shape is (3, 3)
-
species (Optional[np.ndarray] (dtype=”
)) – Element list of atoms as string. Either species or atomic_numbers should be provided. The shape is (n_atoms, ) -
atomic_numbers (Optional[np.ndarray] (dtype=np.uint8)) – Element list of atoms as atomic number. Either species or atomic_numbers should be provided. The shape is (n_atoms, )
-
pbc (Optional[np.ndarray] (dtype=np.uint8)) – Whether periodic boundary conditions are applied (1) or not (0) for each axis. The shape is (3, )
-
- atomic_numbers: Optional[ndarray] = None#
- cell: ndarray#
- coordinates: ndarray#
- pbc: Optional[ndarray] = None#
- properties: List[str]#
- species: Optional[ndarray] = None#
Calculator#
- class light_pfp_client.ase_calculator.ASECalculator(estimator: Estimator)#
-
Bases:
Calculator
ASECalculator is a derivation of ase.calculators.calculator.
Usually this will be used from ase.Atoms object.
It can be safe to have multiple instances of ASECalculator running
concurrently in different threads, as long as they do not share
the same Estimator instance. It is not safe to use a single
instance of ASECalculator concurrently and trying to do so will
likely raise a ConcurrentUseDetected exception. Due to hardware
limitations, the overall efficiency decreases when more than five
LightPFP calculators are used simultaneously.
:param estimator: LightPFP Estimator
:type estimator: Estimator- atoms: Optional[Atoms]#
- calculate(atoms: Optional[Atoms] = None, properties: Optional[Sequence[str]] = None, system_changes: Sequence[str] = [‘positions’, ‘numbers’, ‘cell’, ‘pbc’, ‘initial_charges’, ‘initial_magmoms’]) None #
-
Do the calculation. This function will be called from various ASE objects such as ase.optimizer or ase.md classes.
:param atoms: ase.Atoms object.
:param properties: Sequence of what needs to be calculated. Current supported values are ‘energy’, ‘forces’, ‘stress’, and ‘charges’.
:param system_changes: Sequence of what has changed since last calculation.
- static calculate_stress(virial: ndarray, atom_volume: ndarray) ndarray #
- convert_properties(properties: Sequence[str]) List[str] #
- reverse_convert_properties(properties: Sequence[str]) List[str] #
- set_default_properties(default_properties: Sequence[str]) None #
-
Specify the properties that are always calculated.
Estimator_fn#
- light_pfp_client.estimator_fn.light_pfp_estimator_fn(model_id: str, book_keeping: bool = True, max_retries: int = 10, address: str = ‘unix:///var/run/pfp-api/light-pfp-api.sock’) Callable[[], Estimator] #
-
An estimator function for a LightPFP estimator.
The MatlantisFeatures can be used with LightPFP estimator_fn.
For more information about the estimator function,
please read our guidebook(en)
or guidebook(ja).- Parameters
-
-
model_id (str) – The ID of LightPFP model.
-
book_keeping – (bool, optional):
Whether to enable book keeping. Defaults to True. -
max_retries – (int, Optional)
Maximum number of retries when light-pfp-client fails to
get replies from the server. Defaults to 10.
-
- Returns
-
callable object that returns an estimator.
- Return type
-
EstimatorFnType