tcal package

Submodules

tcal.tcal module

Tcal

class tcal.tcal.PairAnalysis(apta: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])[source]

Bases: object

Analyze atomic pair transfer integrals.

print_element_pairs() None[source]

Print element pairs.

print_largest_pairs() None[source]

Print largest pairs.

class tcal.tcal.Tcal(file: str, monomer1_atom_num: int = -1)[source]

Bases: object

Calculate transfer integrals.

EV: float = 27211.38456571948
atomic_pair_transfer_analysis(analyze_orbital: Literal['HOMO', 'LUMO'] = 'HOMO', output_apta: bool = False) ndarray[Any, dtype[float64]][source]

Calculate atomic pair transfer integrals.

Parameters:
  • analyze_orbital (str) – Analyze orbital., default ‘HOMO’

  • output_apta (bool) – If it is True, output csv file of atomic pair transfer integrals., default False

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static cal_transfer_integrals(bra: ndarray[Any, dtype[float64]], overlap: ndarray[Any, dtype[float64]], fock: ndarray[Any, dtype[float64]], ket: ndarray[Any, dtype[float64]]) float[source]

Calculate intermolecular transfer integrals.

Parameters:
  • bra (numpy.array) – MO coefficients of one molecule.

  • overlap (numpy.array) – Overlap matrix of dimer.

  • fock (numpy.array) – Fock matrix of dimer.

  • ket (numpy.array) – MO coefficients of the other molecule.

Returns:

Intermolecular transfer integrals.

Return type:

float

check_extension_log() None[source]

Check the extension of log file.

static check_normal_termination(reader: TextIO) TextIO[source]

Whether the calculation of gaussian was successful or not.

Parameters:

reader (_io.TextIOWrapper) – Return value of open function.

Returns:

Return value of function.

Return type:

_io.TextIOWrapper

Examples

>>> with open('sample.log', 'r') as f:
...     f = Tcal.check_normal_termination(f)
convert_xyz_to_gjf(function: str = 'B3LYP/6-31G(d,p)', nprocshared: int = 4, mem: int = 16, unit: str = 'GB') None[source]

Convert xyz file to gjf file.

Parameters:
  • function (str) – Gaussian calculation method and basis set., default ‘b3lyp/6-31g(d,p)’

  • nprocshared (int) – The number of nprocshared., default 4

  • mem (int) – The number of memory., default 16

  • unit (str) – The unit of memory., default ‘GB’

create_cube_file() None[source]

Create cube file.

create_monomer_file() None[source]

Create gjf files of monomer from gjf file of dimer.

custom_atomic_pair_transfer_analysis(analyze_orb1: int, analyze_orb2: int, output_apta: bool = False) ndarray[Any, dtype[float64]][source]

Calculate atomic pair transfer integrals.

Parameters:
  • analyze_orb1 (int) – Analyze orbital., default -1

  • analyze_orb2 (int) – Analyze orbital., default -1

  • output_apta (bool) – If it is True, output csv file of atomic pair transfer integrals., default False

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static extract_coordinates(reader: TextIO) Tuple[TextIO, List[str]][source]

Extract coordinates from gjf file of dimer.

Parameters:

reader (_io.TextIOWrapper) – Return value of open function.

Returns:

  • _io.TextIOWrapper – Return value of open function.

  • list – The list of coordinates.

Examples

>>> import re
>>> with open(f'sample.gjf', 'r') as f:
...     while True:
...         line = f.readline()
...         if not line:
...             break
...         if re.search('[-0-9]+ [0-3]', line):
...             f, coordinates = Tcal.extract_coordinates(f)
static extract_num(pattern: str, line: str, idx: int = 0) int | None[source]

Extract integer in strings.

Parameters:
  • pattern (str) – Strings using regular expression.

  • line (str) – String of target.

  • idx (int) – Index of integer. default 0

Returns:

If there is integer, return it.

Return type:

int or None

static output_csv(file_name: str, array: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None[source]

Output csv file of array.

Parameters:
  • file_name (str) – File name including extension.

  • array (array_like) – Array to create csv file.

print_apta(a_transfer: ndarray[Any, dtype[float64]], message: str = 'Atomic Pair Transfer Analysis') ndarray[Any, dtype[float64]][source]

Create list of apta and print it.

Parameters:
  • a_transfer (numpy.array) – Result of atomic pair transfer analysis.

  • message (str) – Message to print., default ‘Atomic Pair Transfer Analysis’

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static print_matrix(matrix: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None[source]

Print matrix.

Parameters:

matrix (array_like)

static print_timestamp() None[source]

Print timestamp.

print_transfer_integral_diff_levels(nlevel: int, output_ti_diff_levels: bool = False) None[source]

Print transfer integrals between different orbitals.

Parameters:
  • nlevel (int) – The number of levels to print.

  • output_ti_diff_levels (bool) – If it is True, output csv file of transfer integrals between different orbitals., default False

print_transfer_integrals() None[source]

Print transfer integrals of NLUMO, LUMO, HOMO and NHOMO.

read_dimer(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract overlap and fock matrix from log file of dimer.

Parameters:
  • is_matrix (bool) – If it is True, print overlap and fock matrix., default False

  • output_matrix (bool) – If it is True, Output overlap and fock matrix., default False

static read_matrix(reader: TextIO, n_basis: int, n_bsuse: int) ndarray[Any, dtype[float64]][source]

Read matrix.

Parameters:
  • reader (_io.TextIOWrapper) – Return value of open function.

  • n_basis (int) – The number of row.

  • n_bsuse (int) – The number of column.

Returns:

Read matrix like MO coefficients.

Return type:

numpy.array

read_monomer1(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from log file of monomer.

Parameters:
  • is_matrix (bool) – If it is True, print MO coefficients., default False

  • output_matrix (bool) – If it is True, Output MO coefficients., default False

read_monomer2(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from log file of monomer.

Parameters:
  • is_matrix (bool, optional) – If it is True, print MO coefficients., default False

  • output_matrix (bool, optional) – If it is True, Output MO coefficients., default False

static read_symmetric_matrix(reader: TextIO, n_basis: int) ndarray[Any, dtype[float64]][source]

Read symmetric matrix.

Parameters:
  • reader (_io.TextIOWrapper) – Return value of open function.

  • n_basis (int) – The number of column or row.

Returns:

Read symmetrix matrix like overlap or fock matrix.

Return type:

numpy.array

run_gaussian(gaussian_command: str, skip_monomer_num: List[int] = [0]) int[source]

Execute gjf files using gaussian.

Parameters:
  • gaussian_command (str) – Command of gaussian.

  • skip_monomer_num (list[int]) – If it is 1, skip 1st monomer calculation. If it is 2, skip 2nd monomer calculation. If it is 3, skip dimer calculation.

Returns:

Returncode of subprocess.run.

Return type:

int

tcal.tcal.main()[source]

This code is to execute tcal for command line.

tcal.tcal_pyscf module

TcalPySCF

class tcal.tcal_pyscf.TcalPySCF(file: str, monomer1_atom_num: int = -1, method: str = 'B3LYP/6-31G(d,p)', charge: int = 0, spin: int = 0, use_gpu: bool = False, ncore: int = 4, max_memory_gb: int = 16, cart: bool = False)[source]

Bases: Tcal

Calculate transfer integrals using PySCF.

create_cube_file() None[source]

Generate NHOMO/HOMO/LUMO/NLUMO cube files for both monomers.

read_dimer(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract overlap and Fock matrix from PySCF result of dimer.

Parameters:
  • is_matrix (bool) – If True, print overlap and Fock matrices. default False

  • output_matrix (bool) – If True, output overlap and Fock matrices to CSV. default False

read_monomer1(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from PySCF result of monomer 1.

Parameters:
  • is_matrix (bool) – If True, print MO coefficients. default False

  • output_matrix (bool) – If True, output MO coefficients to CSV. default False

read_monomer2(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from PySCF result of monomer 2.

Parameters:
  • is_matrix (bool) – If True, print MO coefficients. default False

  • output_matrix (bool) – If True, output MO coefficients to CSV. default False

run_pyscf(skip_monomer_num: List[int] = [0]) None[source]

Run PySCF calculations for monomers and dimer.

Parameters:

skip_monomer_num (list[int]) – If 1 is in the list, skip 1st monomer calculation. If 2 is in the list, skip 2nd monomer calculation. If 3 is in the list, skip dimer calculation.

Module contents

class tcal.PairAnalysis(apta: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes])[source]

Bases: object

Analyze atomic pair transfer integrals.

print_element_pairs() None[source]

Print element pairs.

print_largest_pairs() None[source]

Print largest pairs.

class tcal.Tcal(file: str, monomer1_atom_num: int = -1)[source]

Bases: object

Calculate transfer integrals.

EV: float = 27211.38456571948
atomic_pair_transfer_analysis(analyze_orbital: Literal['HOMO', 'LUMO'] = 'HOMO', output_apta: bool = False) ndarray[Any, dtype[float64]][source]

Calculate atomic pair transfer integrals.

Parameters:
  • analyze_orbital (str) – Analyze orbital., default ‘HOMO’

  • output_apta (bool) – If it is True, output csv file of atomic pair transfer integrals., default False

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static cal_transfer_integrals(bra: ndarray[Any, dtype[float64]], overlap: ndarray[Any, dtype[float64]], fock: ndarray[Any, dtype[float64]], ket: ndarray[Any, dtype[float64]]) float[source]

Calculate intermolecular transfer integrals.

Parameters:
  • bra (numpy.array) – MO coefficients of one molecule.

  • overlap (numpy.array) – Overlap matrix of dimer.

  • fock (numpy.array) – Fock matrix of dimer.

  • ket (numpy.array) – MO coefficients of the other molecule.

Returns:

Intermolecular transfer integrals.

Return type:

float

check_extension_log() None[source]

Check the extension of log file.

static check_normal_termination(reader: TextIO) TextIO[source]

Whether the calculation of gaussian was successful or not.

Parameters:

reader (_io.TextIOWrapper) – Return value of open function.

Returns:

Return value of function.

Return type:

_io.TextIOWrapper

Examples

>>> with open('sample.log', 'r') as f:
...     f = Tcal.check_normal_termination(f)
convert_xyz_to_gjf(function: str = 'B3LYP/6-31G(d,p)', nprocshared: int = 4, mem: int = 16, unit: str = 'GB') None[source]

Convert xyz file to gjf file.

Parameters:
  • function (str) – Gaussian calculation method and basis set., default ‘b3lyp/6-31g(d,p)’

  • nprocshared (int) – The number of nprocshared., default 4

  • mem (int) – The number of memory., default 16

  • unit (str) – The unit of memory., default ‘GB’

create_cube_file() None[source]

Create cube file.

create_monomer_file() None[source]

Create gjf files of monomer from gjf file of dimer.

custom_atomic_pair_transfer_analysis(analyze_orb1: int, analyze_orb2: int, output_apta: bool = False) ndarray[Any, dtype[float64]][source]

Calculate atomic pair transfer integrals.

Parameters:
  • analyze_orb1 (int) – Analyze orbital., default -1

  • analyze_orb2 (int) – Analyze orbital., default -1

  • output_apta (bool) – If it is True, output csv file of atomic pair transfer integrals., default False

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static extract_coordinates(reader: TextIO) Tuple[TextIO, List[str]][source]

Extract coordinates from gjf file of dimer.

Parameters:

reader (_io.TextIOWrapper) – Return value of open function.

Returns:

  • _io.TextIOWrapper – Return value of open function.

  • list – The list of coordinates.

Examples

>>> import re
>>> with open(f'sample.gjf', 'r') as f:
...     while True:
...         line = f.readline()
...         if not line:
...             break
...         if re.search('[-0-9]+ [0-3]', line):
...             f, coordinates = Tcal.extract_coordinates(f)
static extract_num(pattern: str, line: str, idx: int = 0) int | None[source]

Extract integer in strings.

Parameters:
  • pattern (str) – Strings using regular expression.

  • line (str) – String of target.

  • idx (int) – Index of integer. default 0

Returns:

If there is integer, return it.

Return type:

int or None

static output_csv(file_name: str, array: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None[source]

Output csv file of array.

Parameters:
  • file_name (str) – File name including extension.

  • array (array_like) – Array to create csv file.

print_apta(a_transfer: ndarray[Any, dtype[float64]], message: str = 'Atomic Pair Transfer Analysis') ndarray[Any, dtype[float64]][source]

Create list of apta and print it.

Parameters:
  • a_transfer (numpy.array) – Result of atomic pair transfer analysis.

  • message (str) – Message to print., default ‘Atomic Pair Transfer Analysis’

Returns:

The array of atomic pair transfer analysis.

Return type:

numpy.array

static print_matrix(matrix: _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes]) None[source]

Print matrix.

Parameters:

matrix (array_like)

static print_timestamp() None[source]

Print timestamp.

print_transfer_integral_diff_levels(nlevel: int, output_ti_diff_levels: bool = False) None[source]

Print transfer integrals between different orbitals.

Parameters:
  • nlevel (int) – The number of levels to print.

  • output_ti_diff_levels (bool) – If it is True, output csv file of transfer integrals between different orbitals., default False

print_transfer_integrals() None[source]

Print transfer integrals of NLUMO, LUMO, HOMO and NHOMO.

read_dimer(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract overlap and fock matrix from log file of dimer.

Parameters:
  • is_matrix (bool) – If it is True, print overlap and fock matrix., default False

  • output_matrix (bool) – If it is True, Output overlap and fock matrix., default False

static read_matrix(reader: TextIO, n_basis: int, n_bsuse: int) ndarray[Any, dtype[float64]][source]

Read matrix.

Parameters:
  • reader (_io.TextIOWrapper) – Return value of open function.

  • n_basis (int) – The number of row.

  • n_bsuse (int) – The number of column.

Returns:

Read matrix like MO coefficients.

Return type:

numpy.array

read_monomer1(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from log file of monomer.

Parameters:
  • is_matrix (bool) – If it is True, print MO coefficients., default False

  • output_matrix (bool) – If it is True, Output MO coefficients., default False

read_monomer2(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from log file of monomer.

Parameters:
  • is_matrix (bool, optional) – If it is True, print MO coefficients., default False

  • output_matrix (bool, optional) – If it is True, Output MO coefficients., default False

static read_symmetric_matrix(reader: TextIO, n_basis: int) ndarray[Any, dtype[float64]][source]

Read symmetric matrix.

Parameters:
  • reader (_io.TextIOWrapper) – Return value of open function.

  • n_basis (int) – The number of column or row.

Returns:

Read symmetrix matrix like overlap or fock matrix.

Return type:

numpy.array

run_gaussian(gaussian_command: str, skip_monomer_num: List[int] = [0]) int[source]

Execute gjf files using gaussian.

Parameters:
  • gaussian_command (str) – Command of gaussian.

  • skip_monomer_num (list[int]) – If it is 1, skip 1st monomer calculation. If it is 2, skip 2nd monomer calculation. If it is 3, skip dimer calculation.

Returns:

Returncode of subprocess.run.

Return type:

int

class tcal.TcalPySCF(file: str, monomer1_atom_num: int = -1, method: str = 'B3LYP/6-31G(d,p)', charge: int = 0, spin: int = 0, use_gpu: bool = False, ncore: int = 4, max_memory_gb: int = 16, cart: bool = False)[source]

Bases: Tcal

Calculate transfer integrals using PySCF.

create_cube_file() None[source]

Generate NHOMO/HOMO/LUMO/NLUMO cube files for both monomers.

read_dimer(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract overlap and Fock matrix from PySCF result of dimer.

Parameters:
  • is_matrix (bool) – If True, print overlap and Fock matrices. default False

  • output_matrix (bool) – If True, output overlap and Fock matrices to CSV. default False

read_monomer1(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from PySCF result of monomer 1.

Parameters:
  • is_matrix (bool) – If True, print MO coefficients. default False

  • output_matrix (bool) – If True, output MO coefficients to CSV. default False

read_monomer2(is_matrix: bool = False, output_matrix: bool = False) None[source]

Extract MO coefficients from PySCF result of monomer 2.

Parameters:
  • is_matrix (bool) – If True, print MO coefficients. default False

  • output_matrix (bool) – If True, output MO coefficients to CSV. default False

run_pyscf(skip_monomer_num: List[int] = [0]) None[source]

Run PySCF calculations for monomers and dimer.

Parameters:

skip_monomer_num (list[int]) – If 1 is in the list, skip 1st monomer calculation. If 2 is in the list, skip 2nd monomer calculation. If 3 is in the list, skip dimer calculation.