{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7c94046f-1bc7-456d-b721-29f356e99d00",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>\n",
       "h1, h2, h3, h4, h5, h6 {\n",
       "  font-family: Verdana, \"DejaVu Sans\", \"Bitstream Vera Sans\", Geneva, sans-serif;\n",
       "  font-weight: bold;\n",
       "}\n",
       "body, intro, introE, rq, rqE, ex, exE, app, appE, sol  {\n",
       "  font-family: Verdana, \"DejaVu Sans\", \"Bitstream Vera Sans\", Geneva, sans-serif;\n",
       "  font-weight: 400;\n",
       "  font-size: 12px;\n",
       "}\n",
       "h1 {\n",
       "  border: 0 solid #333;\n",
       "  padding: 30px ;\n",
       "  color: white;\n",
       "  background: #b11d01;\n",
       "  text-align: center;\n",
       "}\n",
       "h2 {\n",
       "  border: 3px solid #333;\n",
       "  padding: 18px ;\n",
       "  color: #b11d01;\n",
       "  background: #ffffff;\n",
       "  text-align: center;\n",
       "}\n",
       "h3 {\n",
       "  border: 0 solid #333;\n",
       "  padding: 12px ;\n",
       "  color: #000000;\n",
       "  background: #c1c1c1;\n",
       "  text-align: left;\n",
       "}\n",
       "h4 {\n",
       "  border: 0 solid #333;\n",
       "  padding: 2px ;\n",
       "  color: #000000;\n",
       "  background: #d9fffc;\n",
       "  text-align: left;\n",
       "}\n",
       "h5 {\n",
       "  border: 1px solid #333;\n",
       "  padding: 2px ;\n",
       "  color: #000000;\n",
       "  background: #ffffff;\n",
       "  text-align: left;\n",
       "}\n",
       ".intro {    \n",
       "    background-color: #f1f1f1;\n",
       "    border-color: #969696;\n",
       "    border-left: 5px solid #969696;\n",
       "    padding: 0.5em;\n",
       "}\n",
       ".introE {    \n",
       "    background-color: #f1f1f1;\n",
       "    border-color: #969696;\n",
       "    border-left: 5px solid #969696;\n",
       "    padding: 0.5em;\n",
       "    color : #117996;\n",
       "}\n",
       ".rq {    \n",
       "    background-color: #fcf2f2;\n",
       "    border-color: #dFb5b4;\n",
       "    border-left: 5px solid #dfb5b4;\n",
       "    padding: 0.5em;\n",
       "}\n",
       ".rqE {    \n",
       "    background-color: #fcf2f2;\n",
       "    border-color: #dFb5b4;\n",
       "    border-left: 5px solid #dfb5b4;\n",
       "    padding: 0.5em;\n",
       "    color : #117996;\n",
       "}\n",
       ".exold {    \n",
       "    background-color: #b2dbea80;\n",
       "    border-color: #0055ff;\n",
       "    border-left: 10px solid #0055ff;\n",
       "    padding: 0.5em;\n",
       "}\n",
       ".ex {    \n",
       "    background-color: #b2dbea80;\n",
       "    padding: 0.5em;\n",
       "    padding-top: 0em;\n",
       "    position:relative;\n",
       "}\n",
       ".ex::before {\n",
       "    background-color: #b2dbea;\n",
       "    content:\"Exercice\";\n",
       "    margin-left:-0.5em;\n",
       "    margin-right:-0.5em;\n",
       "    padding-left:0.5em;\n",
       "    padding-right:0.5em;\n",
       "    font-weight: 600;\n",
       "    display: block;\n",
       "}\n",
       ".exE {    \n",
       "    background-color: #b2dbea80;\n",
       "    padding: 0.5em;\n",
       "    padding-top: 0em;\n",
       "    position:relative;\n",
       "    color : #117996;\n",
       "}\n",
       ".exE::before {\n",
       "    background-color: #b2dbea;\n",
       "    content:\"Exercise\";\n",
       "    margin-left:-0.5em;\n",
       "    margin-right:-0.5em;\n",
       "    padding-left:0.5em;\n",
       "    padding-right:0.5em;\n",
       "    font-weight: 600;\n",
       "    display: block;\n",
       "    color : #117996;\n",
       "}\n",
       ".app {    \n",
       "    background-color: #b2dbea80;\n",
       "    padding: 0.5em;\n",
       "    padding-top: 0em;\n",
       "    position:relative;\n",
       "}\n",
       ".app::before {\n",
       "    background-color: #b2dbea;\n",
       "    content:\"Application\";\n",
       "    margin-left:-0.5em;\n",
       "    margin-right:-0.5em;\n",
       "    padding-left:0.5em;\n",
       "    padding-right:0.5em;\n",
       "    font-weight: 600;\n",
       "    display: block;\n",
       "}\n",
       ".appE {    \n",
       "    background-color: #b2dbea80;\n",
       "    padding: 0.5em;\n",
       "    padding-top: 0em;\n",
       "    color : #117996;\n",
       "    position:relative;\n",
       "}\n",
       ".appE::before {\n",
       "    background-color: #b2dbea;\n",
       "    content:\"Application\";\n",
       "    margin-left:-0.5em;\n",
       "    margin-right:-0.5em;\n",
       "    padding-left:0.5em;\n",
       "    padding-right:0.5em;\n",
       "    font-weight: 600;\n",
       "    color : #117996;\n",
       "    display: block;\n",
       "}\n",
       ".sol {    \n",
       "    background-color: #bbeab880;\n",
       "    padding: 0.5em;\n",
       "    padding-top: 0em;\n",
       "    position:relative;\n",
       "}\n",
       ".sol::before {\n",
       "    background-color: #bbeab8;\n",
       "    content:\"Answer\";\n",
       "    margin-left:-0.5em;\n",
       "    margin-right:-0.5em;\n",
       "    padding-left:0.5em;\n",
       "    padding-right:0.5em;\n",
       "    font-weight: 600;\n",
       "    display: block;\n",
       "}\n",
       "</style>\n"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "**Start at:** Thursday 24 April 2025, 22:06:06  \n",
       "**Hostname:** device-9.home (Linux)"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/markdown": [
       "<p style=\"text-align: center\"><img width=\"800px\" src=\"./somos/config/svg/pyPCBanner.svg\" style=\"margin-left:auto; margin-right:auto\"/></p>"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from somos.config import tools4pyPC as t4p\n",
    "from somos.config import visualID_Eng as vID\n",
    "from somos.config.visualID_Eng import fg, hl, bg\n",
    "\n",
    "import importlib"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b3617b2-8f08-46ec-a45a-b73c796718b9",
   "metadata": {},
   "source": [
    "## Define files"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "9503d8f1-9553-4b85-acbd-4e1f5a017073",
   "metadata": {},
   "outputs": [],
   "source": [
    "logfolder = \"./logs\"\n",
    "logfile = \"H2CO_T1_g09_wOverlaps.log.gz\""
   ]
  },
  {
   "cell_type": "markdown",
   "id": "565c3fcb-7e65-4538-9ee2-face50295ec5",
   "metadata": {},
   "source": [
    "## Cosine similarity"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "abc35e1a-57d9-4838-9c74-2b41c1ffdd0a",
   "metadata": {},
   "source": [
    "### Interactive similarity, SOMO candidates, cross_match_all"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "f63b0c0a-ec69-4fee-8a87-b7b09eb2e2b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>🚨 ENTERING load_mos_from_cclib 🚨</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "UDFT\n",
      "✅ Finished load_mos_from_cclib\n",
      "n_basis = 46\n",
      "Occupied alpha MOs: 9 (1 -> 9)\n",
      "Occupied beta MOs : 7 (47 -> 54)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Index</th>\n",
       "      <th>Occupation</th>\n",
       "      <th>Energy (Ha)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>O</td>\n",
       "      <td>-19.239507</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>O</td>\n",
       "      <td>-10.237578</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>O</td>\n",
       "      <td>-1.096300</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>O</td>\n",
       "      <td>-0.672080</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>O</td>\n",
       "      <td>-0.528690</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>87</th>\n",
       "      <td>42</td>\n",
       "      <td>V</td>\n",
       "      <td>2.772919</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>88</th>\n",
       "      <td>43</td>\n",
       "      <td>V</td>\n",
       "      <td>2.792189</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>89</th>\n",
       "      <td>44</td>\n",
       "      <td>V</td>\n",
       "      <td>2.877559</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90</th>\n",
       "      <td>45</td>\n",
       "      <td>V</td>\n",
       "      <td>3.253179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>91</th>\n",
       "      <td>46</td>\n",
       "      <td>V</td>\n",
       "      <td>3.400959</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>92 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    Index Occupation  Energy (Ha)\n",
       "0       1          O   -19.239507\n",
       "1       2          O   -10.237578\n",
       "2       3          O    -1.096300\n",
       "3       4          O    -0.672080\n",
       "4       5          O    -0.528690\n",
       "..    ...        ...          ...\n",
       "87     42          V     2.772919\n",
       "88     43          V     2.792189\n",
       "89     44          V     2.877559\n",
       "90     45          V     3.253179\n",
       "91     46          V     3.400959\n",
       "\n",
       "[92 rows x 3 columns]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Interactive similarity</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "fa9756e53a554884a2a7af1e913efeb6",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(Dropdown(description='Alpha OM', options={'alpha #1': 0, 'alpha #2': 1, 'alpha #3': 2, '…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Magnetic MOs</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Eigenvalue of S2 operator = 2.0055\n",
      "S-value = 1.0018\n",
      "Spin multiplicity = 3.0\n",
      "✅ Number of magnetic orbitals (2) is consistent with spin value = 2.0036 (within 0.1 tolerance).\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Alpha MO</th>\n",
       "      <th>Beta MO</th>\n",
       "      <th>Beta MO for Jmol</th>\n",
       "      <th>Similarity</th>\n",
       "      <th>Alpha Energy</th>\n",
       "      <th>Alpha Occ</th>\n",
       "      <th>Beta Energy</th>\n",
       "      <th>Beta Occ</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>8</td>\n",
       "      <td>8</td>\n",
       "      <td>54</td>\n",
       "      <td>0.940176</td>\n",
       "      <td>-0.36750</td>\n",
       "      <td>O</td>\n",
       "      <td>-0.17659</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9</td>\n",
       "      <td>9</td>\n",
       "      <td>55</td>\n",
       "      <td>0.980720</td>\n",
       "      <td>-0.20354</td>\n",
       "      <td>O</td>\n",
       "      <td>-0.04685</td>\n",
       "      <td>V</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Alpha MO  Beta MO  Beta MO for Jmol  Similarity  Alpha Energy Alpha Occ  \\\n",
       "0         8        8                54    0.940176      -0.36750         O   \n",
       "1         9        9                55    0.980720      -0.20354         O   \n",
       "\n",
       "   Beta Energy Beta Occ  \n",
       "0     -0.17659        V  \n",
       "1     -0.04685        V  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Similarity table</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Alpha MO</th>\n",
       "      <th>Alpha Energy</th>\n",
       "      <th>Alpha Occ</th>\n",
       "      <th>Beta MO</th>\n",
       "      <th>Beta MO for Jmol</th>\n",
       "      <th>Beta Energy</th>\n",
       "      <th>Beta Occ</th>\n",
       "      <th>Similarity</th>\n",
       "      <th>SOMO-like</th>\n",
       "      <th>ΔE (eV)</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>-19.239507</td>\n",
       "      <td>O</td>\n",
       "      <td>1</td>\n",
       "      <td>47</td>\n",
       "      <td>-19.209147</td>\n",
       "      <td>O</td>\n",
       "      <td>0.999999</td>\n",
       "      <td>False</td>\n",
       "      <td>0.83</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>-10.237578</td>\n",
       "      <td>O</td>\n",
       "      <td>2</td>\n",
       "      <td>48</td>\n",
       "      <td>-10.225658</td>\n",
       "      <td>O</td>\n",
       "      <td>0.999999</td>\n",
       "      <td>False</td>\n",
       "      <td>0.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>-1.096300</td>\n",
       "      <td>O</td>\n",
       "      <td>3</td>\n",
       "      <td>49</td>\n",
       "      <td>-1.028690</td>\n",
       "      <td>O</td>\n",
       "      <td>0.998108</td>\n",
       "      <td>False</td>\n",
       "      <td>1.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>-0.672080</td>\n",
       "      <td>O</td>\n",
       "      <td>4</td>\n",
       "      <td>50</td>\n",
       "      <td>-0.622630</td>\n",
       "      <td>O</td>\n",
       "      <td>0.997191</td>\n",
       "      <td>False</td>\n",
       "      <td>1.35</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>-0.528690</td>\n",
       "      <td>O</td>\n",
       "      <td>5</td>\n",
       "      <td>51</td>\n",
       "      <td>-0.463850</td>\n",
       "      <td>O</td>\n",
       "      <td>0.945427</td>\n",
       "      <td>False</td>\n",
       "      <td>1.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>6</td>\n",
       "      <td>-0.486810</td>\n",
       "      <td>O</td>\n",
       "      <td>6</td>\n",
       "      <td>52</td>\n",
       "      <td>-0.452510</td>\n",
       "      <td>O</td>\n",
       "      <td>0.989591</td>\n",
       "      <td>False</td>\n",
       "      <td>0.93</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>7</td>\n",
       "      <td>-0.437560</td>\n",
       "      <td>O</td>\n",
       "      <td>7</td>\n",
       "      <td>53</td>\n",
       "      <td>-0.368280</td>\n",
       "      <td>O</td>\n",
       "      <td>0.987580</td>\n",
       "      <td>False</td>\n",
       "      <td>1.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>8</td>\n",
       "      <td>-0.367500</td>\n",
       "      <td>O</td>\n",
       "      <td>8</td>\n",
       "      <td>54</td>\n",
       "      <td>-0.176590</td>\n",
       "      <td>V</td>\n",
       "      <td>0.940176</td>\n",
       "      <td>True</td>\n",
       "      <td>5.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>9</td>\n",
       "      <td>-0.203540</td>\n",
       "      <td>O</td>\n",
       "      <td>9</td>\n",
       "      <td>55</td>\n",
       "      <td>-0.046850</td>\n",
       "      <td>V</td>\n",
       "      <td>0.980720</td>\n",
       "      <td>True</td>\n",
       "      <td>4.26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>10</td>\n",
       "      <td>0.021070</td>\n",
       "      <td>V</td>\n",
       "      <td>10</td>\n",
       "      <td>56</td>\n",
       "      <td>0.030390</td>\n",
       "      <td>V</td>\n",
       "      <td>0.996892</td>\n",
       "      <td>False</td>\n",
       "      <td>0.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>11</td>\n",
       "      <td>0.045480</td>\n",
       "      <td>V</td>\n",
       "      <td>11</td>\n",
       "      <td>57</td>\n",
       "      <td>0.051460</td>\n",
       "      <td>V</td>\n",
       "      <td>0.995695</td>\n",
       "      <td>False</td>\n",
       "      <td>0.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>12</td>\n",
       "      <td>0.055440</td>\n",
       "      <td>V</td>\n",
       "      <td>12</td>\n",
       "      <td>58</td>\n",
       "      <td>0.060820</td>\n",
       "      <td>V</td>\n",
       "      <td>0.999532</td>\n",
       "      <td>False</td>\n",
       "      <td>0.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>13</td>\n",
       "      <td>0.069970</td>\n",
       "      <td>V</td>\n",
       "      <td>13</td>\n",
       "      <td>59</td>\n",
       "      <td>0.092330</td>\n",
       "      <td>V</td>\n",
       "      <td>0.981547</td>\n",
       "      <td>False</td>\n",
       "      <td>0.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>14</td>\n",
       "      <td>0.169230</td>\n",
       "      <td>V</td>\n",
       "      <td>14</td>\n",
       "      <td>60</td>\n",
       "      <td>0.181530</td>\n",
       "      <td>V</td>\n",
       "      <td>0.980210</td>\n",
       "      <td>False</td>\n",
       "      <td>0.33</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    Alpha MO  Alpha Energy Alpha Occ  Beta MO  Beta MO for Jmol  Beta Energy  \\\n",
       "0          1    -19.239507         O        1                47   -19.209147   \n",
       "1          2    -10.237578         O        2                48   -10.225658   \n",
       "2          3     -1.096300         O        3                49    -1.028690   \n",
       "3          4     -0.672080         O        4                50    -0.622630   \n",
       "4          5     -0.528690         O        5                51    -0.463850   \n",
       "5          6     -0.486810         O        6                52    -0.452510   \n",
       "6          7     -0.437560         O        7                53    -0.368280   \n",
       "7          8     -0.367500         O        8                54    -0.176590   \n",
       "8          9     -0.203540         O        9                55    -0.046850   \n",
       "9         10      0.021070         V       10                56     0.030390   \n",
       "10        11      0.045480         V       11                57     0.051460   \n",
       "11        12      0.055440         V       12                58     0.060820   \n",
       "12        13      0.069970         V       13                59     0.092330   \n",
       "13        14      0.169230         V       14                60     0.181530   \n",
       "\n",
       "   Beta Occ  Similarity  SOMO-like ΔE (eV)  \n",
       "0         O    0.999999      False    0.83  \n",
       "1         O    0.999999      False    0.32  \n",
       "2         O    0.998108      False    1.84  \n",
       "3         O    0.997191      False    1.35  \n",
       "4         O    0.945427      False    1.76  \n",
       "5         O    0.989591      False    0.93  \n",
       "6         O    0.987580      False    1.89  \n",
       "7         V    0.940176       True    5.19  \n",
       "8         V    0.980720       True    4.26  \n",
       "9         V    0.996892      False    0.25  \n",
       "10        V    0.995695      False    0.16  \n",
       "11        V    0.999532      False    0.15  \n",
       "12        V    0.981547      False    0.61  \n",
       "13        V    0.980210      False    0.33  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✅ Similarity table saved with SOMO highlights: logs/H2CO_T1_g09_wOverlaps.log_similarity.xlsx\n",
      "✅ Saved SOMO similarity sheets: logs/H2CO_T1_g09_wOverlaps.log_similarityOfSOMOs.xlsx\n"
     ]
    }
   ],
   "source": [
    "from somos import io, cosim\n",
    "importlib.reload(io)\n",
    "importlib.reload(cosim)\n",
    "\n",
    "listMOs, coeffMOs, nBasis, dfSOMOs, S = cosim.analyzeSimilarity(logfolder,logfile)\n",
    "\n",
    "cosim.save_similarity_per_somo_from_df(dfSOMOs, listMOs, coeffMOs, nBasis, S, logfolder,logfile)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "480f96c0-0dac-49f0-a812-62b872c44bfd",
   "metadata": {},
   "source": [
    "### Heatmaps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "b5537fbe-87ee-4947-9ddc-577ff6e45cb0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Cosine similarity of alpha/beta MOs around HOMO-LUMO frontier</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4ee80b4784ed4927b38110aacfdd30d0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(Button(description='💾 Save heatmap', style=ButtonStyle(), tooltip='Save heatmap to PNG in ./log…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "4b7f0a08efe14094958342632430a696",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "2fbbc8212538457ab6115b386adbd4c8",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=5, continuous_update=False, description='HOMO–n > HOMO', max=30, min=1),…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "cosim.heatmap_MOs(listMOs, coeffMOs, nBasis, S, logfolder, logfile)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a53d06f-ab0f-46c2-a67d-58b24ad51c4b",
   "metadata": {},
   "source": [
    "### tSNE"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0d93c731-e16d-45ab-aceb-22b648c7657c",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Running t-SNE... please wait.\n",
      "t-SNE completed in 0.42 seconds.\n"
     ]
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "95e6356316b749ae92858a7c9364292e",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "VBox(children=(HBox(children=(SelectMultiple(description='Type', index=(0, 1), options=('Alpha', 'Beta'), valu…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "f862e52ec9d846f2b10b713e27835c4f",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "cosim.tsne(listMOs, coeffMOs, S, logfolder,logfile)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cdd7ce13-e0db-4452-a6b1-1ea58e9d0813",
   "metadata": {},
   "source": [
    "## Projection\n",
    "\n",
    "### Main  utility"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3bd9c4d2-4eeb-4892-b707-e3d2c13aaf76",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>🚨 ENTERING load_mos_from_cclib 🚨</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "UDFT\n",
      "✅ Finished load_mos_from_cclib\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Computes the squared projection of each occupied alpha orbital onto the subspaces spanned by both virtual and occupied beta orbitals</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "✅ Saved to: logs/H2CO_T1_g09_wOverlaps_projection_sorted.xlsx\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>🚨 ENTERING load_mos_from_cclib 🚨</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "UDFT\n",
      "✅ Finished load_mos_from_cclib\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<style type=\"text/css\">\n",
       "#T_8482a_row0_col0, #T_8482a_row0_col1, #T_8482a_row0_col2, #T_8482a_row0_col3, #T_8482a_row0_col4, #T_8482a_row0_col5, #T_8482a_row0_col6, #T_8482a_row0_col7, #T_8482a_row0_col8, #T_8482a_row0_col9, #T_8482a_row0_col10, #T_8482a_row0_col11, #T_8482a_row0_col12, #T_8482a_row0_col13, #T_8482a_row0_col14, #T_8482a_row0_col15, #T_8482a_row1_col0, #T_8482a_row1_col1, #T_8482a_row1_col2, #T_8482a_row1_col3, #T_8482a_row1_col4, #T_8482a_row1_col5, #T_8482a_row1_col6, #T_8482a_row1_col7, #T_8482a_row1_col8, #T_8482a_row1_col9, #T_8482a_row1_col10, #T_8482a_row1_col11, #T_8482a_row1_col12, #T_8482a_row1_col13, #T_8482a_row1_col14, #T_8482a_row1_col15 {\n",
       "  background-color: #ffff99;\n",
       "}\n",
       "</style>\n",
       "<table id=\"T_8482a\">\n",
       "  <thead>\n",
       "    <tr>\n",
       "      <th class=\"blank level0\" >&nbsp;</th>\n",
       "      <th id=\"T_8482a_level0_col0\" class=\"col_heading level0 col0\" >Alpha MO</th>\n",
       "      <th id=\"T_8482a_level0_col1\" class=\"col_heading level0 col1\" >Occ α</th>\n",
       "      <th id=\"T_8482a_level0_col2\" class=\"col_heading level0 col2\" >Energy (Ha)</th>\n",
       "      <th id=\"T_8482a_level0_col3\" class=\"col_heading level0 col3\" >Projection² on β_virtual</th>\n",
       "      <th id=\"T_8482a_level0_col4\" class=\"col_heading level0 col4\" >Projection² on β_occupied</th>\n",
       "      <th id=\"T_8482a_level0_col5\" class=\"col_heading level0 col5\" >Dominant β MO</th>\n",
       "      <th id=\"T_8482a_level0_col6\" class=\"col_heading level0 col6\" >Index4Jmol</th>\n",
       "      <th id=\"T_8482a_level0_col7\" class=\"col_heading level0 col7\" >Occ β</th>\n",
       "      <th id=\"T_8482a_level0_col8\" class=\"col_heading level0 col8\" >E (β, Ha)</th>\n",
       "      <th id=\"T_8482a_level0_col9\" class=\"col_heading level0 col9\" >Top 1 contrib (%)</th>\n",
       "      <th id=\"T_8482a_level0_col10\" class=\"col_heading level0 col10\" >Top 2 contrib (%)</th>\n",
       "      <th id=\"T_8482a_level0_col11\" class=\"col_heading level0 col11\" >Top 3 contrib (%)</th>\n",
       "      <th id=\"T_8482a_level0_col12\" class=\"col_heading level0 col12\" >Dominance ratio</th>\n",
       "      <th id=\"T_8482a_level0_col13\" class=\"col_heading level0 col13\" >Spread?</th>\n",
       "      <th id=\"T_8482a_level0_col14\" class=\"col_heading level0 col14\" >β orbitals >20%</th>\n",
       "      <th id=\"T_8482a_level0_col15\" class=\"col_heading level0 col15\" >SOMO?</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row0\" class=\"row_heading level0 row0\" >37</th>\n",
       "      <td id=\"T_8482a_row0_col0\" class=\"data row0 col0\" >9</td>\n",
       "      <td id=\"T_8482a_row0_col1\" class=\"data row0 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row0_col2\" class=\"data row0 col2\" >-0.203540</td>\n",
       "      <td id=\"T_8482a_row0_col3\" class=\"data row0 col3\" >0.996000</td>\n",
       "      <td id=\"T_8482a_row0_col4\" class=\"data row0 col4\" >0.004000</td>\n",
       "      <td id=\"T_8482a_row0_col5\" class=\"data row0 col5\" >9</td>\n",
       "      <td id=\"T_8482a_row0_col6\" class=\"data row0 col6\" >55</td>\n",
       "      <td id=\"T_8482a_row0_col7\" class=\"data row0 col7\" >V</td>\n",
       "      <td id=\"T_8482a_row0_col8\" class=\"data row0 col8\" >-0.046850</td>\n",
       "      <td id=\"T_8482a_row0_col9\" class=\"data row0 col9\" >96.200000</td>\n",
       "      <td id=\"T_8482a_row0_col10\" class=\"data row0 col10\" >99.100000</td>\n",
       "      <td id=\"T_8482a_row0_col11\" class=\"data row0 col11\" >99.400000</td>\n",
       "      <td id=\"T_8482a_row0_col12\" class=\"data row0 col12\" >0.962000</td>\n",
       "      <td id=\"T_8482a_row0_col13\" class=\"data row0 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row0_col14\" class=\"data row0 col14\" >9: 96.2%</td>\n",
       "      <td id=\"T_8482a_row0_col15\" class=\"data row0 col15\" >Yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row1\" class=\"row_heading level0 row1\" >38</th>\n",
       "      <td id=\"T_8482a_row1_col0\" class=\"data row1 col0\" >8</td>\n",
       "      <td id=\"T_8482a_row1_col1\" class=\"data row1 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row1_col2\" class=\"data row1 col2\" >-0.367500</td>\n",
       "      <td id=\"T_8482a_row1_col3\" class=\"data row1 col3\" >0.895000</td>\n",
       "      <td id=\"T_8482a_row1_col4\" class=\"data row1 col4\" >0.105000</td>\n",
       "      <td id=\"T_8482a_row1_col5\" class=\"data row1 col5\" >8</td>\n",
       "      <td id=\"T_8482a_row1_col6\" class=\"data row1 col6\" >54</td>\n",
       "      <td id=\"T_8482a_row1_col7\" class=\"data row1 col7\" >V</td>\n",
       "      <td id=\"T_8482a_row1_col8\" class=\"data row1 col8\" >-0.176590</td>\n",
       "      <td id=\"T_8482a_row1_col9\" class=\"data row1 col9\" >88.400000</td>\n",
       "      <td id=\"T_8482a_row1_col10\" class=\"data row1 col10\" >98.900000</td>\n",
       "      <td id=\"T_8482a_row1_col11\" class=\"data row1 col11\" >99.700000</td>\n",
       "      <td id=\"T_8482a_row1_col12\" class=\"data row1 col12\" >0.884000</td>\n",
       "      <td id=\"T_8482a_row1_col13\" class=\"data row1 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row1_col14\" class=\"data row1 col14\" >8: 88.4%</td>\n",
       "      <td id=\"T_8482a_row1_col15\" class=\"data row1 col15\" >Yes</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row2\" class=\"row_heading level0 row2\" >39</th>\n",
       "      <td id=\"T_8482a_row2_col0\" class=\"data row2 col0\" >7</td>\n",
       "      <td id=\"T_8482a_row2_col1\" class=\"data row2 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row2_col2\" class=\"data row2 col2\" >-0.437560</td>\n",
       "      <td id=\"T_8482a_row2_col3\" class=\"data row2 col3\" >0.005000</td>\n",
       "      <td id=\"T_8482a_row2_col4\" class=\"data row2 col4\" >0.995000</td>\n",
       "      <td id=\"T_8482a_row2_col5\" class=\"data row2 col5\" >7</td>\n",
       "      <td id=\"T_8482a_row2_col6\" class=\"data row2 col6\" >53</td>\n",
       "      <td id=\"T_8482a_row2_col7\" class=\"data row2 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row2_col8\" class=\"data row2 col8\" >-0.368280</td>\n",
       "      <td id=\"T_8482a_row2_col9\" class=\"data row2 col9\" >97.500000</td>\n",
       "      <td id=\"T_8482a_row2_col10\" class=\"data row2 col10\" >99.400000</td>\n",
       "      <td id=\"T_8482a_row2_col11\" class=\"data row2 col11\" >99.600000</td>\n",
       "      <td id=\"T_8482a_row2_col12\" class=\"data row2 col12\" >0.975000</td>\n",
       "      <td id=\"T_8482a_row2_col13\" class=\"data row2 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row2_col14\" class=\"data row2 col14\" >7: 97.5%</td>\n",
       "      <td id=\"T_8482a_row2_col15\" class=\"data row2 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row3\" class=\"row_heading level0 row3\" >40</th>\n",
       "      <td id=\"T_8482a_row3_col0\" class=\"data row3 col0\" >6</td>\n",
       "      <td id=\"T_8482a_row3_col1\" class=\"data row3 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row3_col2\" class=\"data row3 col2\" >-0.486810</td>\n",
       "      <td id=\"T_8482a_row3_col3\" class=\"data row3 col3\" >0.000000</td>\n",
       "      <td id=\"T_8482a_row3_col4\" class=\"data row3 col4\" >1.000000</td>\n",
       "      <td id=\"T_8482a_row3_col5\" class=\"data row3 col5\" >6</td>\n",
       "      <td id=\"T_8482a_row3_col6\" class=\"data row3 col6\" >52</td>\n",
       "      <td id=\"T_8482a_row3_col7\" class=\"data row3 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row3_col8\" class=\"data row3 col8\" >-0.452510</td>\n",
       "      <td id=\"T_8482a_row3_col9\" class=\"data row3 col9\" >97.900000</td>\n",
       "      <td id=\"T_8482a_row3_col10\" class=\"data row3 col10\" >99.800000</td>\n",
       "      <td id=\"T_8482a_row3_col11\" class=\"data row3 col11\" >99.900000</td>\n",
       "      <td id=\"T_8482a_row3_col12\" class=\"data row3 col12\" >0.979000</td>\n",
       "      <td id=\"T_8482a_row3_col13\" class=\"data row3 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row3_col14\" class=\"data row3 col14\" >6: 97.9%</td>\n",
       "      <td id=\"T_8482a_row3_col15\" class=\"data row3 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row4\" class=\"row_heading level0 row4\" >41</th>\n",
       "      <td id=\"T_8482a_row4_col0\" class=\"data row4 col0\" >5</td>\n",
       "      <td id=\"T_8482a_row4_col1\" class=\"data row4 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row4_col2\" class=\"data row4 col2\" >-0.528690</td>\n",
       "      <td id=\"T_8482a_row4_col3\" class=\"data row4 col3\" >0.106000</td>\n",
       "      <td id=\"T_8482a_row4_col4\" class=\"data row4 col4\" >0.894000</td>\n",
       "      <td id=\"T_8482a_row4_col5\" class=\"data row4 col5\" >5</td>\n",
       "      <td id=\"T_8482a_row4_col6\" class=\"data row4 col6\" >51</td>\n",
       "      <td id=\"T_8482a_row4_col7\" class=\"data row4 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row4_col8\" class=\"data row4 col8\" >-0.463850</td>\n",
       "      <td id=\"T_8482a_row4_col9\" class=\"data row4 col9\" >89.400000</td>\n",
       "      <td id=\"T_8482a_row4_col10\" class=\"data row4 col10\" >99.500000</td>\n",
       "      <td id=\"T_8482a_row4_col11\" class=\"data row4 col11\" >99.800000</td>\n",
       "      <td id=\"T_8482a_row4_col12\" class=\"data row4 col12\" >0.894000</td>\n",
       "      <td id=\"T_8482a_row4_col13\" class=\"data row4 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row4_col14\" class=\"data row4 col14\" >5: 89.4%</td>\n",
       "      <td id=\"T_8482a_row4_col15\" class=\"data row4 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row5\" class=\"row_heading level0 row5\" >42</th>\n",
       "      <td id=\"T_8482a_row5_col0\" class=\"data row5 col0\" >4</td>\n",
       "      <td id=\"T_8482a_row5_col1\" class=\"data row5 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row5_col2\" class=\"data row5 col2\" >-0.672080</td>\n",
       "      <td id=\"T_8482a_row5_col3\" class=\"data row5 col3\" >0.002000</td>\n",
       "      <td id=\"T_8482a_row5_col4\" class=\"data row5 col4\" >0.998000</td>\n",
       "      <td id=\"T_8482a_row5_col5\" class=\"data row5 col5\" >4</td>\n",
       "      <td id=\"T_8482a_row5_col6\" class=\"data row5 col6\" >50</td>\n",
       "      <td id=\"T_8482a_row5_col7\" class=\"data row5 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row5_col8\" class=\"data row5 col8\" >-0.622630</td>\n",
       "      <td id=\"T_8482a_row5_col9\" class=\"data row5 col9\" >99.400000</td>\n",
       "      <td id=\"T_8482a_row5_col10\" class=\"data row5 col10\" >99.700000</td>\n",
       "      <td id=\"T_8482a_row5_col11\" class=\"data row5 col11\" >99.800000</td>\n",
       "      <td id=\"T_8482a_row5_col12\" class=\"data row5 col12\" >0.994000</td>\n",
       "      <td id=\"T_8482a_row5_col13\" class=\"data row5 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row5_col14\" class=\"data row5 col14\" >4: 99.4%</td>\n",
       "      <td id=\"T_8482a_row5_col15\" class=\"data row5 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row6\" class=\"row_heading level0 row6\" >43</th>\n",
       "      <td id=\"T_8482a_row6_col0\" class=\"data row6 col0\" >3</td>\n",
       "      <td id=\"T_8482a_row6_col1\" class=\"data row6 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row6_col2\" class=\"data row6 col2\" >-1.096300</td>\n",
       "      <td id=\"T_8482a_row6_col3\" class=\"data row6 col3\" >0.001000</td>\n",
       "      <td id=\"T_8482a_row6_col4\" class=\"data row6 col4\" >0.999000</td>\n",
       "      <td id=\"T_8482a_row6_col5\" class=\"data row6 col5\" >3</td>\n",
       "      <td id=\"T_8482a_row6_col6\" class=\"data row6 col6\" >49</td>\n",
       "      <td id=\"T_8482a_row6_col7\" class=\"data row6 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row6_col8\" class=\"data row6 col8\" >-1.028690</td>\n",
       "      <td id=\"T_8482a_row6_col9\" class=\"data row6 col9\" >99.600000</td>\n",
       "      <td id=\"T_8482a_row6_col10\" class=\"data row6 col10\" >99.800000</td>\n",
       "      <td id=\"T_8482a_row6_col11\" class=\"data row6 col11\" >99.900000</td>\n",
       "      <td id=\"T_8482a_row6_col12\" class=\"data row6 col12\" >0.996000</td>\n",
       "      <td id=\"T_8482a_row6_col13\" class=\"data row6 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row6_col14\" class=\"data row6 col14\" >3: 99.6%</td>\n",
       "      <td id=\"T_8482a_row6_col15\" class=\"data row6 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row7\" class=\"row_heading level0 row7\" >44</th>\n",
       "      <td id=\"T_8482a_row7_col0\" class=\"data row7 col0\" >2</td>\n",
       "      <td id=\"T_8482a_row7_col1\" class=\"data row7 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row7_col2\" class=\"data row7 col2\" >-10.237578</td>\n",
       "      <td id=\"T_8482a_row7_col3\" class=\"data row7 col3\" >0.000000</td>\n",
       "      <td id=\"T_8482a_row7_col4\" class=\"data row7 col4\" >1.000000</td>\n",
       "      <td id=\"T_8482a_row7_col5\" class=\"data row7 col5\" >2</td>\n",
       "      <td id=\"T_8482a_row7_col6\" class=\"data row7 col6\" >48</td>\n",
       "      <td id=\"T_8482a_row7_col7\" class=\"data row7 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row7_col8\" class=\"data row7 col8\" >-10.225658</td>\n",
       "      <td id=\"T_8482a_row7_col9\" class=\"data row7 col9\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row7_col10\" class=\"data row7 col10\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row7_col11\" class=\"data row7 col11\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row7_col12\" class=\"data row7 col12\" >1.000000</td>\n",
       "      <td id=\"T_8482a_row7_col13\" class=\"data row7 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row7_col14\" class=\"data row7 col14\" >2: 100.0%</td>\n",
       "      <td id=\"T_8482a_row7_col15\" class=\"data row7 col15\" >No</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th id=\"T_8482a_level0_row8\" class=\"row_heading level0 row8\" >45</th>\n",
       "      <td id=\"T_8482a_row8_col0\" class=\"data row8 col0\" >1</td>\n",
       "      <td id=\"T_8482a_row8_col1\" class=\"data row8 col1\" >O</td>\n",
       "      <td id=\"T_8482a_row8_col2\" class=\"data row8 col2\" >-19.239507</td>\n",
       "      <td id=\"T_8482a_row8_col3\" class=\"data row8 col3\" >0.000000</td>\n",
       "      <td id=\"T_8482a_row8_col4\" class=\"data row8 col4\" >1.000000</td>\n",
       "      <td id=\"T_8482a_row8_col5\" class=\"data row8 col5\" >1</td>\n",
       "      <td id=\"T_8482a_row8_col6\" class=\"data row8 col6\" >47</td>\n",
       "      <td id=\"T_8482a_row8_col7\" class=\"data row8 col7\" >O</td>\n",
       "      <td id=\"T_8482a_row8_col8\" class=\"data row8 col8\" >-19.209147</td>\n",
       "      <td id=\"T_8482a_row8_col9\" class=\"data row8 col9\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row8_col10\" class=\"data row8 col10\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row8_col11\" class=\"data row8 col11\" >100.000000</td>\n",
       "      <td id=\"T_8482a_row8_col12\" class=\"data row8 col12\" >1.000000</td>\n",
       "      <td id=\"T_8482a_row8_col13\" class=\"data row8 col13\" >No</td>\n",
       "      <td id=\"T_8482a_row8_col14\" class=\"data row8 col14\" >1: 100.0%</td>\n",
       "      <td id=\"T_8482a_row8_col15\" class=\"data row8 col15\" >No</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7f457b304f90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from somos import io, proj\n",
    "importlib.reload(io)\n",
    "importlib.reload(proj)\n",
    "\n",
    "df_proj, info = proj.project_occupied_alpha_onto_beta(logfolder, logfile)\n",
    "display(proj.show_alpha_to_homo(df_proj, logfolder, logfile))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0bd1b3c7-e068-4c39-959b-d90e6bc28316",
   "metadata": {},
   "source": [
    "### Heatmap"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "bc97b0e1-61ed-4205-bcc9-affd9f88d8c8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>🚨 ENTERING load_mos_from_cclib 🚨</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "UDFT\n",
      "✅ Finished load_mos_from_cclib\n",
      "n_basis = 46\n",
      "Occupied alpha MOs: 9 (1 -> 9)\n",
      "Occupied beta MOs : 7 (47 -> 54)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div style='text-align:center; font-weight: bold; font-size:16px;background-color: #343132;color: #ffffff'>Main projection contribution of Alpha MOs on Beta MOs</div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "f49e042ebd0441d3bb7a2547ce869146",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "HBox(children=(Button(description='💾 Save map', style=ButtonStyle(), tooltip='Save map to PNG in ./logs'),))"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "0f67c0fa5f1442188080f6f6a92ebb34",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "Output()"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3662efaf6a994615ab71f4c30fdcfd68",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "interactive(children=(IntSlider(value=5, continuous_update=False, description='HOMO–n > HOMO', max=30, min=1),…"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "proj.projection_heatmap_from_df(df_proj, info[\"nbasis\"], logfolder, logfile)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37eecd14-fec7-4ed8-a74e-bd3b8ad84df5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
