mcal package - mcal 0.1.0 documentation

Skip to content
Back to top
View this page

# mcal package

## Subpackages

- mcal.calculations package
  - Submodules
  - mcal.calculations.hopping_mobility_model module
    - `cal_pinv()`
    - `demo()`
    - `diffusion_coefficient_tensor()`
    - `diffusion_coefficient_tensor_MC()`
    - `diffusion_coefficient_tensor_ODE()`
    - `marcus_rate()`
    - `mobility_tensor()`
    - `print_tensor()`
  - mcal.calculations.rcal module
    - `GausTermError`
    - `OSCTypeError`
    - `Rcal`
      - `Rcal.calc_reorganization()`
      - `Rcal.check_error_term()`
      - `Rcal.check_extension_log()`
      - `Rcal.extract_energy()`
      - `Rcal.print_timestamp()`
    - `main()`
  - mcal.calculations.tcal module
    - `PairAnalysis`
      - `PairAnalysis.print_element_pairs()`
      - `PairAnalysis.print_largest_pairs()`
    - `Tcal`
      - `Tcal.EV`
      - `Tcal.atomic_pair_transfer_analysis()`
      - `Tcal.cal_transfer_integrals()`
      - `Tcal.check_extension_log()`
      - `Tcal.check_normal_termination()`
      - `Tcal.convert_xyz_to_gjf()`
      - `Tcal.create_cube_file()`
      - `Tcal.create_monomer_file()`
      - `Tcal.custom_atomic_pair_transfer_analysis()`
      - `Tcal.extract_coordinates()`
      - `Tcal.extract_num()`
      - `Tcal.output_csv()`
      - `Tcal.print_apta()`
      - `Tcal.print_matrix()`
      - `Tcal.print_timestamp()`
      - `Tcal.print_tranfer_integral_diff_levels()`
      - `Tcal.print_transfer_integrals()`
      - `Tcal.read_dimer()`
      - `Tcal.read_matrix()`
      - `Tcal.read_monomer1()`
      - `Tcal.read_monomer2()`
      - `Tcal.read_symmetric_matrix()`
      - `Tcal.run_gaussian()`
    - `main()`
  - Module contents
- mcal.utils package
  - Submodules
  - mcal.utils.cif_reader module
    - `CifReader`
      - `CifReader.ATOMIC_WEIGHTS`
      - `CifReader.COVALENT_RADII`
      - `CifReader.ELEMENT_PROP`
      - `CifReader.calc_cen_of_weight()`
      - `CifReader.convert_cart_to_frac()`
      - `CifReader.convert_frac_to_cart()`
      - `CifReader.expand_mols()`
      - `CifReader.export_unit_cell_file()`
      - `CifReader.parent_dir`
      - `CifReader.remove_duplicates()`
    - `ElementPropertiesIsNotDefinedError`
    - `FileIO`
      - `FileIO.add_adjacency_mat()`
      - `FileIO.add_coordinates()`
      - `FileIO.add_symbols()`
      - `FileIO.export_mol_file()`
      - `FileIO.export_xyz_file()`
    - `SymmetryIsNotDefinedError`
    - `ZValueIsNotMatchError`
  - mcal.utils.gaus_log_reader module
    - `FileReader`
      - `FileReader.close()`
      - `FileReader.reversed_readline()`
    - `check_normal_termination()`
  - mcal.utils.gjf_maker module
    - `GjfMaker`
      - `GjfMaker.ELEMENTS_NUM`
      - `GjfMaker.ELEMENT_PROP`
      - `GjfMaker.add_link()`
      - `GjfMaker.add_root()`
      - `GjfMaker.create_chk_file()`
      - `GjfMaker.create_rwf_file()`
      - `GjfMaker.export_gjf()`
      - `GjfMaker.opt()`
      - `GjfMaker.output_detail()`
      - `GjfMaker.parent_dir`
      - `GjfMaker.reset_variable()`
      - `GjfMaker.set_charge_spin()`
      - `GjfMaker.set_coordinates()`
      - `GjfMaker.set_function()`
      - `GjfMaker.set_resource()`
      - `GjfMaker.set_symbols()`
      - `GjfMaker.set_title()`
  - Module contents

## Submodules

## mcal.mcal module

mcal

exception mcal.mcal.OSCTypeError

  Bases: `Exception`

  Exception for semiconductor type

mcal.mcal.atom_weight(symbol: str) → float

  Get atom weight

  Parameters:

    symbol (str) – Symbol of atom

  Returns:

    Atomic weight

  Return type:

    float

