Device¶
- class hoomd.device.Device(communicator, notice_level, message_filename)¶
Base class device.
Provides methods and properties common to
CPU
andGPU
, 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
).- property communicator¶
The MPI Communicator [read only].
- property message_filename¶
Filename to write messages to.
By default, HOOMD prints all messages and errors to Python’s
sys.stdout
andsys.stderr
(or the system’sstdout
andstderr
when running in an MPI environment).Set
message_filename
to a filename to redirect these messages to that file.Set
message_filename
toNone
to use the system’sstdout
andstderr
.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:
- notice(message, level=1)¶
Write a notice message.
Write the given message string to the output defined by
message_filename
on MPI rank 0 whennotice_level
>=level
.Example:
device.notice("Message")
Hint
Use
notice
instead ofprint
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-specificmessage_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: