diff --git a/analysis.py b/analysis.py index 3792b46..7513ab2 100644 --- a/analysis.py +++ b/analysis.py @@ -9,8 +9,8 @@ def calc_redox(cl1, cl2, energy_ref = None): cl2 (Calculation) - structure with lower concentration energy_ref (float) - energy in eV per one alkali ion in anode; default value is for Li; -1.31 eV for Na, -1.02 eV for K """ - cl1 = cl1 - cl2 = cl2 + if cl1 is None or cl2 is None: + return energy_ref_dict = {3:-1.9, 11:-1.31, 19:-1.02} z_alk_ions = [3, 11, 19] @@ -78,7 +78,7 @@ def calc_redox(cl1, cl2, energy_ref = None): # final_outstring = ("{:} | {:.2f} eV \n1".format(cl1.id[0]+'.'+cl1.id[1], redox )) final_outstring = ("{:30} | {:10.2f} eV | {:10.1f} %".format(cl1.name, redox, vol_red )) - printlog( final_outstring ) + printlog( final_outstring, end = '\n' ) try: results_dic = {'is':cl1.id[0], 'redox_pot':redox, 'id_is':cl1.id, 'id_ds':cl2.id, diff --git a/database.py b/database.py index a6adb3c..a65e008 100644 --- a/database.py +++ b/database.py @@ -252,7 +252,7 @@ def check(key, inquiry_keys): if len(x1s) == 0 or len(x2s) == 0: - print('No information in database for this inquire') + print('No information in database for this inquire:', x1, x2, mat, str(inquiry_keys) ) return None, None key1 = x1s[0] diff --git a/tutorials/working_with_database.ipynb b/tutorials/working_with_database.ipynb index d08882e..6511810 100644 --- a/tutorials/working_with_database.ipynb +++ b/tutorials/working_with_database.ipynb @@ -1,46 +1,81 @@ { "metadata": { "name": "", - "signature": "sha256:014b208250907b1d16d86d21c53f4bd29151965472dfbfbccda1bc64bde3816a" + "signature": "sha256:e1b4245844ccede90e9e49397e097a17e649aceb667830051a0f53fce50fc2a5" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###1. Install required packages:\n", + "\n", + "- Install [Anaconda](https://www.continuum.io/downloads). For linux it is enought to install just [IPython](https://ipython.org/install.html) or [Jupyter Notebook](https://jupyter.readthedocs.io/en/latest/install.html)\n", + "- Install [paramiko](http://www.paramiko.org/) package by running in command line *pip install paramiko*\n", + "- Download siman package from https://github.com/dimonaks/siman/archive/v0.2.zip \n", + " and unpack into your folder, for example *'C:/programms/siman-0.2'*\n", + "- Download SSHTools from http://zhugayevych.me/python/SSHTools/SSHTools.zip and unpack into *'C:/programms/SSHTools'*\n", + "- open this file (*siman-0.2/tutorials/working_with_database.ipynb*) in Notebook\n", + "\n", + "###2. Import packages:" + ] + }, { "cell_type": "code", "collapsed": false, "input": [ - "for mat in ['LiFePO4', 'LiTiO2']:\n", - " # cl1, cl2 = get_from_database('x1', 'x0', mat, inquiry_keys = ['UGGA-Upaw400'])\n", - " cl1, cl2 = get_from_database('x1', 'x0', mat, inquiry_keys = [''], silent = True)\n", - " calc_redox(cl1, cl2)\n" + "import sys\n", + "sys.path.extend(['/home/aksenov/Simulation_wrapper/siman', '/home/aksenov/Simulation_wrapper/SSHTools'])\n", + "sys.path.extend(['C:/programms/siman-0.2', 'C:/programms/SSHTools']) #path to siman package and SSHtools\n", + "from analysis import calc_redox\n", + "from database import get_from_database\n", + "from SSHTools import SSHTools" ], "language": "python", "metadata": {}, - "outputs": [] + "outputs": [], + "prompt_number": 9 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###3. Initialize ssh:\n", + "The database server address is '10.30.100.28'. Use your account data and private rsa key (created earlier and added to server)" + ] }, { "cell_type": "code", "collapsed": false, "input": [ - "import sys\n", - "sys.path.append('/home/aksenov/Simulation_wrapper') #path to siman package\n", - "sys.path.append('/home/aksenov/Simulation_wrapper/siman') #path to siman package\n", - "sys.path.append('/home/aksenov/Simulation_wrapper/SSHTools') #path to ssh tools\n", - "from siman.analysis import calc_redox\n", - "from siman.database import get_from_database\n", - "from SSHTools import SSHTools\n", - "\n", "ssh = SSHTools()\n", - "\n", "# ssh.setup(user=\"Andriy.Zhugayevych\",host=\"cluster.skoltech.ru\",pkey=\"C:/Users/azh/Sys/Internet/SSH/skoltech/key2.ppk\")\n", - "\n", - "ssh.setup(user=\"aksenov\",host=\"10.30.100.28\",pkey=\"/home/aksenov/.ssh/id_rsa\")\n", - "\n", - "cl1, cl2 = get_from_database('x1', 'x0', 'LiFePO4', inquiry_keys = ['UGGA'], ssh_object = ssh)\n", - "calc_redox(cl1, cl2)\n" + "ssh.setup(user=\"aksenov\",host=\"10.30.100.28\",pkey=\"/home/aksenov/.ssh/id_rsa\")" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###4. Access to database\n", + "The first two arguments are concentrations. The second argument is material. \n", + "To clarify the inquiry use *inquiry_keys*. To switch off messages use *silent = 1*" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "cl1, cl2 = get_from_database('x1', 'x0', 'LiTiS2', ssh_object = ssh)\n", + "calc_redox(cl1, cl2)" ], "language": "python", "metadata": {}, @@ -51,69 +86,180 @@ "text": [ "\n", "Files for x1 :\n", - "1 LiFePO4/bin/x1_UGGA-Upaw400.pickle\n", - "2 LiFePO4/bin/x1s_UGGA-Upaw400.pickle\n", - "3 LiFePO4/bin/x1_UGGA-Upaw400_111.pickle\n", - "4 LiFePO4/bin/x1_UGGA-Upaw400_122.pickle\n", - "5 LiFePO4/bin/x1_UGGA-Upaw400_122s.pickle\n", - "6 LiFePO4/bin/x1_UGGA-Upaw400_122m.pickle\n", - "7 LiFePO4/bin/x1_UGGA-Upaw400_111m.pickle\n", - "8 LiFePO4/bin/x1_UGGA-Upaw400_111s.pickle\n", - "9 LiFePO4/em/bin/x1_UGGA-Upaw400_vs5.pickle\n", - "10 LiFePO4/em/bin/x1_UGGA-Upaw400_vs3.pickle\n", - "11 LiFePO4/em/bin/x1_UGGA-Upaw400_vs1.pickle\n", - "12 LiFePO4/em/bin/x1_UGGA-Upaw400_vs2.pickle\n", - "13 LiFePO4/em/bin/x1_UGGA-Upaw400_vs4.pickle\n", - "14 LiFePO4/em/bin/x1_UGGA-Upaw400_cg4.pickle\n", - "15 LiFePO4/em/bin/x1s_UGGA-Upaw400_cg2.pickle\n", - "16 LiFePO4/em/bin/x1_UGGA-Upaw400_111s_cg2.pickle\n", - "17 LiFePO4/em/bin/x1_UGGA-Upaw400_122s_cg2.pickle\n", - "18 LiFePO4/em/bin/x1_UGGA-Upaw400_111m_cg2.pickle\n", - "19 LiFePO4/em/bin/x1_UGGA-Upaw400_122m_cg2.pickle\n", - "20 LiFePO4/bin/x1_UGGA-Upaw400_UHSE06paw400.pickle\n", - "21 LiFePO4/bin/x1_UGGA-Upaw400_UGGA-Upaw600.pickle\n", + "1 LiTiS2/bin/x1_PBEpaw400.pickle\n", + "2 LiTiS2/bin/x1_UGGA-Upaw400.pickle\n", + "3 LiTiS2/em/bin/x1_PBEpaw400_cg4.pickle\n", + "4 LiTiS2/em/bin/x1_PBEpaw400_vs3.pickle\n", + "5 LiTiS2/em/bin/x1_PBEpaw400_vs5.pickle\n", + "6 LiTiS2/em/bin/x1_PBEpaw400_vs1.pickle\n", + "7 LiTiS2/em/bin/x1_PBEpaw400_vs2.pickle\n", + "8 LiTiS2/em/bin/x1_PBEpaw400_vs4.pickle\n", + "9 LiTiS2/em/bin/x1_UGGA-Upaw400_cg4.pickle\n", + "10 LiTiS2/em/bin/x1_UGGA-Upaw400_vs1.pickle\n", + "11 LiTiS2/em/bin/x1_UGGA-Upaw400_vs5.pickle\n", + "12 LiTiS2/em/bin/x1_UGGA-Upaw400_vs2.pickle\n", + "13 LiTiS2/em/bin/x1_UGGA-Upaw400_vs6.pickle\n", + "14 LiTiS2/em/bin/x1_UGGA-Upaw400_vs7.pickle\n", + "15 LiTiS2/em/bin/x1_UGGA-Upaw400_vs3.pickle\n", + "16 LiTiS2/em/bin/x1_UGGA-Upaw400_vs4.pickle\n", + "17 LiTiS2/aks/bin/x1_UPBE-Upaw400_s10_su_4uis_100.pickle\n", "\n", "Files for x0 :\n", - "1 LiFePO4/bin/x0_UGGA-Upaw400.pickle\n", - "2 LiFePO4/bin/x0_UGGA-Upaw400_122.pickle\n", - "3 LiFePO4/bin/x0_UGGA-Upaw400_234.pickle\n", - "4 LiFePO4/bin/x0_UGGA-Upaw400_111.pickle\n", - "5 LiFePO4/bin/x0_UGGA-Upaw400_122m.pickle\n", - "6 LiFePO4/bin/x0_UGGA-Upaw400_111s.pickle\n", - "7 LiFePO4/bin/x0_UGGA-Upaw400_111m.pickle\n", - "8 LiFePO4/bin/x0_UGGA-Upaw400_122s.pickle\n", - "9 LiFePO4/em/bin/x0_UGGA-Upaw400_vs4.pickle\n", - "10 LiFePO4/em/bin/x0_UGGA-Upaw400_cg4.pickle\n", - "11 LiFePO4/em/bin/x0_UGGA-Upaw400_vs3.pickle\n", - "12 LiFePO4/em/bin/x0_UGGA-Upaw400_vs2.pickle\n", - "13 LiFePO4/em/bin/x0_UGGA-Upaw400_vs6.pickle\n", - "14 LiFePO4/em/bin/x0_UGGA-Upaw400_vs1.pickle\n", - "15 LiFePO4/em/bin/x0_UGGA-Upaw400_vs5.pickle\n", - "16 LiFePO4/bin/x0_UGGA-Upaw400_122s_mchg.pickle\n", - "17 LiFePO4/em/bin/x0_UGGA-Upaw400_111m_cg2.pickle\n", - "18 LiFePO4/em/bin/x0_UGGA-Upaw400_122s_cg2.pickle\n", - "19 LiFePO4/em/bin/x0_UGGA-Upaw400_111s_cg2.pickle\n", - "20 LiFePO4/em/bin/x0_UGGA-Upaw400_122m_cg2.pickle\n", - "21 LiFePO4/bin/x0_UGGA-Upaw400_UGGA-Upaw600.pickle\n", - "22 LiFePO4/em/bin/x0_UGGA-Upaw400_234m_cg2gp.pickle\n", - "23 LiFePO4/em/bin/x0_UGGA-Upaw400_234s_cg2gp.pickle\n", + "1 LiTiS2/bin/x0_PBEpaw400.pickle\n", + "2 LiTiS2/em/bin/x0_PBEpaw400_vs1.pickle\n", + "3 LiTiS2/em/bin/x0_PBEpaw400_vs9.pickle\n", + "4 LiTiS2/em/bin/x0_PBEpaw400_vs3.pickle\n", + "5 LiTiS2/em/bin/x0_PBEpaw400_vs8.pickle\n", + "6 LiTiS2/em/bin/x0_PBEpaw400_vs2.pickle\n", + "7 LiTiS2/em/bin/x0_PBEpaw400_vs7.pickle\n", + "8 LiTiS2/em/bin/x0_PBEpaw400_vs4.pickle\n", + "9 LiTiS2/em/bin/x0_PBEpaw400_vs6.pickle\n", + "10 LiTiS2/em/bin/x0_PBEpaw400_vs5.pickle\n", + "11 LiTiS2/aks/bin/x0_UPBE-Upaw400_id_su_s10_su_4uis_100.pickle\n", + "\n", + "I choose first entries for both concentrations: LiTiS2/bin/x1_PBEpaw400.pickle and LiTiS2/bin/x0_PBEpaw400.pickle \n", "\n", - "I choose first entries for both concentrations: LiFePO4/bin/x1_UGGA-Upaw400.pickle and LiFePO4/bin/x0_UGGA-Upaw400.pickle \n", + " Directory /tmp/LiTiS2/bin was created\n", + " \n", "\n", - "-- LiFePO4 | 3.51 eV | 4.3 % \n", + "-- LiTiS2 | 1.91 eV | -2.7 % \n", "\n" ] }, { "metadata": {}, "output_type": "pyout", - "prompt_number": 15, + "prompt_number": 7, "text": [ "{}" ] } ], - "prompt_number": 15 + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#clarifying with 'UGGA' and 'vs2' tags\n", + "cl1, cl2 = get_from_database('x1', 'x0', 'LiTiS2', inquiry_keys = ['PBEpaw400', 'vs2'], ssh_object = ssh)\n", + "calc_redox(cl1, cl2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Files for x1 :\n", + "1 LiTiS2/em/bin/x1_PBEpaw400_vs2.pickle\n", + "\n", + "Files for x0 :\n", + "1 LiTiS2/em/bin/x0_PBEpaw400_vs2.pickle\n", + "\n", + "I choose first entries for both concentrations: LiTiS2/em/bin/x1_PBEpaw400_vs2.pickle and LiTiS2/em/bin/x0_PBEpaw400_vs2.pickle \n", + "\n", + "-- LiTiS2 | 1.91 eV | 3.6 % \n" + ] + }, + { + "metadata": {}, + "output_type": "pyout", + "prompt_number": 4, + "text": [ + "{}" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "for mat in ['LiCoO2', 'LiMn2O4', 'LiFePO4', 'NaFePO4', 'NaMnAsO4', 'LiVPO4F',\n", + " 'KVPO4F', 'Na2FePO4F', 'KFeSO4F', 'LiVP2O7', 'Na2FeVF7']:\n", + " cl1, cl2 = get_from_database('x1', 'x0', mat, inquiry_keys = ['UGGA'], silent = 1, ssh_object = ssh)\n", + " calc_redox(cl1, cl2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- LiCoO2 | 3.93 eV | -0.1 % \n", + "-- LiMn2O4 | 3.63 eV | 5.7 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- LiFePO4 | 3.51 eV | 4.3 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- NaFePO4 | 3.09 eV | 12.5 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- NaMnAsO4 | 3.53 eV | 13.9 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- LiVPO4F | 3.93 eV | 7.3 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- KVPO4F | 4.03 eV | 8.7 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- Na2FePO4F | 4.11 eV | 3.9 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- KFeSO4F | 3.79 eV | 10.5 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- LiVP2O7 | 3.93 eV | 3.5 % \n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "-- Na2FeVF7 | 4.22 eV | 7.6 % \n" + ] + } + ], + "prompt_number": 8 } ], "metadata": {}