GPUMD IO#
- calorine.gpumd.read_dipole(fname)[source]#
Read a GPUMD
dipole.outfile written by thedump_dipolekeyword.GPUMD writes one header per
runand appends to the same file. The blocks are laid end to end, each contributing its owndt_output, sotimeruns across the whole file. Thestepcolumn is the counter GPUMD wrote, which restarts at everyrun.- Parameters:
fname (
str) – Path to thedipole.outfile.- Returns:
DataFrame with columns
step(int),mu_x,mu_y,mu_z(dipole moment \(\mu\) for molecules, or polarization P for extended systems, in e·Å). If a header is present in thedipole.outfile, thetimein ps is also included as a column.- Return type:
DataFrame
- calorine.gpumd.read_dpdt(fname)[source]#
Read a GPUMD
dpdt.outfile.The time column is converted from fs (as written by GPUMD) to ps.
GPUMD writes one header per
runand appends to the same file. The blocks are laid end to end, each contributing its owndt_output, sotimeruns across the whole file.- Parameters:
fname (
str) – Path to thedpdt.outfile.- Returns:
DataFrame with columns
time(ps),dPx,dPy,dPz(time derivatives of the polarization in e·Å/fs), andPx,Py,Pz(polarization components in e·Å).- Return type:
DataFrame
- calorine.gpumd.read_hac(filename, exclude_currents=True, exclude_in_out=True)[source]#
Parses a file in
hac.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here.- Parameters:
filename (
str) – Input file name.exclude_currents (
bool) – Do not include currents in output to save memory.exclude_in_out (
bool) – Do not includeinandoutparts of conductivity in output to save memory.
- Return type:
DataFrame
- calorine.gpumd.read_kappa(filename)[source]#
Parses a file in
kappa.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here.- Parameters:
filename (
str) – Input file name.- Return type:
DataFrame
- calorine.gpumd.read_mcmd(filename, accumulate=True)[source]#
Parses a Monte Carlo output file in
mcmd.outformat and returns the content in the form of a DataFrame.- Parameters:
filename (
str) – Path to file to be parsed.accumulate (
bool) – IfTruethe MD steps between subsequent Monte Carlo runs in the same output file will be accumulated.
- Return type:
DataFrame- Returns:
DataFrame containing acceptance ratios and concentrations (if available), as well as key Monte Carlo parameters.
- calorine.gpumd.read_msd(filename)[source]#
Parses a file in
msd.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here.GPUMD writes one header per
runand appends to the same file. Each block is a separate correlation function, so a file holding more than one is rejected rather than combined.- Parameters:
filename (
str) – Input file name.- Return type:
DataFrame
- calorine.gpumd.read_polarizability(fname, normalize=None, scale=None)[source]#
Read a GPUMD
polarizability.outfile written bydump_polarizability.GPUMD writes one header per
runand appends to the same file. The blocks are laid end to end, each contributing its owndt_outputandnum_atoms, sotimeruns across the whole file. Thestepcolumn is the counter GPUMD wrote, which restarts at everyrun.- Parameters:
fname (
str) – Path to thepolarizability.outfile.normalize (
bool|None) – Divide the six susceptibility columns by the number of atoms, taken from thenum_atomsline of each header block.scale (
float) – Divisor applied to the six susceptibility columns in place of the count in the header. Passing it impliesnormalize, and naming it together withnormalize=Falseraises. GPUMD writes the total supercell susceptibility \(\chi_\mathrm{cell}\), so the divisor should match the normalization constant used as the training target scale of the TNEP model, typically the number of atoms. Dividing by it recovers the intensive, per-atom quantity thatget_raman_spectrum()expects. Thestepcolumn is not affected.
- Returns:
DataFrame with columns
step(int) and the six independent componentsxx,yy,zz,xy,yz,xzof the polarizability \(\alpha\) (molecules) or susceptibility \(\chi\) (extended systems), in the same units as the TNEP training data (typically Å^3 or bohr^3 per atom whenscaleequals the number of atoms). The off-diagonal order follows the GPUMDpolarizability.outfile (xy, yz, xz). If a header is present in thepolarizability.outfile, thetimein ps is also included as a column.- Return type:
DataFrame
- calorine.gpumd.read_runfile(filename)[source]#
Parses a GPUMD input file in
run.informat and returns the content in the form a list of keyword-value pairs.The values of a few keywords are cast to a number, among them the dump interval that opens a
dump_xyzline. The remaining fields of such a line, meaning the file name and any flags, are kept as strings, and all other values fall back to strings as well.- Parameters:
filename (
str) – Input file name.- Return type:
list[tuple[str,list]]- Returns:
List of keyword-value pairs.
- calorine.gpumd.read_sdc(filename)[source]#
Parses a file in
sdc.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here.GPUMD writes one header per
runand appends to the same file. Each block is a separate correlation function, so a file holding more than one is rejected rather than combined.- Parameters:
filename (
str) – Input file name.- Return type:
DataFrame
- calorine.gpumd.read_shc(filename)[source]#
Parses a file in
shc.outformat from GPUMD (written by thecompute_shckeyword) and returns the correlation and spectral blocks as two data frames.When the calculation covers more than one output group, the
ki/ko/shc_i/shc_ocolumns are suffixed with the group index GPUMD assigns, which runs from 1 (ki_1,ko_1,ki_2, …); the sharedtime/omegagrid is not suffixed.GPUMD writes one header per
runand appends to the same file. Each block is a separate correlation function, so a file holding more than one is rejected rather than combined.This reader requires the header, which alone says how the correlation and spectral blocks are laid out. Its siblings fall back to reading a header-less file by column count.
- Parameters:
filename (
str) – Input file name.- Return type:
tuple[DataFrame,DataFrame]- Returns:
correlation (DataFrame) – DataFrame with columns
time,ki,ko(suffixed with the group index, e.g.ki_1, when the calculation covers multiple output groups).shc (DataFrame) – DataFrame with columns
omega,shc_i,shc_o(suffixed with the group index when the calculation covers multiple output groups).
- calorine.gpumd.read_thermo(filename, normalize=None, natoms=None)[source]#
Parses a file in
thermo.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here. Additionally, the time (in ps), the pressure (in GPa), the volume (in Å:sup:3), the lengths of the three cell vectors (cell_length_1tocell_length_3, in Å) and the angles between them (cell_angle_12,cell_angle_13andcell_angle_23, in degrees) are included. A header that names one of those derived columns itself, or names any column twice, raises.GPUMD writes one header per
runand appends to the same file. The blocks are laid end to end, each contributing its owndt_outputandnum_atoms, sotimeruns across the whole file and each block is normalized by its own atom count.- Parameters:
filename (
str) – Input file name.normalize (
bool|None) – Divide the energies by the number of atoms, taken from thenum_atomsline of each header block.natoms (
int) – Number of atoms to divide the energies by, in place of the count in the header. Passing it impliesnormalize, and naming it together withnormalize=Falseraises.
- Returns:
DataFrame with columns determined by the
thermo.outformat.- Return type:
DataFrame
- calorine.gpumd.read_viscosity(filename)[source]#
Parses a file in
viscosity.outformat from GPUMD and returns the content as a data frame. More information concerning file format, content and units can be found here.GPUMD writes one header per
runand appends to the same file. Each block is a separate correlation function, so a file holding more than one is rejected rather than combined.- Parameters:
filename (
str) – Input file name.- Return type:
DataFrame
- calorine.gpumd.read_xyz(filename)[source]#
Reads the structure input file (
model.xyz) for GPUMD and returns the structure.This is a wrapper function around
ase.io.read_xyz()since the ASE implementation does not read velocities properly. Specifically, the velocity unit is converted from GPUMD units (Å/fs) to ASE units (1/sqrt(u/eV)).- Parameters:
filename (
str) – Name of file from which to read the structure.- Return type:
- Returns:
Structure as ASE Atoms object with additional per-atom arrays representing atomic masses, velocities etc.
- calorine.gpumd.write_runfile(file, parameters)[source]#
Write a file in run.in format to define input parameters for MD simulation.
- Parameters:
file (
Path) – Path to file to be written.parameters (
list[tuple[str,int|float|tuple[str,float]]]) – Defines all command-parameter(s) pairs used in run.in file (see GPUMD documentation for a complete list). Values can be either floats, integers, or lists/tuples.
- calorine.gpumd.write_xyz(filename, structure, groupings=None)[source]#
Writes a structure into GPUMD input format (
model.xyz).This is a wrapper function around
ase.io.write_xyz()since the ASE implementation does not write velocities properly. Specifically, the velocity unit is converted from ASE units (1/sqrt(u/eV)) to GPUMD units (Å/fs).- Parameters:
filename (
str) – Name of file to which the structure should be written.structure (
Atoms) – Input structure.groupings (
list[list[list[int]]]) – Groups into which the individual atoms should be divided in the form of a list of list of lists. Specifically, the outer list corresponds to the grouping methods, of which there can be three at the most, which contains a list of groups in the form of lists of site indices. The sum of the lengths of the latter must be the same as the total number of atoms.
- Raises:
ValueError – Raised if parameters are incompatible.