Examples
Use the Quickstart Guide to launch the NIM before running the following examples.
For the request format and required atomic data fields, refer to API Reference.
Install the Python libraries needed for the examples on this page:
Using ASE for Structure I/O
Use the NIM for BGR to process a chemistry dataset by combining it with the I/O
capabilities from the Atomic Simulation Environment (ASE). With a file
structures.extxyz containing multiple structures in ASE
extended XYZ format,
and NIM for BGR running at http://localhost:8000/v1/infer, the
following script runs batched optimization. Refer to the example
structures.extxyz file.
For periodic systems, ASE.Atoms objects must have cell and pbc attributes defined.
For isolated molecules, omit the cell field or set pbc to false.
The following Python script reads structures from structures.extxyz,
performs batched optimization, and produces a structures_opt.extxyz file with
optimized structures.
Concurrent Requests
The inference API accepts multiple concurrent requests; the server processes them and returns responses in order. There is no dedicated async/polling API. Achieve concurrent behavior by issuing multiple requests and waiting on the responses.
Concurrent behavior example (Python)
Asynchronous example (Python)
Use asyncio with an async HTTP client to
send multiple inference requests without blocking. Install aiohttp
(for example, pip install aiohttp) and run the following:
Partial Optimization With Active Masks
Freeze specific atoms during optimization by using the active_mask field: