mcal package¶
Subpackages¶
- mcal.calculations package
- mcal.utils package
- Submodules
- mcal.utils.cif_reader module
- mcal.utils.gaus_log_reader module
- mcal.utils.gjf_maker module
GjfMakerGjfMaker.ELEMENTS_NUMGjfMaker.ELEMENT_PROPGjfMaker.add_link()GjfMaker.add_root()GjfMaker.create_chk_file()GjfMaker.create_rwf_file()GjfMaker.export_gjf()GjfMaker.opt()GjfMaker.output_detail()GjfMaker.parent_dirGjfMaker.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
- mcal.mcal.atom_weight(symbol: str) float[source]¶
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]][source]¶
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[source]¶
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]]][source]¶
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[source]¶
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]]][source]¶
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']][source]¶
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_reorganization_energy_completion_pyscf(cif_path_without_ext: str, osc_type: Literal['p', 'n']) List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']][source]¶
Check if PySCF reorganization energy calculations are completed.
- 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)
- 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[source]¶
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.check_transfer_integral_completion_pyscf(input_file: str) bool[source]¶
Check if TcalPySCF calculation is completed by reading job_status/completed from all chkfiles.
- Parameters:
input_file (str) – Base path of input file (without extension)
- Returns:
True if all chkfiles (dimer, monomer1, monomer2) have job_status/completed flag
- 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[source]¶
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_reorg_xyz(symbols: ndarray[Any, dtype[str]], coordinates: ndarray[Any, dtype[float64]], basename: str, save_dir: str) None[source]¶
Create xyz file for reorganization energy calculation.
- Parameters:
symbols (NDArray[str]) – Symbols of atoms
coordinates (NDArray[np.float64]) – Coordinates of atoms
basename (str) – Base name of xyz file
save_dir (str) – Directory to save xyz file
- 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[source]¶
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.create_ti_xyz(unique_mol: Dict[str, ndarray[Any, dtype[str]] | ndarray[Any, dtype[float64]]], neighbor_mol: Dict[str, ndarray[Any, dtype[str]] | ndarray[Any, dtype[float64]]], input_basename: str, save_dir: str = '.') None[source]¶
Create xyz file for transfer integral calculation (dimer).
- 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
input_basename (str) – Base name of xyz file
save_dir (str) – Directory to save xyz file, by default ‘.’
- mcal.mcal.main()[source]¶
Calculate mobility tensor considering anisotropy and path continuity.
Examples
- Basic usage:
Calculate p-type mobility for xxx crystal
$ mcal xxx.cif p
Calculate n-type mobility for xxx crystal
$ mcal xxx.cif n
- With resource options:
Use 8 CPUs and 16GB memory
$ mcal xxx.cif p -c 8 -m 16
Use different calculation method (default is B3LYP/6-31G(d,p))
$ mcal 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
$ mcal xxx.cif p –fullcal
Expand calculation range to 5x5x5 supercell to widen transfer integral calculation range
$ mcal xxx.cif p –cellsize 2
- Resume and save results:
Resume from existing calculations
$ mcal xxx.cif p –resume
Save results to pickle file
$ mcal xxx.cif p –pickle
Read results from existing pickle file
$ mcal xxx_result.pkl p -rp
Read results from existing log files without running Gaussian
$ mcal xxx.cif p -r
- Plot mobility tensor in 2D plane:
Plot mobility tensor in 2D plane (Examples: ab, ac, ba, bc, ca, cb (default is ab))
$ python hop_mcal.py xxx.cif p –plot-plane ab
- mcal.mcal.plot_mobility_2d(save_path: Path, mobility_tensor: ndarray[Any, dtype[float64]], lattice: ndarray[Any, dtype[float64]], plane: Literal['ab', 'ac', 'ba', 'bc', 'ca', 'cb'] = 'ab') None[source]¶
Plot mobility tensor in 2D plane.
- Parameters:
save_path (Path) – Path to save the plot
mobility_tensor (NDArray[np.float64]) – Mobility tensor
lattice (NDArray[np.float64]) – Lattice vectors [Å]
plane (Literal['ab', 'ac', 'ba', 'bc', 'ca', 'cb']) – Plane to plot, by default ‘ab’
- mcal.mcal.print_mobility(value: ndarray[Any, dtype[float64]], vector: ndarray[Any, dtype[float64]], sim_type: Literal['MC', 'ODE'] = '')[source]¶
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)[source]¶
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')[source]¶
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)[source]¶
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, plot_plane: Literal['ab', 'ac', 'ba', 'bc', 'ca', 'cb'] | None = None) None[source]¶
Read pickle file and plot mobility tensor in 2D plane.
- Parameters:
file_name (str) – Path to the pickle file
plot_plane (Optional[Literal['ab', 'ac', 'ba', 'bc', 'ca', 'cb']]) – Plane to plot, by default None
Module contents¶
- class mcal.CifReader(cif_path: str)[source]¶
Bases:
objectCifReader class.
This class is used to read cif file and extract crystal information.
- Raises:
ElementPropertiesIsNotDefinedError – Raised when element properties is not defined.
SymmetryIsNotDefinedError – Raised when symmetry is not defined.
ZValueIsNotMatchError – Raised when z value is not match. The atomic bond detection may not be functioning correctly.
- ATOMIC_WEIGHTS = {'Ag': 107.87, 'Al': 26.982, 'Ar': 39.95, 'As': 74.922, 'Au': 196.97, 'B': 10.81, 'Ba': 137.33, 'Be': 9.0122, 'Bi': 208.98, 'Br': 79.904, 'C': 12.011, 'Ca': 40.078, 'Cd': 112.41, 'Ce': 140.12, 'Cl': 35.45, 'Co': 58.933, 'Cr': 51.996, 'Cs': 132.91, 'Cu': 63.546, 'D': 2.014, 'Dy': 162.5, 'Er': 167.26, 'Eu': 151.96, 'F': 18.998, 'Fe': 55.845, 'Ga': 69.723, 'Gd': 157.25, 'Ge': 72.63, 'H': 1.008, 'He': 4.0026, 'Hf': 178.49, 'Hg': 200.59, 'Ho': 164.93, 'I': 126.9, 'In': 114.82, 'Ir': 192.22, 'K': 39.098, 'Kr': 83.798, 'La': 138.91, 'Li': 6.94, 'Lu': 174.97, 'Mg': 24.305, 'Mn': 54.938, 'Mo': 95.95, 'N': 14.007, 'Na': 22.99, 'Nb': 92.906, 'Nd': 144.24, 'Ne': 20.18, 'Ni': 58.693, 'O': 15.999, 'Os': 190.23, 'P': 30.974, 'Pa': 231.04, 'Pb': 207.2, 'Pd': 106.42, 'Pt': 195.08, 'Rb': 85.468, 'Re': 186.21, 'Rh': 102.91, 'Ru': 101.07, 'S': 32.06, 'Sb': 121.76, 'Sc': 44.956, 'Se': 78.971, 'Si': 28.085, 'Sm': 150.36, 'Sn': 118.71, 'Sr': 87.62, 'Ta': 180.95, 'Tb': 158.93, 'Te': 127.6, 'Th': 232.04, 'Ti': 47.867, 'Tl': 204.38, 'Tm': 168.93, 'U': 238.03, 'V': 50.942, 'W': 183.84, 'X': 0.0, 'Xe': 131.29, 'Y': 88.906, 'Yb': 173.05, 'Zn': 65.38, 'Zr': 91.224}¶
- COVALENT_RADII = {'Ag': 1.45, 'Al': 1.21, 'Ar': 1.06, 'As': 1.19, 'Au': 1.36, 'B': 0.84, 'Ba': 2.15, 'Be': 0.96, 'Bi': 1.48, 'Br': 1.2, 'C': 0.76, 'Ca': 1.76, 'Cd': 1.44, 'Ce': 2.04, 'Cl': 1.02, 'Co': 1.5, 'Cr': 1.39, 'Cs': 2.44, 'Cu': 1.32, 'D': 0.31, 'Dy': 1.92, 'Er': 1.89, 'Eu': 1.98, 'F': 0.57, 'Fe': 1.52, 'Ga': 1.22, 'Gd': 1.96, 'Ge': 1.2, 'H': 0.31, 'He': 0.28, 'Hf': 1.75, 'Hg': 1.32, 'Ho': 1.92, 'I': 1.39, 'In': 1.42, 'Ir': 1.41, 'K': 2.03, 'Kr': 1.16, 'La': 2.07, 'Li': 1.28, 'Lu': 1.87, 'Mg': 1.41, 'Mn': 1.61, 'Mo': 1.54, 'N': 0.71, 'Na': 1.66, 'Nb': 1.64, 'Nd': 2.01, 'Ne': 0.58, 'Ni': 1.24, 'O': 0.66, 'Os': 1.44, 'P': 1.07, 'Pa': 2.0, 'Pb': 1.46, 'Pd': 1.39, 'Pt': 1.36, 'Rb': 2.2, 'Re': 1.51, 'Rh': 1.42, 'Ru': 1.46, 'S': 1.05, 'Sb': 1.39, 'Sc': 1.7, 'Se': 1.2, 'Si': 1.11, 'Sm': 1.98, 'Sn': 1.39, 'Sr': 1.95, 'Ta': 1.7, 'Tb': 1.94, 'Te': 1.38, 'Th': 2.06, 'Ti': 1.6, 'Tl': 1.45, 'Tm': 1.9, 'U': 1.96, 'V': 1.53, 'W': 1.62, 'X': 0.0, 'Xe': 1.4, 'Y': 1.9, 'Yb': 1.87, 'Zn': 1.22, 'Zr': 1.75}¶
- ELEMENT_PROP = number symbol name period group weight vdw_radius covalent_radius 0 0 X Dummy 0 0 0.0000 0.00 0.00 1 1 H Hydrogen 1 1 1.0080 1.20 0.31 2 1 D Deuterium 1 1 2.0140 1.20 0.31 3 2 He Helium 1 18 4.0026 1.43 0.28 4 3 Li Lithium 2 1 6.9400 2.12 1.28 .. ... ... ... ... ... ... ... ... 83 82 Pb Lead 6 14 207.2000 2.60 1.46 84 83 Bi Bismuth 6 15 208.9800 2.54 1.48 91 90 Th Thorium 7 3 232.0400 2.93 2.06 92 91 Pa Protactinium 7 3 231.0400 2.88 2.00 93 92 U Uranium 7 3 238.0300 2.71 1.96 [85 rows x 8 columns]¶
- calc_cen_of_weight(coordinates: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]][source]¶
Calculate center of weight.
- Parameters:
coordinates (NDArray[np.float64]) – Coordinates of monomolecular.
- Returns:
Center of weight.
- Return type:
NDArray[np.float64]
- convert_cart_to_frac(cart_coord: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]][source]¶
Convert Cartesian coordinates to fractional coordinates.
- Parameters:
cart_coord (NDArray[np.float64]) – Cartesian coordinates.
- Returns:
Fractional coordinates.
- Return type:
NDArray[np.float64]
- convert_frac_to_cart(frac_coord: ndarray[Any, dtype[float64]]) ndarray[Any, dtype[float64]][source]¶
Convert fractional coordinates to Cartesian coordinates.
- Parameters:
frac_coord (NDArray[np.float64]) – Fractional coordinates.
- Returns:
Cartesian coordinates.
- Return type:
NDArray[np.float64]
- expand_mols(expand_range: int = 1) Dict[Tuple[int, int, int], Dict[int, List[Tuple[str, ndarray[Any, dtype[float64]]]]]][source]¶
Generate molecules around unique molecules.
- Parameters:
expand_range (int) – The number of molecular cycles produced., by default 1
- Returns:
A nested dictionary containing the expanded molecular structure:
- Outer key: Tuple[int, int, int]
Represents the unit cell offset (i, j, k) relative to the origin unit cell. For example, (0, 0, 0) is the origin unit cell, (1, 0, 0) is one unit cell away in the a-direction, etc.
- Inner key: int
The index of the unique molecule within that unit cell.
- Value: Tuple[List[str], NDArray[np.float64]]
A list containing molecular information: - List[str]: Element symbols of the molecule - NDArray[np.float64]: Cartesian coordinates of the molecule (shape: (3, n))
- Return type:
Dict[Tuple[int, int, int], Dict[int, List[Tuple[str, NDArray[np.float64]]]]]
- export_unit_cell_file(file_path: str, format: Literal['mol', 'xyz'] = 'mol') None[source]¶
export unit cell file
- Parameters:
file_path (str) – Path of the file to be saved.
format (Literal['mol', 'xyz']) – Format of the file to be saved.
- parent_dir = PosixPath('/home/subaru/Documents/manage-with-git/mcal/src/mcal')¶
- remove_duplicates(symbol: List[str], coordinate: ndarray[Any, dtype[float64]], tol: float = 0.0001) Tuple[List[str], ndarray[Any, dtype[float64]]][source]¶
Remove duplicates from symbol and coordinate arrays based on coordinate with a given tolerance.
- Parameters:
symbol (List[str]) – Symbols of molecules.
coordinate (NDArray[np.float64]) – Coordinates of molecules.
tol (float) – Tolerance for duplicate detection.
- Returns:
Symbols and coordinates of unique molecules.
- Return type:
Tuple[List[str], NDArray[np.float64]]
- class mcal.FileReader(file_path, buffer_size=8192)[source]¶
Bases:
objectFile reader that reads line by line from the end.
Examples
>>> with FileReader('sample.txt') as f: ... while True: ... line = f.reversed_readline() ... if not line: ... break ... print(line)
- class mcal.GjfMaker(remove_radical_flag: bool = False)[source]¶
Bases:
object- ELEMENTS_NUM = {'Ac': 89, 'Ag': 47, 'Al': 13, 'Am': 95, 'Ar': 18, 'As': 33, 'At': 85, 'Au': 79, 'B': 5, 'Ba': 56, 'Be': 4, 'Bh': 107, 'Bi': 83, 'Bk': 97, 'Br': 35, 'C': 6, 'Ca': 20, 'Cd': 48, 'Ce': 58, 'Cf': 98, 'Cl': 17, 'Cm': 96, 'Cn': 112, 'Co': 27, 'Cr': 24, 'Cs': 55, 'Cu': 29, 'D': 1, 'Db': 105, 'Ds': 110, 'Dy': 66, 'Er': 68, 'Es': 99, 'Eu': 63, 'F': 9, 'Fe': 26, 'Fl': 114, 'Fm': 100, 'Fr': 87, 'Ga': 31, 'Gd': 64, 'Ge': 32, 'H': 1, 'He': 2, 'Hf': 72, 'Hg': 80, 'Ho': 67, 'Hs': 108, 'I': 53, 'In': 49, 'Ir': 77, 'K': 19, 'Kr': 36, 'La': 57, 'Li': 3, 'Lr': 103, 'Lu': 71, 'Lv': 116, 'Mc': 115, 'Md': 101, 'Mg': 12, 'Mn': 25, 'Mo': 42, 'Mt': 109, 'N': 7, 'Na': 11, 'Nb': 41, 'Nd': 60, 'Ne': 10, 'Nh': 113, 'Ni': 28, 'No': 102, 'Np': 93, 'O': 8, 'Og': 118, 'Os': 76, 'P': 15, 'Pa': 91, 'Pb': 82, 'Pd': 46, 'Pm': 61, 'Po': 84, 'Pr': 59, 'Pt': 78, 'Pu': 94, 'Ra': 88, 'Rb': 37, 'Re': 75, 'Rf': 104, 'Rg': 111, 'Rh': 45, 'Rn': 86, 'Ru': 44, 'S': 16, 'Sb': 51, 'Sc': 21, 'Se': 34, 'Sg': 106, 'Si': 14, 'Sm': 62, 'Sn': 50, 'Sr': 38, 'Ta': 73, 'Tb': 65, 'Tc': 43, 'Te': 52, 'Th': 90, 'Ti': 22, 'Tl': 81, 'Tm': 69, 'Ts': 117, 'U': 92, 'V': 23, 'W': 74, 'X': 0, 'Xe': 54, 'Y': 39, 'Yb': 70, 'Zn': 30, 'Zr': 40}¶
- ELEMENT_PROP = number symbol name period group weight vdw_radius covalent_radius 0 0 X Dummy 0 0 0.0000 0.00 0.00 1 1 H Hydrogen 1 1 1.0080 1.20 0.31 2 1 D Deuterium 1 1 2.0140 1.20 0.31 3 2 He Helium 1 18 4.0026 1.43 0.28 4 3 Li Lithium 2 1 6.9400 2.12 1.28 .. ... ... ... ... ... ... ... ... 115 114 Fl Flerovium 7 14 NaN NaN NaN 116 115 Mc Moscovium 7 15 NaN NaN NaN 117 116 Lv Livermorium 7 16 NaN NaN NaN 118 117 Ts Tennessine 7 17 NaN NaN NaN 119 118 Og Oganesson 7 18 NaN NaN NaN [120 rows x 8 columns]¶
- export_gjf(file_name: str, save_dir: str = '.', chk_rwf_name: str | None = None) None[source]¶
Export the gjf file.
- Parameters:
file_name (str) – Name of the gjf file.
save_dir (str) – Directory to save the gjf file.
chk_rwf_name (Optional[str]) – Name of the chk or rwf file.
- opt(tight: bool = True) None[source]¶
Set the optimization option of the gjf file.
- Parameters:
tight (bool) – If True, the optimization is tight, by default True.
- parent_dir = PosixPath('/home/subaru/Documents/manage-with-git/mcal/src/mcal')¶
- set_charge_spin(charge: int, spin: int) None[source]¶
Set the charge and spin of the molecule.
- Parameters:
charge (int) – Charge of the molecule.
spin (int) – Spin of the molecule.
- set_coordinates(coordinates: List[Tuple[float, float, float]]) None[source]¶
Set the coordinates of the molecule.
- Parameters:
coordinates (List[Tuple[float, float, float]]) – Coordinates of the molecule.
- set_function(function: str) None[source]¶
Set the function of the gjf file.
- Parameters:
function (str) – Function of the gjf file.
- set_resource(cpu_num: int, mem_num: int, mem_unit: str = 'GB') None[source]¶
Set the number of cpu and memory.
- Parameters:
cpu_num (int) – Number of cpu.
mem_num (int) – Number of memory.
mem_unit (str) – Unit of memory, by default ‘GB’.
- class mcal.Rcal(input_file: str, osc_type: Literal['p', 'n'] = 'p', fmt='gjf')[source]¶
Bases:
objectCalculate reorganization energy.
- calc_reorganization(gau_com: str = 'g16', only_read: bool = False, is_output_detail: bool = False, skip_specified_cal: List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']] = []) float[source]¶
Calculate reorganization energy.
- Parameters:
gau_com (str) – Gaussian command, by default ‘g16’.
only_read (bool) – if True, the calculation is only read, by default False.
is_output_detail (bool) – if True, the calculation detail will be output, by default False.
skip_specified_cal (List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']]) – if specified, the calculation of the specified type will be skipped, by default [].
- Returns:
reorganization energy [eV].
- Return type:
float
- static check_error_term(line: str) None[source]¶
Check the error term of Gaussian.
- Parameters:
line (str) – last line of the log file.
- Raises:
GausTermError – if the calculation of Gaussian was error termination.
- check_extension_log(gjf: str) None[source]¶
Check the extension of log file.
- Parameters:
gjf (str) – gjf file name.
- extract_energy(gjf: str, only_read: bool = False, is_output_detail: bool = False, skip_cal: bool = False) float[source]¶
Extract energy from log file.
- Parameters:
gjf (str) – gjf file name.
only_read (bool) – if True, the calculation is only read, by default False.
is_output_detail (bool) – if True, the calculation detail will be output, by default False.
- Returns:
total energy.
- Return type:
float
- class mcal.RcalPySCF(xyz_file: str, osc_type: Literal['p', 'n'] = 'p', method: str = 'B3LYP/6-31G(d,p)', use_gpu: bool = False, ncore: int = 4, max_memory_gb: int = 16, cart: bool = False)[source]¶
Bases:
RcalCalculate reorganization energy using PySCF.
- HARTREE_TO_EV = 27.2114¶
- calc_reorganization(gau_com: str = 'g16', only_read: bool = False, is_output_detail: bool = False, skip_specified_cal: List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']] = []) float[source]¶
Calculate reorganization energy.
- Parameters:
gau_com (str) – Ignored. Kept for interface compatibility with Rcal.
only_read (bool) – If True, load results from existing checkpoint files without running calculations.
is_output_detail (bool) – If True, print energy details for each step.
skip_specified_cal (List[Literal['opt_neutral', 'opt_ion', 'neutral', 'ion']]) – Steps to skip (load from existing files instead of running).
- Returns:
Reorganization energy [eV].
- Return type:
float
- mcal.atom_weight(symbol: str) float[source]¶
Get atom weight
- Parameters:
symbol (str) – Symbol of atom
- Returns:
Atomic weight
- Return type:
float
- 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]][source]¶
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.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[source]¶
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.cal_min_distance(symbols1: ndarray[Any, dtype[str]], coords1: ndarray[Any, dtype[float64]], symbols2: ndarray[Any, dtype[str]], coords2: ndarray[Any, dtype[float64]]) float[source]¶
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.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]]][source]¶
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.cal_pinv(array: ndarray[Any, dtype[float64]], rcond: float = 0.001) ndarray[Any, dtype[float64]][source]¶
Calculate pseudo-inverse matrix using eigenvalue decomposition
- Parameters:
array (NDArray[np.float64]) – Input matrix
rcond (float, optional) – Cutoff for small singular values, by default 1e-9
- Returns:
Pseudo-inverse matrix
- Return type:
NDArray[np.float64]
- Raises:
ValueError – The last eigenvalue is not zero.
ValueError – All eigenvalues except the last one should be negative.
- mcal.check_normal_termination(log_file: str) bool[source]¶
Check if the calculation terminated normally.
- Parameters:
log_file (str) – Path to the log file
- Returns:
True if the calculation terminated normally, False otherwise
- Return type:
bool
- mcal.diffusion_coefficient_tensor(lattice: ndarray[Any, dtype[float64]], hop: List[Tuple[int, int, int, int, int, float]]) ndarray[Any, dtype[float64]][source]¶
Calculate diffusion coefficient tensor from hopping rate
- Parameters:
lattice (3x3 numpy.array) – lattice[0,:] is a-axis vector, lattice[1,:] b-axis vector, lattice[2,:] c-axis vector
hop (list of (int, int, int, int, int, float) tuple.) – (s, t, i, j, k, p) means that the hopping rate from s-th molecule in (0, 0, 0) cell to t-th molecule in (i, j, k) cell is p.
- Returns:
Diffusion coefficient tensor
- Return type:
3x3 numpy.array
- mcal.marcus_rate(transfer: float, reorganization: float, T: float = 300.0) float[source]¶
Calculate hopping rate (1/s) from transfer integral (eV) and reorganization energy (eV)
- Parameters:
transfer (float) – Transfer integral [eV]
reorganization (float) – Reorganization energy [eV]
T (float) – Temperature [K], by default 300.0
- Returns:
Hopping rate [1/s]
- Return type:
float
- mcal.mobility_tensor(D: ndarray[Any, dtype[float64]], T: float = 300.0) ndarray[Any, dtype[float64]][source]¶
Calculate mobility tensor from diffusion coefficient tensor
- Parameters:
D (3x3 numpy.array) – Diffusion coefficient tensor
T (float) – Temperature [K], by default 300.0
- Returns:
Mobility tensor
- Return type:
3x3 numpy.array