{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "378ede26-4ab0-4c0b-80e0-5dfa8534446f", "metadata": { "tags": [] }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from rdkit import Chem\n", "from rdkit.Chem import AllChem, Draw, PandasTools\n", "\n", "from rdkit.Chem.rdDistGeom import ETKDG, ETKDGv3, EmbedMolecule\n", "from rdkit.Chem.rdForceFieldHelpers import MMFFHasAllMoleculeParams, MMFFOptimizeMolecule\n", "from rdkit.Chem.Draw import IPythonConsole\n", "import psi4\n", "\n", "import datetime\n", "import time\n", "\n", "def GetSpinMultiplicity(Mol, CheckMolProp = True):\n", " \"\"\"Get spin multiplicity of a molecule. The spin multiplicity is either\n", " retrieved from 'SpinMultiplicity' molecule property or calculated\n", " from the number of free radical electrons using Hund's rule of maximum\n", " multiplicity defined as 2S + 1 where S is the total electron spin. The\n", " total spin is 1/2 the number of free radical electrons in a molecule.\n", " \n", " The 'SpinMultiplicity' molecule property may contain multiple space delimited\n", " values. The total spin multiplicity corresponds to the total number of free radical\n", " electrons which are calculated for each specified value.\n", " \n", " Arguments:\n", " Mol (object): RDKit molecule object.\n", " CheckMolProp (bool): Check 'SpinMultiplicity' molecule property to\n", " retrieve spin multiplicity.\n", " \n", " Returns:\n", " int : Spin multiplicity.\n", " \n", " \"\"\"\n", " \n", " Name = 'SpinMultiplicity'\n", " if (CheckMolProp and Mol.HasProp(Name)):\n", " SpinMultiplicity = Mol.GetProp(Name)\n", " Values = SpinMultiplicity.split()\n", " if len(Values) > 1:\n", " MiscUtil.PrintWarning(\"RDKitUtil.GetSpinMultiplicity: Molecule property, %s, contains multiple values, %s. Calculating spin multiplicity corresponding to total number of free radical electrons for each specified value...\" % (Name, SpinMultiplicity))\n", " NumRadicalElectrons = 0\n", " for Value in Values:\n", " NumRadicalElectrons += int(float(Value)) - 1\n", " \n", " TotalElectronicSpin = NumRadicalElectrons/2\n", " SpinMultiplicity = 2 * TotalElectronicSpin + 1\n", " else:\n", " SpinMultiplicity = int(float(SpinMultiplicity))\n", " else:\n", " SpinMultiplicity = CalculateSpinMultiplicity(Mol)\n", " \n", " return int(SpinMultiplicity)\n", "\n", "def CalculateSpinMultiplicity(Mol):\n", " \"\"\"Calculate spin multiplicity of a molecule. The spin multiplicity is calculated\n", " from the number of free radical electrons using Hund's rule of maximum\n", " multiplicity defined as 2S + 1 where S is the total electron spin. The\n", " total spin is 1/2 the number of free radical electrons in a molecule.\n", " \n", " Arguments:\n", " Mol (object): RDKit molecule object.\n", " \n", " Returns:\n", " int : Spin multiplicity.\n", " \n", " \"\"\"\n", " \n", " # Calculate spin multiplicity using Hund's rule of maximum multiplicity...\n", " NumRadicalElectrons = 0\n", " for Atom in Mol.GetAtoms():\n", " NumRadicalElectrons += Atom.GetNumRadicalElectrons()\n", " TotalElectronicSpin = NumRadicalElectrons/2\n", " SpinMultiplicity = 2 * TotalElectronicSpin + 1\n", " return int(SpinMultiplicity)" ] }, { "cell_type": "code", "execution_count": 2, "id": "ebb54891-5fbb-4245-a427-62fe5996b012", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", " Memory set to 5.588 GiB by Python driver.\n", "mol_input = 0 2\n", " O 0.7119609356786913 0.0 0.0\n", " N -0.7119609356786913 0.0 0.0\n" ] }, { "ename": "SCFConvergenceError", "evalue": "Could not converge SCF iterations in 1000 iterations.", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mSCFConvergenceError\u001b[0m Traceback (most recent call last)", "File \u001b[0;32m:67\u001b[0m\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/driver.py:1245\u001b[0m, in \u001b[0;36moptimize\u001b[0;34m(name, **kwargs)\u001b[0m\n\u001b[1;32m 1242\u001b[0m opt_calcs \u001b[38;5;241m=\u001b[39m opt_object\u001b[38;5;241m.\u001b[39mcalculations_needed() \u001b[38;5;66;03m# tuple of strings ('energy', 'gradient', etc)\u001b[39;00m\n\u001b[1;32m 1244\u001b[0m \u001b[38;5;66;03m# Compute the gradient - no longer need to worry about opt_data being wiped\u001b[39;00m\n\u001b[0;32m-> 1245\u001b[0m G, wfn \u001b[38;5;241m=\u001b[39m \u001b[43mgradient\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlowername\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mreturn_wfn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmolecule\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmolecule\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1246\u001b[0m thisenergy \u001b[38;5;241m=\u001b[39m core\u001b[38;5;241m.\u001b[39mvariable(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCURRENT ENERGY\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 1247\u001b[0m opt_object\u001b[38;5;241m.\u001b[39mE \u001b[38;5;241m=\u001b[39m thisenergy\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/driver.py:639\u001b[0m, in \u001b[0;36mgradient\u001b[0;34m(name, **kwargs)\u001b[0m\n\u001b[1;32m 637\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCompute gradient(): method=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mlowername\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, basis=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcore\u001b[38;5;241m.\u001b[39mget_global_option(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mBASIS\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;241m.\u001b[39mlower()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, molecule=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmolecule\u001b[38;5;241m.\u001b[39mname()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m, nre=\u001b[39m\u001b[38;5;132;01m{\u001b[39;00m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mw/EFP\u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mif\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28mhasattr\u001b[39m(molecule,\u001b[38;5;250m \u001b[39m\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mEFP\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01melse\u001b[39;00m\u001b[38;5;250m \u001b[39mmolecule\u001b[38;5;241m.\u001b[39mnuclear_repulsion_energy()\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 638\u001b[0m logger\u001b[38;5;241m.\u001b[39mdebug(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mw/EFP\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mhasattr\u001b[39m(molecule, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mEFP\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;28;01melse\u001b[39;00m pp\u001b[38;5;241m.\u001b[39mpformat(molecule\u001b[38;5;241m.\u001b[39mto_dict()))\n\u001b[0;32m--> 639\u001b[0m wfn \u001b[38;5;241m=\u001b[39m \u001b[43mprocedures\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43mgradient\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[43mlowername\u001b[49m\u001b[43m]\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlowername\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mmolecule\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mmolecule\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 640\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mReturn gradient(): \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mcore\u001b[38;5;241m.\u001b[39mvariable(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCURRENT ENERGY\u001b[39m\u001b[38;5;124m'\u001b[39m)\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 641\u001b[0m logger\u001b[38;5;241m.\u001b[39minfo(nppp(wfn\u001b[38;5;241m.\u001b[39mgradient()\u001b[38;5;241m.\u001b[39mnp))\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/proc.py:93\u001b[0m, in \u001b[0;36mselect_scf_gradient\u001b[0;34m(name, **kwargs)\u001b[0m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m\n\u001b[1;32m 92\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[0;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/proc.py:2671\u001b[0m, in \u001b[0;36mrun_scf_gradient\u001b[0;34m(name, **kwargs)\u001b[0m\n\u001b[1;32m 2669\u001b[0m ref_wfn \u001b[38;5;241m=\u001b[39m kwargs\u001b[38;5;241m.\u001b[39mget(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mref_wfn\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;28;01mNone\u001b[39;00m)\n\u001b[1;32m 2670\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m ref_wfn \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m-> 2671\u001b[0m ref_wfn \u001b[38;5;241m=\u001b[39m \u001b[43mrun_scf\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2673\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m core\u001b[38;5;241m.\u001b[39mget_option(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mSCF\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mREFERENCE\u001b[39m\u001b[38;5;124m'\u001b[39m) \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mROHF\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mCUHF\u001b[39m\u001b[38;5;124m'\u001b[39m]:\n\u001b[1;32m 2674\u001b[0m ref_wfn\u001b[38;5;241m.\u001b[39msemicanonicalize()\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/proc.py:2571\u001b[0m, in \u001b[0;36mrun_scf\u001b[0;34m(name, **kwargs)\u001b[0m\n\u001b[1;32m 2568\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m core\u001b[38;5;241m.\u001b[39mhas_global_option_changed(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mSCF_TYPE\u001b[39m\u001b[38;5;124m'\u001b[39m):\n\u001b[1;32m 2569\u001b[0m core\u001b[38;5;241m.\u001b[39mset_global_option(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mSCF_TYPE\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mDF\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m-> 2571\u001b[0m scf_wfn \u001b[38;5;241m=\u001b[39m \u001b[43mscf_helper\u001b[49m\u001b[43m(\u001b[49m\u001b[43mname\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mpost_scf\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mFalse\u001b[39;49;00m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2572\u001b[0m returnvalue \u001b[38;5;241m=\u001b[39m scf_wfn\u001b[38;5;241m.\u001b[39menergy()\n\u001b[1;32m 2574\u001b[0m ssuper \u001b[38;5;241m=\u001b[39m scf_wfn\u001b[38;5;241m.\u001b[39mfunctional()\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/proc.py:1870\u001b[0m, in \u001b[0;36mscf_helper\u001b[0;34m(name, post_scf, **kwargs)\u001b[0m\n\u001b[1;32m 1862\u001b[0m core\u001b[38;5;241m.\u001b[39mprint_out(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\"\"\u001b[39m\u001b[38;5;124m Using potential file\u001b[39m\n\u001b[1;32m 1863\u001b[0m \u001b[38;5;124m \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mpol_embed_options[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpotfile\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\n\u001b[1;32m 1864\u001b[0m \u001b[38;5;124m for Polarizable Embedding calculation.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\"\"\u001b[39m)\n\u001b[1;32m 1865\u001b[0m scf_wfn\u001b[38;5;241m.\u001b[39mpe_state \u001b[38;5;241m=\u001b[39m solvent\u001b[38;5;241m.\u001b[39mpol_embed\u001b[38;5;241m.\u001b[39mCppeInterface(\n\u001b[1;32m 1866\u001b[0m molecule\u001b[38;5;241m=\u001b[39mscf_molecule, options\u001b[38;5;241m=\u001b[39mpol_embed_options,\n\u001b[1;32m 1867\u001b[0m basisset\u001b[38;5;241m=\u001b[39mscf_wfn\u001b[38;5;241m.\u001b[39mbasisset()\n\u001b[1;32m 1868\u001b[0m )\n\u001b[0;32m-> 1870\u001b[0m e_scf \u001b[38;5;241m=\u001b[39m \u001b[43mscf_wfn\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mcompute_energy\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 1871\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m obj \u001b[38;5;129;01min\u001b[39;00m [core, scf_wfn]:\n\u001b[1;32m 1872\u001b[0m \u001b[38;5;66;03m# set_variable(\"SCF TOTAL ENERGY\") # P::e SCF\u001b[39;00m\n\u001b[1;32m 1873\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m pv \u001b[38;5;129;01min\u001b[39;00m [\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSCF TOTAL ENERGY\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCURRENT ENERGY\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mCURRENT REFERENCE ENERGY\u001b[39m\u001b[38;5;124m\"\u001b[39m]:\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/scf_proc/scf_iterator.py:92\u001b[0m, in \u001b[0;36mscf_compute_energy\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 88\u001b[0m core\u001b[38;5;241m.\u001b[39mprint_out(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m Failed to converge.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 89\u001b[0m \u001b[38;5;66;03m# energy = 0.0\u001b[39;00m\n\u001b[1;32m 90\u001b[0m \u001b[38;5;66;03m# A P::e fn to either throw or protest upon nonconvergence\u001b[39;00m\n\u001b[1;32m 91\u001b[0m \u001b[38;5;66;03m# die_if_not_converged()\u001b[39;00m\n\u001b[0;32m---> 92\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m e\n\u001b[1;32m 93\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 94\u001b[0m core\u001b[38;5;241m.\u001b[39mprint_out(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m Energy and/or wave function did not converge, but proceeding anyway.\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/scf_proc/scf_iterator.py:85\u001b[0m, in \u001b[0;36mscf_compute_energy\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 82\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39minitialize()\n\u001b[1;32m 84\u001b[0m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[0;32m---> 85\u001b[0m \u001b[38;5;28;43mself\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miterations\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 86\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m SCFConvergenceError \u001b[38;5;28;01mas\u001b[39;00m e:\n\u001b[1;32m 87\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m core\u001b[38;5;241m.\u001b[39mget_option(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mSCF\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mFAIL_ON_MAXITER\u001b[39m\u001b[38;5;124m\"\u001b[39m):\n", "File \u001b[0;32m~/mywin/mywork/minfo/software/psi4/psi4-1.7/build/stage/lib/psi4/driver/procrouting/scf_proc/scf_iterator.py:519\u001b[0m, in \u001b[0;36mscf_iterate\u001b[0;34m(self, e_conv, d_conv)\u001b[0m\n\u001b[1;32m 516\u001b[0m \u001b[38;5;28;01mbreak\u001b[39;00m\n\u001b[1;32m 518\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39miteration_ \u001b[38;5;241m>\u001b[39m\u001b[38;5;241m=\u001b[39m core\u001b[38;5;241m.\u001b[39mget_option(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mSCF\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mMAXITER\u001b[39m\u001b[38;5;124m'\u001b[39m):\n\u001b[0;32m--> 519\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m SCFConvergenceError(\u001b[38;5;124m\"\"\"\u001b[39m\u001b[38;5;124mSCF iterations\u001b[39m\u001b[38;5;124m\"\"\"\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39miteration_, \u001b[38;5;28mself\u001b[39m, Ediff, Dnorm)\n", "\u001b[0;31mSCFConvergenceError\u001b[0m: Could not converge SCF iterations in 1000 iterations." ] } ], "source": [ "%%time\n", "psi4.core.clean()\n", "\n", "#psi4.set_num_threads(nthread=1)\n", "psi4.set_memory(\"6GB\")\n", "\n", "suppl = Chem.SDMolSupplier(\"Structure2D_COMPOUND_CID_145068.sdf\", removeHs=False)\n", "smile = \"[N]=O\"\n", "\n", "\"\"\"\n", "RuntimeError: \n", "Fatal Error: RHF: RHF reference is only for singlets.\n", "Error occurred in file: /home/tomohisa/mywin/mywork/minfo/software/psi4/psi4-1.7/psi4/src/psi4/libscf_solver/rhf.cc on line: 92\n", "The most recent 5 function calls were:\n", "psi::PsiException::PsiException(std::__cxx11::basic_string, std::allocator >, char const*, int)\n", "\"\"\"\n", "\n", "mols = [x for x in suppl if x is not None]\n", "mol = mols[0]\n", "\n", "# GetSpinMultiplicity()\n", "# http://www.mayachemtools.org/docs/modules/html/code/RDKitUtil.py.html\n", "spin = GetSpinMultiplicity(mol)\n", "\n", "#mol = Chem.MolFromSmiles(smile)\n", "mol = Chem.AddHs(mol)\n", "#print(type(mol))\n", "#\n", "\n", "# 3d structure \n", "params = ETKDGv3()\n", "dt_now = datetime.datetime.now()\n", "params.randomseed = int(dt_now.microsecond) \n", "EmbedMolecule(mol, params)\n", "\n", "# MMFF(Merck Molecular Force Field) \n", "MMFFOptimizeMolecule(mol)\n", "#UFF(Universal Force Field)\n", "#UFFOptimizeMolecule(mol)\n", "\n", "conf = mol.GetConformer()\n", "\n", "# chatge \" \" spin-multiplicity\n", "mol_input = \"0 \" + str(spin)\n", "for atom in mol.GetAtoms():\n", " mol_input += \"\\n \" + atom.GetSymbol() \\\n", " + \" \" + str(conf.GetAtomPosition(atom.GetIdx()).x)\\\n", " + \" \" + str(conf.GetAtomPosition(atom.GetIdx()).y)\\\n", " + \" \" + str(conf.GetAtomPosition(atom.GetIdx()).z)\n", "\n", "print(f\"mol_input = {mol_input}\")\n", "molecule = psi4.geometry(mol_input)\n", "\n", "# https://psicode.org/psi4manual/4.0b2/autodir_options_c/module__scf.html\n", "psi4.set_options({'reference': 'UHF'}) # default is RHF\n", "#psi4.set_options({'reference':'uks'})\n", "psi4.set_options({'MAXITER': 1000}) # Default is 100\n", "psi4.set_options({'geom_maxiter': 1000}) # Default is 50\n", "#psi4.set_options({\"intrafrag_step_limit_max\": 1}) # default is 1.00\n", "psi4.set_output_file(\"log.log\")\n", "\n", "\n", "level = \"hf/sto-3g\"\n", "#level = \"mp2/6-31G(d)\"\n", "#level = \"b3lyp/6-31G*\"\n", "\n", "psi4.optimize(level, molecule=molecule)\n", "#energy, wf = psi4.optimize(level, molecule=molecule, return_wfn=True)\n", "energy, wf = psi4.energy(level, molecule=molecule, return_wfn=True)\n" ] }, { "cell_type": "code", "execution_count": null, "id": "661d4f86-a5b1-4219-aa75-67effb654314", "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.9.10" } }, "nbformat": 4, "nbformat_minor": 5 }