From Command Line

In this tutorial, all calculations are performed via the command line.

Starting from version 1.1.6, horton-part only supports input files in yaml format to run its programs.
Below is a simple example of an input file, sample_input.yaml:
part-gen:
  inputs:
    - ./data/h2o.fchk
  outputs:
    - h2o_dens.npz
part-dens:
  inputs:
    - h2o_dens.npz
  outputs:
    - h2o_part.npz

This input file specifies the inputs and outputs for two sub-programs: part-gen and part-dens.

  • The inputs of part-gen specify the file used to generate the molecular density and molecular grids, which are stored in the path defined in the outputs section of part-gen.

  • The outputs of part-gen become the inputs for the part-dens sub-program, which partitions the molecular density into atomic contributions using various methods. The default method is aLISA.

To run the calculation in the terminal, use the following command:

part sample_input.yaml

If you prefer to run it in a Jupyter notebook, you will need to use the os module to execute the command.

[1]:
import os

Then, one can execute command through calling os.system function. The result is restored in h2o_part.npz that is a Numpy npz file.

[2]:
os.system("part sample_input.yaml")
/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/grid/molgrid.py:436: RuntimeWarning: Sizes are used for making the angular grids, degrees are ignored!
  AtomGrid(rad_grid, degrees=None, sizes=[size], center=atcoord, rotate=rotate)
****************************************************************************************************
                     Settings for part-dens program with Horton-Part 0.0.post1
****************************************************************************************************
                                           input : h2o_dens.npz
                                          output : h2o_part.npz
                                      basis_func : gauss
                                       func_file : None
                                         maxiter : 1000
                                       threshold : 1e-06
                                 inner_threshold : 1e-08
                                            lmax : 3
                                       log_level : INFO
                                          solver : sc
                                   part_job_type : do_partitioning
                                       grid_type : 1
                                        log_file : None
----------------------------------------------------------------------------------------------------

Load grid and density data from h2o_dens.npz ...
Load data done!
Time usage 0.000 s
Create molecular grid ...
Create molecular grid done!
Time usage 0.011 s
****************************************************************************************************
                                            Partitioning
****************************************************************************************************

================================================================================
Information of integral grids.
--------------------------------------------------------------------------------
Grid size of molecular grid: 87300
************************************ Atom 0 ************************************
   |-- Radial grid size: 150
   |-- Angular grid sizes:
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194
************************************ Atom 1 ************************************
   |-- Radial grid size: 150
   |-- Angular grid sizes:
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194
************************************ Atom 2 ************************************
   |-- Radial grid size: 150
   |-- Angular grid sizes:
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194 194
          194 194 194 194 194 194 194 194 194 194
--------------------------------------------------------------------------------
================================================================================

Performing a density-based AIM analysis with a wavefunction as input.
  Molecular grid    : MolGrid
  Using local grids : True
  Scheme                           : Linear Iterative Stockholder
  Outer loop convergence threshold : 1.0e-06
  Inner loop convergence threshold : 1.0e-08
  Using global ISA                 : False
  Maximum outer iterations         : 1000
  lmax                             : 3
  Solver                           : SC
  Basis function type              : GAUSS
  Grid type                        : 1

Load GAUSS basis functions
Iteration       Change      Entropy
        1   1.22830e-01   2.11417e-01
        2   2.65479e-02   1.08527e-01
        3   1.49456e-02   7.83538e-02
        4   9.42839e-03   6.32378e-02
        5   6.28105e-03   5.46797e-02
        6   4.36137e-03   4.95400e-02
        7   3.13626e-03   4.63304e-02
        8   2.32400e-03   4.42673e-02
        9   1.76667e-03   4.29100e-02
       10   1.37210e-03   4.19998e-02
       11   1.08474e-03   4.13791e-02
       12   8.70173e-04   4.09497e-02
       13   7.06459e-04   4.06488e-02
