Block classes

DataBlock

class pylam.DataBlock(blockFile, fline=0, lline=0, header_line='N/A')[source]

Bases: pylam.base.Block

Generic class for a data block within an indexed block file.

Parameters:
  • blockFile (pylam.base.BlockFile) – block file object
  • fline (int) – first line index of the data block
  • lline (int) – last line index of the data block
  • header_line (str) – header of the block
data_delimiter = None

The string used to separate values in a data row (default: None = any whitespace).

__getitem__(index)[source]

Support for read only itemized access.

Parameters:index – block line index
Returns:data
Return type:numpy.ndarray
next()[source]

Returns the next data row from the block as numpy array.

getRows(startRowIndex, endRowIndex)[source]

Returns a part of the data block as a numpy array.

Parameters:
  • startRowIndex (int) – index of first data row
  • endRowIndex (int) – index of last data line (included!)
Returns:

data

Return type:

numpy.ndarray

getRow(rowIndex)[source]

Returns a row of the data block as a numpy array.

Parameters:rowIndex (int) – index of data row
Returns:data
Return type:numpy.ndarray
getCol(idx)[source]

Returns a whole column as a np.ndarray.

Parameters:idx (int) – column index
Returns:column data
Return type:np.ndarray
write(filename)[source]

Writes the whole data block to a file.

Parameters:filename (str) – output file name
data
Returns:the whole data block
Return type:numpy.ndarray
header
Returns:the header line as list
Return type:list
info()[source]

Prints debug info to screen, e.g.:

header      : ['Step', 'Temp', 'E_pair', 'E_mol', 'TotEng', 'Press']
N rows      : 101
N cols      : 6
prop. header: True
properHeader
Returns:tests if a proper header is defined
Return type:bool
columnName2Index(name)[source]

Returns the column index for a given name as defined in the header. Therefore properHeader() must be True.

Parameters:name (str) – column name
Returns:column index
Return type:int
getColumnByName(name)[source]

Returns a whole column as a np.ndarray.

Parameters:name (str) – column name
Returns:column data
Return type:np.ndarray

ThermoBlock

This class represents a thermodynamic info block which is section of the log file (log.lammps).

class pylam.ThermoBlock(logFile, fline=0, lline=0, header_line='N/A')[source]

Bases: pylam.DataBlock

Class for a LAMMPS thermo block within a LAMMPS log file.

Parameters:
  • logFile (pylam.LogFile) – LogFile object
  • fline (int) – first line index of the thermo block
  • lline (int) – last line index of the thermo block
  • header_line (str) – header of the block
info()[source]

Prints debug info to screen, e.g.:

header      : ['Step', 'Temp', 'E_pair', 'E_mol', 'TotEng', 'Press']
N rows      : 101
N cols      : 6
prop. header: True
runprops:
 ─────────── ───────────
   keyword      value
 ─────────── ───────────
       rtime      20.814
       steps       10000
       mempp      4.1816
      thermo         100
       procs          16
       atoms        1372
 ─────────── ───────────
thermo

Returns the thermo value.

Deprecated since version 0.1.dev1: Use runprops['thermo'] instead!

steps

Returns the steps value.

Deprecated since version 0.1.dev1: Use runprops['steps'] instead!

benchmark

Dictionary containing benchmark information of the simulation run.

Keyword Value Type Description
steps_per_sec float steps / sec.
steps_per_sec_proc float steps / ( sec. * process )
atoms_steps_per_sec float ( atoms * steps ) / sec.
atoms_steps_per_sec_proc float ( atoms * steps ) / ( sec. * process )
Returns:simulation run benchmark
Return type:dict
print_benchmark()[source]

Print the simulation run benchmark to screen, e.g.:

Benchmarks:
 ───────────────────────── ─────────────────────────
             steps_per_sec                    480.44
        steps_per_sec_proc                    30.027
       atoms_steps_per_sec                6.5916e+05
  atoms_steps_per_sec_proc                     41197
 ───────────────────────── ─────────────────────────
runprops

Dictionary containing general properties of the simulation run.

Keyword Value Type Description
steps int number of simulation steps
rtime float simtime [sec.]
procs int number of processes used
atoms int number of atoms
thermo int sample interval [steps]
mempp float memory usage per processor [Mbytes]
Returns:simulation run properties
Return type:dict
timing

The statistics from the timing breakdown below the thermodynamic block data, like:

MPI task timing breakdown:
Section |  min time  |  avg time  |  max time  |%varavg| %total
---------------------------------------------------------------
Pair    | 144.79     | 149.62     | 153.95     |  17.4 | 13.10
Bond    | 16.294     | 16.504     | 17.38      |   4.7 |  1.45
Kspace  | 621.19     | 626.01     | 630.98     |   9.0 | 54.81
Neigh   | 261.86     | 262.18     | 262.44     |   1.0 | 22.96
Comm    | 66.306     | 71.848     | 75.624     |  30.6 |  6.29
Output  | 0.054085   | 0.076193   | 0.089217   |   4.2 |  0.01
Modify  | 11.62      | 15.304     | 20.772     |  65.9 |  1.34
Other   |            | 0.5473     |            |       |  0.05

, or the old format:

Pair  time (%) = 3.09352 (14.8625)
Neigh time (%) = 0.00725645 (0.0348627)
Comm  time (%) = 12.9035 (61.9934)
Outpt time (%) = 0.0834265 (0.400812)
Other time (%) = 4.72661 (22.7084)

, as a dictionary with the section (e.g. Pair) as Keyword and a list containing the time used [sec.] and percentage [%], as {'Pair': [149.62, 13.1], 'Bond': [16.504, 1.45], ...}.

Returns:timing statistics
Return type:dict

FixBlock

class pylam.FixBlock(blockFile, fline=0, lline=0, header_line='N/A')[source]