Primary and Secondary Calculation

Hello everyone,

I wanted to retrieve some information about basic calculations of materials.
Since energies are calculated with different mixing schemes (Energy Corrections | Materials Project Documentation) I wanted to retrieve the base calculation data.

On the website the calculations are flagged as either “Primary Calculation”, “Secondary Calculation” or “Deprecated Calculation”.

My question would be, how are these flags set?
I haven’t found hints from the TaskDoc if there is already a flag that marks the tasks as either of the above mentioned options.

I am grateful for every hint!
Thank you

Thanks for reaching out! If you hover over the tabs below the title, a tooltip with help pops up. Is that what you’re looking for?

@tschaume Thank you for your response.
Sadly no. What I actually wanted is e.g. a tag in the API retrieved TaskDoc that states, that this task is a primary calculation or secondary calculation, for exactly the reason you have pointed out: To know which calculation with which parameters was performed to generate the canonical energy reported in MP for the respective material.

This actually would be some interdisciplinary topic between the Website and the API but I thought it to be more reasonable to put it in here.

Since the task collection is parsed directly from raw calculation directories, it is not retroactively updated with information about its role in a resulting material. That role can change when new data releases come out. Here’s an (untested) example code snippet for how the website retrieves that information through the MaterialsRester for a single material:

data = mpr.materials.search(
    material_ids="<mpid>",  
    fields=["task_id", "calc_types", "origins", "deprecated_tasks"]
)[0]

tasks_in_origins = {d.task_id for d in data.origins}
deprecated_tasks = data.deprecated_tasks

def get_task_kind(task_id):
    if task_id in tasks_in_origins:
        return "primary"
    elif task_id in deprecated_tasks:
        return "deprecated"
    else:
        return "secondary"

for task_id, calc_type in data.calc_types.items():
    task_kind = get_task_kind(task_id)
    print(task_id, calc_type, task_kind)

Please note that retrieving materials/tasks one-by-one is inefficient and the above code should be updated to follow our recommendations at Tips for Large Downloads | Materials Project Documentation (i.e. #4). HTH.

1 Like

This is exactly what I was looking for!
Thank you so much for your help.