perturbopy.postproc.calc_modes.dyna_run.DynaRun

class perturbopy.postproc.calc_modes.dyna_run.DynaRun(cdyna_file, tet_file, pert_dict, read_snaps=True)

Bases: CalcMode

Class representation of a Perturbo dynamics-run calculation.

TODO: better handling with snaps. Make it as property. Print a sensible message if snaps is None and access is attempted. Implement a getter and setter for snaps linked to HDF5 file.

kpt

Database for the k-points used in the bands calculation.

Type:

RecipPtDB

bands

Database for the band energies computed by the bands calculation.

Type:

UnitsDict

num_runs

Number of separate simulations performed

Type:

int

_cdyna_file

HDF5 file containing the results of the dynamics-run calculation. We cannot store in RAM the whole file, so we will access the data as needed.

Type:

h5py.File

_tet_file

HDF5 file containing the results of the setup calculation required before the dynamics-run calculation.

Type:

h5py.File

_kpoints

Raw array of k-points. Shape (num_kpoints, 3)

Type:

array

_energies

Raw array of band energies. Shape (num_kpoints, num_bands)

Type:

array

_dat

Python dictionary of DynaIndivRun objects containing results from each simulation

Type:

dict

Methods

close_hdf5_files

Method to close the HDF5 files: _cdyna_file and _tet_file.

extract_steady_drift_vel

Method to extract the drift velocities and equilibrium carrier concentrations

from_hdf5_yaml

Class method to create a DynamicsRunCalcMode object from the HDF5 file and YAML file generated by a Perturbo calculation

from_yaml

Class method to create a CalcMode object from the YAML file generated by a Perturbo calculation.

to_cdyna_h5

Write the dynamics data into the prefix_cdyna.h5 HDF5 file.

close_hdf5_files()

Method to close the HDF5 files: _cdyna_file and _tet_file. After the DynaRun object is created, the HDF5 files are kept open. One has to close them manually.

extract_steady_drift_vel(dyna_pp_yaml_path)

Method to extract the drift velocities and equilibrium carrier concentrations

Returns:

num_runs – Number of runs

Return type:

int

classmethod from_hdf5_yaml(cdyna_path, tet_path, yaml_path='pert_output.yml', read_snaps=True)

Class method to create a DynamicsRunCalcMode object from the HDF5 file and YAML file generated by a Perturbo calculation

Parameters:
  • cdyna_path (str) – Path to the HDF5 file generated by a dynamics-run calculation

  • tet_path (str) – Path to the HDF5 file generated by the setup calculation required before the dynamics-run calculation

  • yaml_path (str, optional) – Path to the YAML file generated by a dynamics-run calculation

Returns:

dyanamics_run – The DynamicsRunCalcMode object generated from the HDF5 and YAML files

Return type:

DynamicsRunCalcMode

classmethod from_yaml(yaml_path='pert_output.yml')

Class method to create a CalcMode object from the YAML file generated by a Perturbo calculation.

Parameters:

yaml_path (str, optional) – Path to the YAML file generated by a Perturbo calculation

Returns:

calc_mode – The CalcMode object generated from the YAML file

Return type:

CalcMode

static to_cdyna_h5(prefix, band_structure_ryd, snap_array, time_step_fs, path='.', new=True, overwrite=False, num_runs=1)

Write the dynamics data into the prefix_cdyna.h5 HDF5 file. Follows the script format of the Perturbo dynamics-run calculation. Currently implemented as a static method. The idea is that if we need to write an HDF5 cdyna file, it is forcfully different from an existing one, therefore, one or more attributes are different from the original cdyna file.

Parameters:
  • prefix (str) – Prefix of the HDF5 file. Same as prefix in any Perturbo calculation.

  • band_structure_ryd (np.ndarray) – Band structure in Rydberg units. Shape: num_kpoints x num_bands

  • snap_array (np.ndarray) – Array of carrier occupations. Shape: (num_steps, num_kpoints, num_bands)

  • time_step_fs (float or np.ndarray) – Time step in fs. If float, the same time step is used for all runs. If np.ndarray, the time steps for each run are specified.

  • path (str) – Path to the directory where the HDF5 file is saved. Default is the current directory.

  • new (bool) – Flag to indicate if the file is new. Default is True.

  • overwrite (bool) – Flag to indicate if the file is overwritten. Default is False.

  • num_runs (int) – Number of dynamics_run runs. Default is 1.