Plotting a voltage curve from a folder of res files

This example will create a hull and plot a voltage curve from the computed phases found inside this directory.

[1]:
# temporarily disables numpy deprecation warnings for CI
import warnings
warnings.filterwarnings("ignore")
[2]:
from matador.hull import QueryConvexHull
from matador.scrapers.castep_scrapers import res2dict
%matplotlib inline
[3]:
cursor, failures = res2dict("LiP_structures/*.res")

hull = QueryConvexHull(
    cursor=cursor,
    species=['Li', 'P'],
    voltage=True,
    volume=True,
    labels=True,
    plot_kwargs={"labels": True}
)
Successfully scraped 6 out of 6 files.
6 structures found within 0.0 eV of the hull, including chemical potentials.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                Source                 !?!  Pressure  Cell volume      Hull dist.      Space group      Formula      # fu   Prov.
                                             (GPa)      (ų/fu)        (meV/atom)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
* P-CollCode150873                              0.01         21.2           0.0           Cmca             P          4      ICSD  
* LiP-ColCode23621                             -0.02        173.2           0.0          I41/acd         LiP7         8      ICSD  
* LiP-CollCode60774                             0.02        198.4           0.0          P212121         Li3P7        4      ICSD  
* LiP-CollCode182159                           -0.02         31.3           0.0           P21/c           LiP         8      ICSD  
* LiP-CollCode165990                           -0.02         58.4           0.0          P63/mmc         Li3P         4      ICSD  
* Li-bcc                                        0.01         20.3           0.0           Pm-3m           Li          16    AIRSS  

Constructing electrode system with active ion: Li

Voltage data:

# Li into P
# Average voltage: 0.96 V
# Q (mAh/g)     Voltage (V)
      0.00      1.51548488
    123.62      1.51548488
    370.87      1.19129313
    865.37      0.95356375
   2596.10      0.89592562
       nan      0.00000000

Volume data:

# Reaction 1
# P
#  Q (mAh/g)      Volume (A^3)  Volume ratio with bulk
      0.00               21.24            1.00
    123.62               24.75            1.16
    370.87               28.34            1.33
    865.37               31.29            1.47
   2596.10               58.37            2.75
../../_images/notebooks_interactive_voltage_from_res_files_4_1.png
../../_images/notebooks_interactive_voltage_from_res_files_4_2.png
../../_images/notebooks_interactive_voltage_from_res_files_4_3.png
[4]:
cursor, failures = res2dict("ternary_structures/*.res")

hull = QueryConvexHull(
    cursor=cursor,
    species="KSnP",
    voltage=True,
    capmap=True,
    hull_cutoff=0.05,
    volume=True,
    plot_kwargs={"labels": True}
)
Successfully scraped 87 out of 87 files.
87 structures found within 0.05 eV of the hull, including chemical potentials.
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
                Source                 !?!  Pressure  Cell volume      Hull dist.      Space group      Formula      # fu   Prov.
                                             (GPa)      (ų/fu)        (meV/atom)
