Device

class hoomd.device.Device(communicator, notice_level, message_filename)

Base class device.

Provides methods and properties common to CPU and GPU, including those that control where status messages are stored (message_filename) how many status messages HOOMD-blue prints (notice_level) and a method for user provided status messages (notice).

Warning

Device cannot be used directly. Instiatate a CPU or GPU object.

property communicator

The MPI Communicator [read only].

Type:

hoomd.communicator.Communicator

property device

Descriptions of the active hardware device.

Type:

str

property message_filename

Filename to write messages to.

By default, HOOMD prints all messages and errors to Python’s sys.stdout and sys.stderr (or the system’s stdout and stderr when running in an MPI environment).

Set message_filename to a filename to redirect these messages to that file.

Set message_filename to None to use the system’s stdout and stderr.

Examples:

device.message_filename = str(path / "messages.log")
device.message_filename = None

Note

All MPI ranks within a given partition must open the same file. To ensure this, the given file name on rank 0 is broadcast to the other ranks. Different partitions may open separate files. For example:

communicator = hoomd.communicator.Communicator(ranks_per_partition=2)
filename = f"messages.{communicator.partition}"
device = hoomd.device.CPU(
    communicator=communicator, message_filename=filename
)
Type:

str

notice(message, level=1)

Write a notice message.

Parameters:
  • message (str) – Message to write.

  • level (int) – Message notice level.

Write the given message string to the output defined by message_filename on MPI rank 0 when notice_level >= level.

Example:

device.notice("Message")

Hint

Use notice instead of print to write status messages and your scripts will work well in parallel MPI jobs. notice writes message only on rank 0. Use with a rank-specific message_filename to troubleshoot issues with specific partitions.

property notice_level

Minimum level of messages to print.

notice_level controls the verbosity of messages printed by HOOMD. The default level of 2 shows messages that the developers expect most users will want to see. Set the level lower to reduce verbosity or as high as 10 to get extremely verbose debugging messages.

Example:

device.notice_level = 4
Type:

int