narupa.ase.frame_adaptor module

Methods for transmitting a simulation frame from ASE.

narupa.ase.frame_adaptor.send_ase_frame(ase_atoms: ase.atoms.Atoms, frame_publisher: narupa.trajectory.frame_publisher.FramePublisher) → Callable[[], None]

Hook to transmit the current state of an ASE Atoms as a frame.

Parameters:
  • ase_atoms – ASE Atoms object from which to extract frame.
  • frame_publisher – The frame publisher on which to send the produced narupa.trajectory.FrameData.

When attached to an ASE simulation, such as a Langevin dynamics simulation, this method will be called to send the frame on the given FrameServer.

>>> frame_server = FrameServer(address="localhost", port=54321)
>>> atoms = FaceCenteredCubic(directions=[[1, 0, 0], [0, 1, 0], [0, 0, 1]],
...                           symbol="Cu", size=(2, 2, 2), pbc=True)
>>> dynamics = Langevin(atoms, timestep=0.5, temperature_K=300, friction=1.0)
>>> dynamics.attach(send_ase_frame(atoms, frame_publisher), interval=2)