───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
* K-Na-Collo                                    0.02         73.3           0.0           Im-3m            K          1     SWAPS  
  KSn-LiSn-87104-9995-390                      -0.05        573.0          47.5            R3            K8Sn         1     AIRSS
  KP-GA-oeaasw-2x57                            -0.00        971.6          41.8            P1            K13P         1       GA
  KP-GA-oeaasw-2x8                              0.01        869.0          27.6            P1            K12P         1       GA
  KP-GA-9479c6-10x26                           -0.00        804.2          31.9            P1            K11P         1       GA
  KP-GA-9479c6-11x21                            0.00        721.1          30.0            P1            K10P         1       GA
  KP-GA-9479c6-15x19                            0.07        632.2          37.3            P1             K9P         1       GA
  KP-GA-oeaasw-2x33                             0.06        532.6          45.1            P1             K8P         1       GA
  KSn-61h5se                                   -0.01        303.5          35.4            Pm            K4Sn         2     AIRSS
  KP-nt8rkc                                     0.01        498.1          35.2            Pm             K7P         2     AIRSS
  KSn-dsjbdt                                    0.04        510.3          37.4            P2            K7Sn2        1     AIRSS
  KP-GA-uynlzz-17x7                            -0.05        411.2          26.3            P1             K6P         2       GA
  KSn-zm0c2z                                    0.03        234.3          47.6            Pm            K3Sn         2     AIRSS
  KP-GA-9479c6-6x14                            -0.04       1077.5          29.1            P1            K16P3        1       GA
  KSn-qgfvw3                                   -0.05        367.6          38.1            Pm            K5Sn2        1     AIRSS
  KP-GA-uynlzz-13x12                            0.04        325.5          26.0            P1             K5P         2       GA
  KP-GA-9479c6-2x14                             0.00        845.8          30.9            P1            K13P3        1       GA
  KSn-NaSn-CollCode24146                        0.02        137.5          29.2           C2/m           K2Sn         2     SWAPS
  KP-GA-oeaasw-2x55                            -0.01        241.0          17.9            P1             K4P         2       GA
  SnK-Ge6Li11-OQMD_7671-CollCode[..]            0.03        720.9          49.2          P2_1/m         K11Sn6        2     SWAPS
  KSn-oi71y3                                   -0.00        573.4          39.6            Pm            K7Sn4        1     AIRSS
  KP-3ledp2                                     0.05        441.2          43.0           Pbam           K7P2         2     AIRSS
  SnK-Hg2Na3-OQMD_113254-CollCod[..]            0.01        202.7          38.9         P4_2/mnm         K3Sn2        4     SWAPS
  KP-GA-0ss21w-10x34                           -0.02        144.2           6.2            P1             K3P         6       GA
  KP-GA-58d37c-6x1                             -0.02        852.1          30.4            P1            K17P6        1       GA
  KSn-GA-djgski-1x48                           -0.06       1249.9          29.4            P1           K16Sn15       1       GA
* SnK-PbRb-OQMD_25009-CollCode409436            0.00         78.1           0.0         I4_1/acd          KSn         16    SWAPS  
  KP-GA-0ss21w-3x40                             0.05        613.5          39.7            Pm            K12P5        1       GA
  KSn-GA-djgski-2x9                             0.02        612.7          44.4            P1            K7Sn8        2       GA
  KPSn-GA-qcrtjd-2x45                           0.01        917.7          40.4            P1          K15Sn2P6       1       GA
  KPSn-GA-qcrtjd-1x26                          -0.01        192.0          46.4            P1            K3SnP        3       GA
  KPSn-GA-lanh4w-1x8                            0.04        894.5          21.1            P1          K16Sn2P7       1       GA
  KP-563yvp                                     0.01        105.8          41.5            Pm             K2P         3     AIRSS
  KPSn-GA-qcrtjd-2x90                           0.03        905.8          26.3            P1          K15Sn2P7       1       GA
  KSn-gjx9ke                                   -0.09        192.9          36.5          P-42_1m         K2Sn3        2     AIRSS
* PKSn-As4Na8Ti-OQMD_13161-CollC[..]            0.05        441.9           0.0           Fd-3m         K8SnP4        2     SWAPS  
  KPSn-GA-lanh4w-1x68                          -0.00        896.7          43.5            P1          K14Sn2P7       1       GA
  KPSn-jw54f0                                   0.03        370.2          38.3          P6_3mc         K6SnP3        2     AIRSS
  KPSn-GA-1vd8ye-10x13                         -0.03        880.5          36.0            P1          K15Sn2P8       1       GA
  KPSn-GA-lanh4w-1x24                           0.03       1116.5          21.7            P1          K20Sn4P11      1       GA
  KSn-fh4saz                                    0.01        109.1           4.7            Pm            KSn2         2     AIRSS
  KPSn-GA-bb6diz-3x69                           0.01       1106.0          33.9            P1          K19Sn4P11      1       GA
  PSnK-AsCuLi2-OQMD_8250-CollCod[..]            0.06        131.2          37.7           C2/m           K2SnP        2     SWAPS
  KSn-GA-djgski-1x28                            0.01       2007.5          18.0            P1           K16Sn35       1       GA