/Users/runner/work/horton-part/horton-part/src/horton_part/scripts/partition_density.py:82: RuntimeWarning: Sizes are used for making the angular grids, degrees are ignored!
  atgrid = AtomGrid(rgrid, sizes=sizes, center=atcoords[iatom], rotate=0)
       14   5.79228e-04   4.04355e-02
       15   4.78820e-04   4.02828e-02
       16   3.98549e-04   4.01724e-02
       17   3.33684e-04   4.00920e-02
       18   2.80795e-04   4.00330e-02
       19   2.37335e-04   3.99894e-02
       20   2.01390e-04   3.99570e-02
       21   1.71490e-04   3.99327e-02
       22   1.46498e-04   3.99145e-02
       23   1.25513e-04   3.99007e-02
       24   1.07823e-04   3.98903e-02
       25   9.28565e-05   3.98823e-02
       26   8.01521e-05   3.98763e-02
       27   6.93374e-05   3.98716e-02
       28   6.01030e-05   3.98680e-02
       29   5.21975e-05   3.98653e-02
       30   4.54125e-05   3.98631e-02
       31   3.95753e-05   3.98615e-02
       32   3.45423e-05   3.98602e-02
       33   3.01945e-05   3.98592e-02
       34   2.64284e-05   3.98584e-02
       35   2.31618e-05   3.98578e-02
       36   2.03229e-05   3.98574e-02
       37   1.78516e-05   3.98570e-02
       38   1.56966e-05   3.98567e-02
       39   1.38148e-05   3.98565e-02
       40   1.21691e-05   3.98563e-02
       41   1.07281e-05   3.98562e-02
       42   9.46461e-06   3.98561e-02
       43   8.35637e-06   3.98560e-02
       44   7.38135e-06   3.98559e-02
       45   6.52413e-06   3.98558e-02
       46   5.76940e-06   3.98558e-02
       47   5.10437e-06   3.98558e-02
       48   4.52132e-06   3.98557e-02
       49   4.00077e-06   3.98557e-02
       50   3.54375e-06   3.98557e-02
       51   3.13992e-06   3.98557e-02
       52   2.78363e-06   3.98557e-02
       53   2.46740e-06   3.98557e-02
       54   2.18796e-06   3.98557e-02
       55   1.94125e-06   3.98557e-02
       56   1.72164e-06   3.98557e-02
       57   1.52537e-06   3.98557e-02
       58   1.35548e-06   3.98557e-02
       59   1.20377e-06   3.98557e-02
       60   1.06879e-06   3.98557e-02
       61   9.47255e-07   3.98557e-02

****************************************************************************************************
                                          Basis functions
****************************************************************************************************
    Exponential order  Exponents coefficients  Initials values
    -----------------  ----------------------  ---------------
Atom H
     2.0                 5.672000                0.042900
     2.0                 1.505000                0.263900
     2.0                 0.530800                0.479000
     2.0                 0.220400                0.212700
Atom O
     2.0               220.100000                0.186900
     2.0                65.660000                0.657600
     2.0                25.980000                0.975100
     2.0                 1.685000                3.065700
     2.0                 0.686000                2.562200
     2.0                 0.231100                0.552800
----------------------------------------------------------------------------------------------------

****************************************************************************************************
                                    The modified initial propars
****************************************************************************************************
Propars of No. 1 atom O:
          0.18689323
          0.65757616
          0.97506466
          3.06558888
          2.56210713
          0.55277996

Propars of No. 2 atom H:
          0.04296450
          0.26429678
          0.47972018
          0.21301980

Propars of No. 3 atom H:
          0.04296450
          0.26429678
          0.47972018
          0.21301980

----------------------------------------------------------------------------------------------------

****************************************************************************************************
                                              Results
****************************************************************************************************
  Atomic charges [a.u.]:
                                          O :     -0.88081213
                                          H :      0.44056855
                                          H :      0.44056855
----------------------------------------------------------------------------------------------------

****************************************************************************************************
                                   Optimized pro-atom parameters
****************************************************************************************************
Propars of No. 1 atom O:
          0.19790820
          0.63334631
          0.98351828
          2.93953329
          3.29297763
          0.83352841

Propars of No. 2 atom H:
          0.07132704
          0.34987871
          0.12994288
          0.00828282

Propars of No. 3 atom H:
          0.07132704
          0.34987871
          0.12994288
          0.00828282

----------------------------------------------------------------------------------------------------

****************************************************************************************************
                                             Time usage
****************************************************************************************************
Do Partitioning                               :       0.89 s
  Update Weights                              :       0.42 s
  Update Atomic Parameters (iter*N_atom)      :       0.39 s
----------------------------------------------------------------------------------------------------

[2]:
0
[3]:
# remove cache files
for f in ["h2o_dens.npz", "h2o_part.npz"]:
    if os.path.exists(f):
        os.remove(f)
[ ]: