{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Complexity Reduction\n", "In this tutorial, we will demonstrate the complexity reduction framework of PyBigDFT. We will begin with the notion of fragment observables by extracting some quantities from a calculation. Then we will introduce the notion of fragment purity to determine the quality of a given fragmentation. We will then present the fragment bond order as a means of quantifying fragment interaction and building interaction graphs. Finally, we will use all of that information to automatically partition a system into fragments." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## System Preparation\n", "First we need a system to use an an example. We will start with a CO2 molecule." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from BigDFT.IO import XYZReader\n", "from BigDFT.Systems import System\n", "from BigDFT.Fragments import Fragment\n", "\n", "sys = System()\n", "sys[\"CO2:0\"] = Fragment()\n", "\n", "with XYZReader(\"CO2\") as ifile:\n", " for at in ifile:\n", " sys[\"CO2:0\"].append(at)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "from BigDFT.IO import write_pdb\n", "with open(\"CO2.pdb\", \"w\") as ofile:\n", " write_pdb(sys, ofile)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's put that in a water box using the [PDB](https://github.com/openmm/pdbfixer) fixer program." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from os import system\n", "from os.path import exists\n", "\n", "# So you don't have to recalculate!\n", "if not exists(\"test.pdb\"):\n", " system(\"pdbfixer CO2.pdb --water-box=1 1 1 --output test.pdb\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "from BigDFT.IO import read_pdb\n", "with open(\"test.pdb\") as ifile:\n", " sys = read_pdb(ifile)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Visualize the system we created." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "application/3dmoljs_load.v0": "
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n jupyter labextension install jupyterlab_3dmol
You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
\n",
" jupyter labextension install jupyterlab_3dmol