Getting voltage graph information via MAPI

I am trying to construct voltage graphs from the data available at

from mp_api import MPRester
mpr = MPRester()

but among the available_fields there seems not to be any obvious way to do it, as the average voltage is the only voltage value that is reported for an electrode.
An idea would be to leverage the available intermediate material ids of every semicell, but I can’t see how to construct the graph without the intermediate voltage values.
Do you have any idea to get this done?

For reference:

['max_delta_volume', 'average_voltage', 'capacity_grav', 'capacity_vol', 'energy_grav', 'energy_vol', 
'fracA_charge', 'fracA_discharge', 'formula_charge', 'formula_discharge', 'stability_charge', 
'stability_discharge', 'id_charge', 'id_discharge', 'battery_id', 'battery_formula', 'framework_formula', 
'host_structure', 'adj_pairs', 'working_ion', 'num_steps', 'max_voltage_step', 'last_updated', 'framework', 
'elements', 'nelements', 'chemsys', 'material_ids', 'formula_anonymous', 'entries_composition_summary', 
'electrode_object', 'warnings']

Hi @acarnevali,

Have you tried looking into the voltage step data contained in adj_pairs and the voltage_pairs attribute of the electrode_object?

– Jason

Hi Jason!
I am not sure what you mean by voltage step data in adj_pairs: getting the data the following way

import requests
import pymatgen.core as mg 
from mp_api import MPRester
mpr = MPRester()

with MPRester(api_key = key) as mpr:
    docs = mpr.insertion_electrodes.search_electrode_docs()
    docs_list = [i for i in docs]
    adj_pairs= [i.adj_pairs for i in docs_list]

it seems that I get an adj_pairs entry for each electrode object, which consists of:

[InsertionVoltagePairDoc(max_delta_volume=0.05798067526371464, average_voltage=4.321407745000005, capacity_grav=157.5225282330018, capacity_vol=359.33106169150375, energy_grav=680.7190735180758, energy_vol=1552.8160330127387, fracA_charge=0.0, fracA_discharge=0.1, formula_charge='Co(GeO3)2', formula_discharge='CaCo(GeO3)2', stability_charge=0.16777887759259702, stability_discharge=0.0, id_charge=MPID(mp-1043245), id_discharge=MPID(mp-1043203))]

not presenting any information about voltage steps :confused: .
About voltage_pairs, I can’t see it among the available fields for insertion_electrodes. Maybe I am looking in the wrong place?

Ideally, what I am looking for is a simple {x in Lix(material): V} having one entry for each voltage step. I am sure that info like this exists, as it is needed to display the V vs Q plots present on the MP website.

Hi @acarnevali,

voltage_pairs is an attribute of the electrode_object which is a field you can ask for in the new API. You can check out the VoltageProfilePlotter (pymatgen.apps.battery.plotter module — pymatgen 2022.3.24 documentation) class which we use to generate those types plots on the new website. It takes in an electrode object and uses the voltage_pairs attribute.

– Jason

1 Like

Hi Jason!
thank you for you time.
Since voltage_pairs is an attribute of the electrode_object, I am trying to fetch it like this:

with MPRester(api_key=key) as mpr: 
    docs = mpr.insertion_electrodes.search_electrode_docs()
    docs_list = [i for i in docs]
    #formula_charge = [i.formula_charge for i in docs_list]
    #formula_discharge = [i.formula_discharge for i in docs_list]
    v_pairs = [i.voltage_pairs for i in docs_list]

but I am prompted AttributeError: 'InsertionElectrodeDoc' object has no attribute 'voltage_pairs'. I am on mp-api 0.21.2.
Uncommenting the two formula lines, though, allows me to fetch the formulas, which if I understand well are attributes of the electrode object as well.

Am I doing something wrong?

No problem, if you change the last line to _pairs = [i.electrode_object.voltage_pairs for i in docs_list], it should get you what you need.

– Jason