* KSn-GA-djgski-1x1                            -0.00        508.8           0.0            P-1           K4Sn9        4       GA   
  KPSn-Na5P3Sn-OQMD_645043-CollC[..]            0.06        278.7           0.9          P2_1/c         K5SnP3        4     SWAPS
  KSn-GA-djgski-1x32                            0.02        669.0          18.0            P1           K5Sn12        3       GA
  KP-GA-0ss21w-1x6                              0.02        879.8          37.1            P1           K16P11        1       GA
  KPSn-GA-1vd8ye-2x37                           0.03       1123.7          30.2            P1          K19Sn4P12      1       GA
  KSn-w7kh1d                                    0.05        229.4          48.4            P-1           K2Sn5        1     AIRSS
  KP-GA-oeaasw-1x78                            -0.01        215.3           1.9            P-1           K4P3         2       GA
  KPSn-k59adg                                   0.00        377.8          35.3            P1           K5Sn3P3       1     AIRSS
  KSn-vyba43                                    0.02        141.6          44.2           P4mm           KSn3         2     AIRSS
  KSn-NaSn-CollCode247416                       0.02       1207.6          48.1           P2/m          K8Sn25        1     SWAPS
* KP-NaP-CollCode56530                         -0.00        267.4           0.0           C2/m           K5P4         1     SWAPS  
  KSn-yw4pdz                                   -0.00        284.2          23.2            P1            K2Sn7        1     AIRSS
  KPSn-GA-1vd8ye-5x39                          -0.02        224.0          43.1            P1           K3Sn2P2       1       GA
  SnK-Hg11K3-OQMD_22903-CollCode[..]            0.03        444.2          48.7           Immm          K3Sn11        1     SWAPS
  SnK-Hg19Rb5-OQMD_18639-CollCod[..]            0.01        782.8          41.9            P-1          K5Sn19        1     SWAPS
  KSn-0qfc4j                                   -0.01        168.7          36.5            C2            KSn4         2     AIRSS
  KP-GA-0cpkk9-1x111                            0.03        455.1          39.3            P1            K8P7         1       GA
  KPSn-6xk4ia                                  -0.05        320.4          48.3          Cmc2_1         K4Sn3P3       2     AIRSS
  KP-GA-scno1g-2x41                            -0.02        914.8          28.0            P1           K16P15        1       GA
* KSn-NaSn-CollCode248167                       0.06        744.4           0.0           R-3m          K3Sn17        2     SWAPS  
  KSn-NaSn-CollCode28123                        0.03        996.8           5.4           Pm-3n         K4Sn23        2     SWAPS
  KSn-okzema                                   -0.01        252.0          38.9            Pm            KSn6         1     AIRSS
* KP-GA-scno1g-3x2                              0.05         57.4           0.0            P1             KP          8       GA   
  KPSn-GA-qcrtjd-1x19                          -0.03        160.9          21.7            P-1          K2SnP2        2       GA
  KP-GA-scno1g-2x42                             0.07        884.8          24.2            P1           K15P16        1       GA
* KPSn-KSbSn-OQMD_6395-CollCode33933            0.07         90.4           0.0          P6_3mc          KSnP         2     SWAPS  
  KP-GA-scno1g-2x26                            -0.01        428.4          41.7            P1            K7P8         1       GA
  KSn-NaSn-CollCode248189                       0.00        713.3          17.6           R-3m           KSn17        2     SWAPS
  KPSn-GA-bb6diz-2x74                           0.06        537.2          43.3            Cm           K5Sn6P6       1       GA
  KP-GA-0ss21w-15x38                            0.08        289.3          17.4            P1            K4P5         2       GA
* Sn-CollCode40039                              0.02         36.4           0.0           Fd-3m           Sn          2      ICSD  
* KP-GA-0ss21w-17x39                            0.01        147.8           0.0            P1            K2P3         4       GA   
* PKSn-As2NaSn2-OQMD_14824-CollC[..]            0.04        134.2           0.0           R-3m          KSn2P2        1     SWAPS  
  KP-GA-0ss21w-17x13                           -0.05        575.7          33.5            P1            K7P12        1       GA
  KP-chpvm6                                     0.05         94.1          44.6           P2_1            KP2         2     AIRSS
