<commit_before>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import smact.lattice as lattice\n",
    "import smact.builder as builder\n",
    "import smact.core as core\n",
    "import copy\n",
    "import os\n",
    "import csv\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# get correct path for datafiles when called from another directory\n",
    "smact_directory = '../../smact'\n",
    "# Append a trailing slash to make coherent directory name - this would select the\n",
    "# root directory in the case of no prefix, so we need to check\n",
    "if smact_directory:\n",
    "    smact_directory = smact_directory + '/'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set up a lattice object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "site_A = lattice.Site([0,0,0],[+1,+2,+3])\n",
    "site_B = lattice.Site([0.5,0.5,0.5],[+5,+4,+3,+2])\n",
    "site_C = lattice.Site([0.5,0.5,0.5],[-2,-1])\n",
    "perovskite = lattice.Lattice([site_A,site_B,site_C],space_group=221)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set up a search space with Josh's command"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "search = core.ordered_elements(3,37)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Assign potential elements to each site, based on known coordination environments\n",
    "* A site : 12 coordinated\n",
    "* B site : 8 coordinated\n",
    "* The third item in the list for each species is the Shannon radius for that charge state"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "A_list = []\n",
    "B_list = []\n",
    "C_list = [['O',-2,1.35],['S',-2,1.84],['Se',-2,1.98],['F',-1,1.285],['Br',-1,1.96],['I',-1,2.2]]\n",
    "for element in search:\n",
    "    with open(smact_directory + 'data/shannon_radii.csv','rU') as f:\n",
    "        reader = csv.reader(f)\n",
    "        r_shannon=False\n",
    "        for row in reader:\n",
    "            if row[2]==\"12_n\" and row[0]==element and int(row[1]) in site_A.oxidation_states:\n",
    "                A_list.append([row[0],row[1],row[4]])\n",
    "            if row[2]==\"8_n\" and row[0]==element and int(row[1]) in site_B.oxidation_states:\n",
    "                B_list.append([row[0],row[1],row[4]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "charge_balanced = []\n",
    "goldschmidt_cubic = []\n",
    "goldschmidt_ortho = []\n",
    "a_too_large = []\n",
    "A_B_similar = []\n",
    "\n",
    "for A in A_list:\n",
    "    for B in B_list:\n",
    "        for C in C_list:\n",
    "            if int(A[1])+int(B[1])+3*int(C[1]) == 0:\n",
    "                charge_balanced.append([A[0],B[0],C[0]])\n",
    "                tol = (float(A[2]) + C[2])/(np.sqrt(2)*(float(B[2])+C[2]))\n",
    "                if tol > 1.0:\n",
    "                    a_too_large.append([A[0],B[0],C[0]])\n",
    "                if tol > 0.9 and tol <= 1.0:\n",
    "                    goldschmidt_cubic.append([A[0],B[0],C[0]])\n",
    "                if tol >= 0.71 and tol < 0.9:\n",
    "                    goldschmidt_ortho.append([A[0],B[0],C[0]])\n",
    "                if tol < 0.71:\n",
    "                    A_B_similar.append([A[0],B[0],C[0]])\n",
    "                    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Number of possible charge neutral perovskites from Li to Kr = 48\n",
      "Number of possible cubic perovskites from Li to Kr = 9\n",
      "Number of possible ortho perovskites from Li to Kr = 35\n",
      "Number of possible hexagonal perovskites from Li to Kr = 4\n",
      "Number of possible non-perovskites from Li to Kr = 0\n"
     ]
    }
   ],
   "source": [
    "print 'Number of possible charge neutral perovskites from', search[0], 'to', search[len(search)-1], '=', len(charge_balanced)\n",
    "print 'Number of possible cubic perovskites from', search[0], 'to', search[len(search)-1], '=', len(goldschmidt_cubic)\n",
    "print 'Number of possible ortho perovskites from', search[0], 'to', search[len(search)-1], '=', len(goldschmidt_ortho)\n",
    "print 'Number of possible hexagonal perovskites from', search[0], 'to', search[len(search)-1], '=', len(a_too_large)\n",
    "print 'Number of possible non-perovskites from', search[0], 'to', search[len(search)-1], '=', len(A_B_similar)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['Na', 'Mg', 'F'], ['Na', 'Mg', 'Br'], ['Na', 'Mg', 'I'], ['Na', 'Ca', 'F'], ['Na', 'Ca', 'Br'], ['Na', 'Ca', 'I'], ['Na', 'Cr', 'O'], ['Na', 'Cr', 'S'], ['Na', 'Cr', 'Se'], ['Na', 'Mn', 'F'], ['Na', 'Mn', 'Br'], ['Na', 'Mn', 'I'], ['Na', 'Fe', 'F'], ['Na', 'Fe', 'Br'], ['Na', 'Fe', 'I'], ['Na', 'Co', 'F'], ['Na', 'Co', 'Br'], ['Na', 'Co', 'I'], ['Na', 'Zn', 'F'], ['Na', 'Zn', 'Br'], ['Na', 'Zn', 'I'], ['K', 'Mg', 'F'], ['K', 'Mg', 'Br'], ['K', 'Mg', 'I'], ['K', 'Ca', 'F'], ['K', 'Ca', 'Br'], ['K', 'Ca', 'I'], ['K', 'Cr', 'O'], ['K', 'Cr', 'S'], ['K', 'Cr', 'Se'], ['K', 'Mn', 'F'], ['K', 'Mn', 'Br'], ['K', 'Mn', 'I'], ['K', 'Fe', 'F'], ['K', 'Fe', 'Br'], ['K', 'Fe', 'I'], ['K', 'Co', 'F'], ['K', 'Co', 'Br'], ['K', 'Co', 'I'], ['K', 'Zn', 'F'], ['K', 'Zn', 'Br'], ['K', 'Zn', 'I'], ['Ca', 'Ti', 'O'], ['Ca', 'Ti', 'S'], ['Ca', 'Ti', 'Se'], ['Ca', 'V', 'O'], ['Ca', 'V', 'S'], ['Ca', 'V', 'Se']]\n"
     ]
    }
   ],
   "source": [
    "print charge_balanced\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2<commit_msg>Added Pauling criterion to the search<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import smact.lattice as lattice\n",
    "import smact.builder as builder\n",
    "import smact.core as core\n",
    "import copy\n",
    "import os\n",
    "import csv\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# get correct path for datafiles when called from another directory\n",
    "smact_directory = '../../smact'\n",
    "# Append a trailing slash to make coherent directory name - this would select the\n",
    "# root directory in the case of no prefix, so we need to check\n",
    "if smact_directory:\n",
    "    smact_directory = smact_directory + '/'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set up a lattice object"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "site_A = lattice.Site([0,0,0],[+1,+2,+3])\n",
    "site_B = lattice.Site([0.5,0.5,0.5],[+5,+4,+3,+2])\n",
    "site_C = lattice.Site([0.5,0.5,0.5],[-2,-1])\n",
    "perovskite = lattice.Lattice([site_A,site_B,site_C],space_group=221)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set up a search space with Josh's command"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "search = core.ordered_elements(3,87)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###Assign potential elements to each site, based on known coordination environments\n",
    "* A site : 12 coordinated\n",
    "* B site : 8 coordinated\n",
    "* The third item in the list for each species is the Shannon radius for that charge state"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "A_list = []\n",
    "B_list = []\n",
    "C_list = [['O',-2,1.35],['S',-2,1.84],['Se',-2,1.98],['F',-1,1.285],['Br',-1,1.96],['I',-1,2.2]]\n",
    "for element in search:\n",
    "    with open(smact_directory + 'data/shannon_radii.csv','rU') as f:\n",
    "        reader = csv.reader(f)\n",
    "        r_shannon=False\n",
    "        for row in reader:\n",
    "            if row[2]==\"12_n\" and row[0]==element and int(row[1]) in site_A.oxidation_states:\n",
    "                A_list.append([row[0],row[1],row[4]])\n",
    "            if row[2]==\"8_n\" and row[0]==element and int(row[1]) in site_B.oxidation_states:\n",
    "                B_list.append([row[0],row[1],row[4]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "charge_balanced = []\n",
    "goldschmidt_cubic = []\n",
    "goldschmidt_ortho = []\n",
    "a_too_large = []\n",
    "A_B_similar = []\n",
    "pauling_perov = []\n",
    "for A in A_list:\n",
    "    for B in B_list:\n",
    "        for C in C_list:\n",
    "            if int(A[1])+int(B[1])+3*int(C[1]) == 0:\n",
    "                charge_balanced.append([A[0],B[0],C[0]])\n",
    "                paul_a = core.Element(A[0]).pauling_eneg\n",
    "                paul_b = core.Element(B[0]).pauling_eneg\n",
    "                paul_c = core.Element(C[0]).pauling_eneg\n",
    "                electroneg_makes_sense = core.pauling_test([A[1],B[1],C[1]], [paul_a,paul_b,paul_c])\n",
    "                if electroneg_makes_sense:\n",
    "                    pauling_perov.append([A[0],B[0],C[0]])\n",
    "                    tol = (float(A[2]) + C[2])/(np.sqrt(2)*(float(B[2])+C[2]))\n",
    "                    if tol > 1.0:\n",
    "                        a_too_large.append([A[0],B[0],C[0]])\n",
    "                    if tol > 0.9 and tol <= 1.0:\n",
    "                        goldschmidt_cubic.append([A[0],B[0],C[0]])\n",
    "                    if tol >= 0.71 and tol < 0.9:\n",
    "                        goldschmidt_ortho.append([A[0],B[0],C[0]])\n",
    "                    if tol < 0.71:\n",
    "                        A_B_similar.append([A[0],B[0],C[0]])\n",
    "                    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      " Number of possible charge neutral perovskites from Li to Rn = 702\n",
      "Number of Pauling senseibe perovskites from Li to Rn = 141\n",
      "Number of possible cubic perovskites from Li to Rn = 21\n",
      "Number of possible ortho perovskites from Li to Rn = 115\n",
      "Number of possible hexagonal perovskites from Li to Rn = 2\n",
      "Number of possible non-perovskites from Li to Rn = 3\n"
     ]
    }
   ],
   "source": [
    "print 'Number of possible charge neutral perovskites from', search[0], 'to', search[len(search)-1], '=', len(charge_balanced)\n",
    "print 'Number of Pauling senseibe perovskites from', search[0], 'to', search[len(search)-1], '=', len(pauling_perov)\n",
    "print 'Number of possible cubic perovskites from', search[0], 'to', search[len(search)-1], '=', len(goldschmidt_cubic)\n",
    "print 'Number of possible ortho perovskites from', search[0], 'to', search[len(search)-1], '=', len(goldschmidt_ortho)\n",
    "print 'Number of possible hexagonal perovskites from', search[0], 'to', search[len(search)-1], '=', len(a_too_large)\n",
    "print 'Number of possible non-perovskites from', search[0], 'to', search[len(search)-1], '=', len(A_B_similar)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[['Na', 'Ba', 'F'], ['Na', 'Ba', 'Br'], ['Na', 'Ba', 'I'], ['Na', 'Eu', 'F'], ['Na', 'Eu', 'Br'], ['Na', 'Eu', 'I'], ['Na', 'Yb', 'F'], ['Na', 'Yb', 'Br'], ['Na', 'Yb', 'I'], ['K', 'Eu', 'F'], ['K', 'Eu', 'Br'], ['K', 'Eu', 'I'], ['K', 'Yb', 'F'], ['K', 'Yb', 'Br'], ['K', 'Yb', 'I'], ['Ca', 'Tb', 'O'], ['Ca', 'Tb', 'S'], ['Ca', 'Tb', 'Se'], ['Rb', 'Eu', 'F'], ['Rb', 'Eu', 'Br'], ['Rb', 'Eu', 'I'], ['Rb', 'Yb', 'F'], ['Rb', 'Yb', 'Br'], ['Rb', 'Yb', 'I'], ['Sr', 'Tb', 'O'], ['Sr', 'Tb', 'S'], ['Sr', 'Tb', 'Se'], ['Cd', 'Ti', 'O'], ['Cd', 'Ti', 'S'], ['Cd', 'Ti', 'Se'], ['Cd', 'V', 'O'], ['Cd', 'V', 'S'], ['Cd', 'V', 'Se'], ['Cd', 'Zr', 'O'], ['Cd', 'Zr', 'S'], ['Cd', 'Zr', 'Se'], ['Cd', 'Nb', 'O'], ['Cd', 'Nb', 'S'], ['Cd', 'Nb', 'Se'], ['Cd', 'Ce', 'O'], ['Cd', 'Ce', 'S'], ['Cd', 'Ce', 'Se'], ['Cd', 'Pr', 'O'], ['Cd', 'Pr', 'S'], ['Cd', 'Pr', 'Se'], ['Cd', 'Tb', 'O'], ['Cd', 'Tb', 'S'], ['Cd', 'Tb', 'Se'], ['Cd', 'Hf', 'O'], ['Cd', 'Hf', 'S'], ['Cd', 'Hf', 'Se'], ['Cs', 'Eu', 'F'], ['Cs', 'Eu', 'Br'], ['Cs', 'Eu', 'I'], ['Cs', 'Yb', 'F'], ['Cs', 'Yb', 'Br'], ['Cs', 'Yb', 'I'], ['Ba', 'Tb', 'O'], ['Ba', 'Tb', 'S'], ['Ba', 'Tb', 'Se'], ['La', 'La', 'O'], ['La', 'La', 'S'], ['La', 'La', 'Se'], ['Ce', 'Ce', 'O'], ['Ce', 'Ce', 'S'], ['Ce', 'Ce', 'Se'], ['Nd', 'Nd', 'O'], ['Nd', 'Nd', 'S'], ['Nd', 'Nd', 'Se'], ['Sm', 'Sm', 'O'], ['Sm', 'Sm', 'S'], ['Sm', 'Sm', 'Se'], ['Tl', 'Mg', 'F'], ['Tl', 'Mg', 'Br'], ['Tl', 'Mg', 'I'], ['Tl', 'Ca', 'F'], ['Tl', 'Ca', 'Br'], ['Tl', 'Ca', 'I'], ['Tl', 'Mn', 'F'], ['Tl', 'Mn', 'Br'], ['Tl', 'Mn', 'I'], ['Tl', 'Sr', 'F'], ['Tl', 'Sr', 'Br'], ['Tl', 'Sr', 'I'], ['Tl', 'Nb', 'O'], ['Tl', 'Nb', 'S'], ['Tl', 'Nb', 'Se'], ['Tl', 'Ba', 'F'], ['Tl', 'Ba', 'Br'], ['Tl', 'Ba', 'I'], ['Tl', 'Nd', 'F'], ['Tl', 'Nd', 'Br'], ['Tl', 'Nd', 'I'], ['Tl', 'Sm', 'F'], ['Tl', 'Sm', 'Br'], ['Tl', 'Sm', 'I'], ['Tl', 'Eu', 'F'], ['Tl', 'Eu', 'Br'], ['Tl', 'Eu', 'I'], ['Tl', 'Dy', 'F'], ['Tl', 'Dy', 'Br'], ['Tl', 'Dy', 'I'], ['Tl', 'Yb', 'F'], ['Tl', 'Yb', 'Br'], ['Tl', 'Yb', 'I'], ['Tl', 'Ta', 'O'], ['Tl', 'Ta', 'S'], ['Tl', 'Ta', 'Se'], ['Pb', 'Ti', 'O'], ['Pb', 'Ti', 'S'], ['Pb', 'Ti', 'Se'], ['Pb', 'V', 'O'], ['Pb', 'V', 'S'], ['Pb', 'V', 'Se'], ['Pb', 'Zr', 'O'], ['Pb', 'Zr', 'S'], ['Pb', 'Zr', 'Se'], ['Pb', 'Nb', 'O'], ['Pb', 'Nb', 'S'], ['Pb', 'Nb', 'Se'], ['Pb', 'Sn', 'O'], ['Pb', 'Sn', 'S'], ['Pb', 'Sn', 'Se'], ['Pb', 'Ce', 'O'], ['Pb', 'Ce', 'S'], ['Pb', 'Ce', 'Se'], ['Pb', 'Pr', 'O'], ['Pb', 'Pr', 'S'], ['Pb', 'Pr', 'Se'], ['Pb', 'Tb', 'O'], ['Pb', 'Tb', 'S'], ['Pb', 'Tb', 'Se'], ['Pb', 'Hf', 'O'], ['Pb', 'Hf', 'S'], ['Pb', 'Hf', 'Se'], ['Pb', 'Pb', 'O'], ['Pb', 'Pb', 'S'], ['Pb', 'Pb', 'Se'], ['Pb', 'Po', 'O'], ['Pb', 'Po', 'S'], ['Pb', 'Po', 'Se']]\n"
     ]
    }
   ],
   "source": [
    "print pauling_perov"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
{'fraction_non_alphanumeric': 0.2893128819054745, 'fraction_numerical': 0.019516149145778774, 'mean_word_length': 2.7738823529411767, 'pattern_counts': {'":': 164, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '126684', 'n_tokens_mistral': 6875, 'n_tokens_neox': 6476, 'n_words': 1498}