{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Import packages and functions" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import sys\n", "# force the notebook to look for files in the upper level directory\n", "sys.path.insert(1, '../')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "from glob import glob\n", "import pymatgen as mg\n", "from data.compound_featurizer import read_new_struct, \\\n", " get_struct, get_elem_info, get_elem_distances, \\\n", " calc_mm_dists, calc_mx_dists, calc_xx_dists, calc_elem_max_potential" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Read in the initial dataframe" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "# initialize an empty list of dataframes\n", "df_lst = []\n", "# iterate over all the cif files\n", "for struct_file_path in glob(\"./user_defined_structures/featurizer_sub_function_demo/*.cif\"):\n", " # add the newly read in dataframe to the list\n", " df_lst.append(read_new_struct(struct_file_path))\n", "# concatenate all the dataframes in the list\n", "df = pd.concat(df_lst, ignore_index=True)\n", "# assign oxidation states to BaTiO3 and Mg2AlFeO5\n", "df.at[df[df.Compound == \"BaTiO3\"].index[0], \"structure\"].add_oxidation_state_by_element({\"Ba\": 2, \"Ti\": 4, \"O\": -2})\n", "df.at[df[df.Compound == \"Mg2AlFeO5\"].index[0], \"structure\"].add_oxidation_state_by_element({\"Mg\": 2, \"Al\": 3, \"Fe\": 3, \"O\": -2})" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false, "jupyter": { "outputs_hidden": false }, "pycharm": { "name": "#%%\n" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | Compound | \n", "structure | \n", "
---|---|---|
0 | \n", "Mg2AlFeO5 | \n", "[[0.1798251 1.58702 2.644008 ] Mg2+, [ 6.407... | \n", "
1 | \n", "La2.8Mg1.2Mn4O12 | \n", "[[0.12084071 1.929845 5.45406422] La:0.700, ... | \n", "
2 | \n", "BaTiO3 | \n", "[[0.00849286 0.00844357 0.00854272] Ba2+, [2.1... | \n", "