Package: hotpot-zzy
HotpotIntroductionThis Python package has been specifically designed to streamline communication between
commonly used computational tools in chemistry and materials research. The package is
aptly named Hotpot, after the popular dish from Sichuan, China. The defining feature of
Hotpot is its ease of preparation and deliciousness, regardless of the ingredients used.
Similarly, this Hotpot package brings together a variety of computational tools
(i.e. ingredients) to simplify research related to chemical materials. This allows chemists
and materials scientists to create delectable scientific cuisine with ease.The following jobs are supported by Hotpot:- Molecular Simulation, link to LAMMPS and RASPA
- Quantum or Ab-initio Calculation, link to Gaussian and ABACUS
- Feature Extraction and Machine learnig, link to openbabel, Zeo++, RdKit et al.InstallationRequirementspython >= 3.9
openbabel >= 3.1.1
cclib
lammpsInstall requirementBefore installing theHotpot, you should install the requirements at the first. It is
recommended to create a new conda environment to run the package.conda create -n hp python==3.9 openbabel cclib lammps -c conda-forgeInstallAfter the requirements are installed, now the ''Hotpot'' could be installed by pipconda activate hppip install hotpot-zzyor you can install from this github repository:git clone https://github.com/Zhang-Zhiyuan-zzy/hotpot.git
pip install build  # install `build` package
python -m build
pip install dist/hotpot_zzy-`VERSION`-py3-none-any.whlUsageThe Hotpot is very easy to use, the core class of Hotpot is theMolecule, which is designed
as the general interface for all functions across the entire the package. In the following
example, we first load a Molecule object bySMILESstring, and then the build their 3D conformer:import hotpot as hpmol = hp.Molecule.read_from('c1c(O)ccc(C(=O)O)c1', 'smi')  # Load a 4-hydroxybenzoic acid moleculeprint(mol.has_3d)  # the molcule is a 2D molcule now, whose all coordinates are (0, 0, 0)mol.build_3d(force_field='UFF')  # build the molecule to 3D, by univeral force fieldprint(m.has_3d)  # Now, the molecule is a 3D molecule, all of atoms have their coordinate# check the atoms coordinates:mol.normalize_labels()  # reorder the atom's labelsfor atom in mol.atoms:print(atom.label, atom.symbol, atom.coordinates)  # get the label, symbol, coordinates of the atomIn general, aMoleculeis consist of manyAtomandBondobjects. One can get the attributes from
theMolecule,AtomsorBonds.print(mol.atoms)  # get all atoms in the moleculeprint(mol.bonds)  # get all bonds in the moleculeatom = mol.atoms[0]bond = mol.bonds[0]print(atom.neighbours)  # get all neigh atoms of this atomsprint(bond.atom1, bond.atom2)  # get the begin and end atom of this bondprint(bond.type)  # get the bond typeMolecule Read and WriteTheHotpotread and write the molecule from string or files by calling theopenbabelandcclibpackages, most formats supported by the two packages are support
byHotpottoo. the Main method to read and parse toMoleculeobject isread_from():mol = hp.Molecule.read_from('/path/to/file', fmt='cif')  # read a cif file from diskOr, read aSMILES,inchikeyor other string like the example above.The argfmtis optional when to readMoleculefrom file, if the suffix of the file are correct:mol = hp.Molecule.read_from('/path/to/file.cif')One also could write the molecule object to formatted file by thewritefile()method, where thefmtis
the first arg and required. the actual format of the output is specified by thefmtarg:mol.writefile('cif', 'path/to/cif/file')One could retrieve the formatted string bydump()method, where only thefmtpass into:cif_script = mol.dump('cif')CheminformaticsIt is easy to get theSMILESorInchikey of theMoleculeobjectprint(mol.smiles)print(mol.inchi)TheMoleculeobject could convert to certain fingerprint object, likeFP2,FP3,FP4orMACCSfp = mol.fingerprint(fptype='FP2')TheMoleculeobjects could calculate the similarity between each other based on specified fingerprintmol.similarity(other_mol, fptype='FP3')  # calculate the similarity by 'FP3' fingerprintThe 'Molecule' object could retrieve its link_matrix as the input of graph learningprint(mol.link_matrix)  # get a [2, Nb] matrix, whereNbis the number of bondsSubmit the Molecule to Gaussian16 softwareOne can directly submit theMoleculeobject to Gaussian16 software. Assuming you want to optimize the
conformer of the molecule by Gaussian16mol.gaussian(g16root='path/to/g16root',link0='the link0 string',route='opt B3LYP/6-311++G**',path_log_file='path/to/save/the/log',path_err_file='path/to/record/error',inplace_attrs=True  # whether to inplace the attribute of the molecule according to the last status of the molecule in the log filedebugger='auto'  # Handle the Gaussian Error by the default method)print(mol.energy)  # get the SCF energy in the last optimized statusprint(mol.coordinates)  # get the coordinates matrix after optimizing by gaussian 16The Gaussian program will run and handle some common error report automatically. To handle errors with more elaborate
methods, user can custom a new debugger by inherit from the hotpot.tanks.quantum.GaussErrorHandle, seeing
documentation for more details.Submit the Molecule(Framework) to LAMMPS to perform grand canonical Monte-Carlo simulationSuppose that you want to determine the Uptake of carbon dioxide in a metal-organic framework at 298.15 K and 0.5 barwork_dir = 'work/dir'  # specify a dir to save the results and log for the GCMC simulationco2 = hp.Molecule.read_from('O=C=O', 'smi')  # load a carbon dioxide by SMILESframe = hp.Molecule.read_from('path/to/mof/file.cif')  # load a mof file as the framework# Run GCMC simulationframe.gcmc(co2,force_field='path/to/force/field',  # by default, the force field is the LJ potential from UFFwork_dir=work_dir,T=298.15, P=0.5  # specify the external environment)When perform the GCMC, the chemical potentialmuor fugacity coefficientphishould be given. Fortunately, in
themuorphicould be estimated by state of equation. For some common substancegcmc()method can calculate
themuandphiautomatically, byPeng-Robinsonequation by default.Access the property of substance for common substanceFor certain common substance, we can access its thermodynamical property, like critical temperatureTcand
saturation vapor pressurePsatbythermopackage:mol = hp.Molecule.read_from('c1ccc(O)cc1', 'smi')  # read a phenol by SMILESmol.thermo_init()  # some kwargs could pass into, see documentationprint(mol.thermo.Tc)  # the critical temperatureprint(mol.thermo.Psat)  # the saturation vapor pressureHandle molecules in large scaleIn the era of artificial intelligence, chemical information needs to be processed and utilized on a large scale.Hotpotprovides an interface calledMolBundlefor processing data on a large scale. For instance, if there
is a large number of single-point energy results computed usingGaussianstored somewhere on a disk, and we
want to create a dataset to train adeep potentialmodel using this data, we can utilize "MolBundle" to efficiently read all theGaussiancomputation data on a large
scale and convert it into the required datasetSystemformat for training the model:import hotpot as hpfrom hotpot.bundle import DeepModelBundlepath_raw_data = 'path/to/gaussian/log'path_system = 'path/to/system'bundle = hp.MolBundle.read_from('g16log', path_raw_data, '*/*.log', nproc=32)# Convert to DeepModelBundle object with method to organize the molecular structures to System datasetbundle: DeepModelBundle = bundle.to('DeepModelBundle')bundle.to_dpmd_sys(path_system, validate_ratio=0.1)# Or, the user could get the System object export from the Molecule directlyhotpotis currently making every effort to support the use of various computational tools from the Deep Modeling
community. In addition to organize the quantum calculation data and save them to disk directly, thehotpotnow allowed buildMoleculeobject from dpdata [System] and [LabeledSystem] object.frompathlibimportPathimporthotpotashpfromhotpot.tasks.deepmdimportread_systemdata_root_dir="path/to/data"# Read MultiSystem objectms=read_system(data_root_dir,file_pattern='**/*.log',fmt="gaussian/md")mols=[]forlsinms:mol=hp.Molecule.build_from_dpdata_system(ls)mols.append(mol)# Supposed that I want to know the process of breaking and generating of bonds of the first Moleculestruct_dir=Path('path/to/struct/save')img_dir=Path('path/to/img/save')mol=mols[0]# Iterating each conformer in the quantum chemistry calculationforiinrange(mol.conformer_counts):mol.conformer_select(i)mol.remove_bonds(*mol.bonds)# Clear all pre-build bondsmol.build_bonds()# rebuild bonds according to the point cloud of atomsmol.assign_bond_types()mol.writefile(struct_dir.joinpath(f"{i}.mol2"))# Save the 3D mol structure with built bonds to mol2 filemol.save_2d_img(img_dir.joinpath(f'{i}.png'))# Save the 2d img structure to png fileTroubleShooting1) Missing dependent dynamic libsWhen installing the package, you might meet some errors from missing dependent libs, like the message:ImportError: libXrender.so.1: cannot open shared object file: No such file or directory.
This trouble is caused by the lacking of thelibxrender1lib and could be solved by run the following command
(supposing an Ubuntu system):sudo apt-get install libxrender1The similar trouble should be solved like the above.