mcal.mcal.cal_cen_of_weight(symbols1: ndarray[Any, dtype[str]], coordinates1: ndarray[Any, dtype[float64]], symbols2: ndarray[Any, dtype[str]] | None = None, coordinates2: ndarray[Any, dtype[float64]] | None = None) → ndarray[Any, dtype[float64]]

  Calculate center of weight

  Parameters:

    - symbols1 (NDArray[str]) – Symbols of atoms in one monomer

    - coordinates1 (NDArray[np.float64]) – Coordinates of atoms in one monomer

    - symbols2 (Optional[NDArray[str]], optional) – Symbols of atoms in another monomer, by default None

    - coordinates2 (Optional[NDArray[np.float64]], optional) – Coordinates of atoms in another monomer, by default None

  Returns:

    Center of weight

  Return type:

    NDArray[np.float64]

mcal.mcal.cal_distance_between_cen_of_weight(symbols1: ndarray[Any, dtype[str]], coordinates1: ndarray[Any, dtype[float64]], symbols2: ndarray[Any, dtype[str]], coordinates2: ndarray[Any, dtype[float64]]) → float

  Calculate distance between centers of weight

  Parameters:

    - symbols1 (NDArray[str]) – Symbols of atoms in one monomer

    - coordinates1 (NDArray[np.float64]) – Coordinates of atoms in one monomer

    - symbols2 (NDArray[str]) – Symbols of atoms in another monomer

    - coordinates2 (NDArray[np.float64]) – Coordinates of atoms in another monomer

  Returns:

    Distance between centers of weight

  Return type:

    float

mcal.mcal.cal_eigenvalue_decomposition(mobility_tensor: ndarray[Any, dtype[float64]]) → Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

  Calculate eigenvalue decomposition of mobility tensor

  Parameters:

    mobility_tensor (NDArray[np.float64]) – Mobility tensor

  Returns:

    Eigenvalue(mobility value) and eigenvector(mobility vector)

  Return type:

    Tuple[NDArray[np.float64], NDArray[np.float64]]

mcal.mcal.cal_min_distance(symbols1: ndarray[Any, dtype[str]], coords1: ndarray[Any, dtype[float64]], symbols2: ndarray[Any, dtype[str]], coords2: ndarray[Any, dtype[float64]]) → float

  Calculate minimum distance between two sets of atoms.

  Parameters:

    - symbols1 (NDArray[str]) – Symbols of atoms in one monomer

    - coords1 (NDArray[np.float64]) – Coordinates of atoms in one monomer

    - symbols2 (NDArray[str]) – Symbols of atoms in another monomer

    - coords2 (NDArray[np.float64]) – Coordinates of atoms in another monomer

  Returns:

    Minimum distance between two sets of atoms

  Return type:

    float

mcal.mcal.cal_moment_of_inertia(symbols1: ndarray[Any, dtype[str]], coordinates1: ndarray[Any, dtype[float64]], symbols2: ndarray[Any, dtype[str]], coordinates2: ndarray[Any, dtype[float64]]) → Tuple[ndarray[Any, dtype[float64]], ndarray[Any, dtype[float64]]]

  Calculate moment of inertia and eigenvectors of the inertia tensor.

  Parameters:

    - symbols1 (NDArray[str]) – Symbols of atoms in one monomer

    - coordinates1 (NDArray[np.float64]) – Coordinates of atoms in one monomer

    - symbols2 (NDArray[str]) – Symbols of atoms in another monomer

    - coordinates2 (NDArray[np.float64]) – Coordinates of atoms in another monomer

  Returns:

    Moment of inertia and eigenvectors of the inertia tensor

  Return type:

    Tuple[NDArray[np.float64], NDArray[np.float64]]

mcal.mcal.check_reorganization_energy_completion(cif_path_without_ext: str, osc_type: Literal['p', 'n'], extension_log: str = '.log') → List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']]

  Check if all reorganization energy calculations are completed normally.

  Parameters:

    - cif_path_without_ext (str) – Base path of cif file (without extension)

    - osc_type (Literal['p', 'n']) – Semiconductor type (p-type or n-type)

    - extension_log (str) – Extension of log file

  Returns:

    List of calculations to skip

  Return type:

    List[Literal[‘opt_neutral’, ‘opt_ion’, ‘neutral’, ‘ion’]]

mcal.mcal.check_transfer_integral_completion(gjf_file: str, extension_log: str = '.log') → bool

  Check if all transfer integral calculations are completed normally.

  Parameters:

    gjf_file (str) – Base path of gjf file (without extension)

  Returns:

    True if all calculations (dimer, monomer1, monomer2) terminated normally

  Return type:

    bool