* KP-Cs3P7-OQMD_57401-CollCode62259            -0.00        294.8           0.0           P4_1           K3P7         4     SWAPS  
* P3Sn4-CollCode15014                          -0.00        165.1           0.0           R-3m           Sn4P3        3      ICSD  
  PSn-AsGe-OQMD_3671-CollCode17033             -0.00         45.2          13.1           I4mm            SnP         1     SWAPS
  KP-NaP5-OQMD_16845-CollCode99177              0.01        143.0          49.6           Pnma            KP5         4     SWAPS
  PSn-As2Si-OQMD_4706-CollCode24801            -0.02         64.6          16.7            Pa3           SnP2         4     SWAPS
* KP-LiP-ColCode23621                           0.01        229.8           0.0         I4_1/acd          KP7         8     SWAPS  
* P3Sn-OQMD_3387-CollCode16293                  0.06         85.4           0.0           R-3m           SnP3         2      ICSD  
* P-CollCode150873                             -0.01         21.2           0.0           Cmce             P          4      ICSD  

Constructing electrode system with active ion: K
2 starting point(s) found.
SnP3 Sn4P3

------------------------------
Reaction 1, SnP3:
SnP3 ---> 0.25 Sn4P3 + 0.321 KP7 ---> 0.25 Sn4P3 + 0.321 K3P7 ---> 0.429 K3P7 + Sn ---> 0.5 KSn2P2 + 0.286 K3P7 ---> 0.286 K3P7 + KSnP ---> KSnP + 0.667 K2P3 ---> KSn + K2P3 ---> 3.0 KP + KSn ---> 0.75 K5P4 + KSn ---> 0.75 K8SnP4 + 0.25 KSn
------------------------------
Reaction 2, Sn4P3:
Sn4P3 ---> 0.429 K3P7 + 4.0 Sn ---> 1.5 KSn2P2 + Sn ---> 3.0 KSnP + Sn ---> 0.059 K3Sn17 + 3.0 KSnP ---> 0.111 K4Sn9 + 3.0 KSnP ---> 3.0 KSnP + KSn ---> 4.0 KSn + K2P3 ---> 3.0 KP + 4.0 KSn ---> 0.75 K5P4 + 4.0 KSn ---> 0.75 K8SnP4 + 3.25 KSn

Voltage data:

# K into SnP3
# Average voltage: 0.54 V
# Q (mAh/g)     Voltage (V)
      0.00      1.56802407
     40.71      1.56802407
    122.13      1.24812250
    162.84      1.11280248
    171.89      0.88411300
    235.21      0.86120500
    295.52      0.65211200
    379.96      0.34951250
    506.61      0.31951625
    601.60      0.25383000
    791.58      0.10594250
       nan      0.00000000

Voltage data:

# K into Sn4P3
# Average voltage: 0.52 V
# Q (mAh/g)     Voltage (V)
      0.00      1.11280248
     60.70      1.11280248
     70.81      0.88411300
    141.63      0.86120500
    149.96      0.85902800
    162.61      0.60875939
    188.84      0.46219000
    283.26      0.34951250
    330.47      0.31951625
    365.87      0.25383000
    436.69      0.10594250
       nan      0.00000000

Volume data:

# Reaction 1
# SnP3
#  Q (mAh/g)      Volume (A^3)  Volume ratio with bulk
      0.00               85.43            1.00
     40.71              115.13            1.35
    122.13              136.05            1.59
    162.84              162.75            1.90
    171.89              151.36            1.77
    235.21              174.68            2.04
    295.52              188.94            2.21
    379.96              225.84            2.64
    506.61              250.38            2.93
    601.60              278.65            3.26
    791.58              350.94            4.11

Volume data:

# Reaction 2
# Sn4P3
#  Q (mAh/g)      Volume (A^3)  Volume ratio with bulk
      0.00              165.13            1.00
     60.70              271.93            1.65
     70.81              237.76            1.44
    141.63              307.71            1.86
    149.96              315.10            1.91
    162.61              327.85            1.99
    188.84              349.40            2.12
    283.26              460.08            2.79
    330.47              484.62            2.93
    365.87              512.90            3.11
    436.69              585.18            3.54
Plotting ternary hull...
Showing plot...
../../_images/notebooks_interactive_voltage_from_res_files_5_1.png
../../_images/notebooks_interactive_voltage_from_res_files_5_2.png
../../_images/notebooks_interactive_voltage_from_res_files_5_3.png