mcal.mcal.create_reorg_gjf(symbols: ndarray[Any, dtype[str]], coordinates: ndarray[Any, dtype[float64]], basename: str, save_dir: str, cpu: int, mem: int, method: str) → None

  Create gjf file for reorganization energy calculation.

  Parameters:

    - symbols (NDArray[str]) – Symbols of atoms

    - coordinates (NDArray[np.float64]) – Coordinates of atoms

    - basename (str) – Base name of gjf file

    - save_dir (str) – Directory to save gjf file

    - cpu (int) – Number of cpu

    - mem (int) – Number of memory [GB]

    - method (str) – Calculation method used in Gaussian calculations

mcal.mcal.create_ti_gjf(unique_mol: Dict[str, ndarray[Any, dtype[str]] | ndarray[Any, dtype[float64]]], neighbor_mol: Dict[str, ndarray[Any, dtype[str]] | ndarray[Any, dtype[float64]]], gjf_basename: str, save_dir: str = '.', cpu: int = 4, mem: int = 16, method: str = 'B3LYP/6-31G*') → None

  Create gjf file for transfer integral calculation.

  Parameters:

    - unique_mol (Dict[str, Union[NDArray[str], NDArray[np.float64]]]) – Dictionary containing symbols and coordinates of unique monomer

    - neighbor_mol (Dict[str, Union[NDArray[str], NDArray[np.float64]]]) – Dictionary containing symbols and coordinates of neighbor monomer

    - gjf_basename (str) – Base name of gjf file

    - save_dir (str) – Directory to save gjf file, by default ‘.’

    - cpu (int) – Number of cpu, by default 4

    - mem (int) – Number of memory [GB], by default 16

    - method (str) – Calculation method used in Gaussian calculations, by default ‘B3LYP/6-31G(d,p)’

mcal.mcal.main()

  Calculate mobility tensor considering anisotropy and path continuity.

  Examples

  Basic usage:

    - Calculate p-type mobility for xxx crystal

    $ python hop_mcal.py xxx.cif p

    - Calculate n-type mobility for xxx crystal

    $ python hop_mcal.py xxx.cif n

  With resource options:

    - Use 8 CPUs and 16GB memory

    $ python hop_mcal.py xxx.cif p -c 8 -m 16

    - Use different calculation method (default is B3LYP/6-31G(d,p))

    $ python hop_mcal.py xxx.cif p -M “B3LYP/6-311G(d,p)”

  High-precision calculation:

    - Calculate all transfer integrals without speedup using moment of inertia and distance between centers of weight

    $ python hop_mcal.py xxx.cif p –fullcal

    - Expand calculation range to 3x3x3 supercell

    $ python hop_mcal.py xxx.cif p –cellsize 1

    - Expand calculation range to 5x5x5 supercell to widen transfer integral calculation range

    $ python hop_mcal.py xxx.cif p –cellsize 2

  Resume and save results:

    - Resume from existing calculations

    $ python hop_mcal.py xxx.cif p –resume

    - Save results to pickle file

    $ python hop_mcal.py xxx.cif p –pickle

    - Read results from existing pickle file

    $ python hop_mcal.py xxx_result.pkl p -rp

    - Read results from existing log files without running Gaussian

    $ python hop_mcal.py xxx.cif p -r

  Compare calculation methods:

    - Compare results using kinetic Monte Carlo and ODE methods

    $ python hop_mcal.py xxx.cif p –mc –ode

mcal.mcal.print_mobility(value: ndarray[Any, dtype[float64]], vector: ndarray[Any, dtype[float64]], sim_type: Literal['MC', 'ODE'] = '')

  Print mobility and mobility vector

  Parameters:

    - value (NDArray[np.float64]) – Mobility value

    - vector (NDArray[np.float64]) – Mobility vector

    - sim_type (str) – Simulation type (MC or ODE)

mcal.mcal.print_reorg_energy(osc_type: Literal['p', 'n'], reorg_energy: float)

  Print reorganization energy

  Parameters:

    - osc_type (Literal['p', 'n']) – Semiconductor type (p-type or n-type)

    - reorg_energy (float) – Reorganization energy [eV]

mcal.mcal.print_tensor(mu: ndarray[Any, dtype[float64]], msg: str = 'Mobility tensor')

  Print mobility tensor

  Parameters:

    - mu (NDArray[np.float64]) – Mobility tensor

    - msg (str) – Message, by default ‘Mobility tensor’

mcal.mcal.print_transfer_integral(osc_type: Literal['p', 'n'], transfer: float)

  Print transfer integral

  Parameters:

    - osc_type (Literal['p', 'n']) – Semiconductor type (p-type or n-type)

    - transfer (float) – Transfer integral [eV]

mcal.mcal.read_pickle(file_name: str)

## Module contents