Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set nkpts field in materials.mp_website.MPBuilder.website store #83

Open
dwinston opened this issue Mar 26, 2019 · 1 comment
Open

Set nkpts field in materials.mp_website.MPBuilder.website store #83

dwinston opened this issue Mar 26, 2019 · 1 comment

Comments

@dwinston
Copy link
Member

dwinston commented Mar 26, 2019

I patched the production collection to include an nkpts field in each document, which is expected for the "# of K-points" cell of the "Structure Optimization" subsection of the "Calculation Summary" section on a material detail page (see screenshot below).

image

My procedure for the patch is shown below to indicate how I derived nkpts from currently-built fields.

docs = list(db.materials.find({}, ["task_id", "blessed_tasks"]))
for d in docs:
    d["opt_id"] = d["blessed_tasks"][next(k for k in d["blessed_tasks"]
                                          if "Optimization" in k)]
rv = list(db.tasks.aggregate([
    {"$match": {"task_id": {"$in": [d["opt_id"] for d in docs]}}},
    {"$project": {
        "task_id": 1,
        "firstcalc_kpts": {
            "$arrayElemAt": [
                "$calcs_reversed.input.kpoints",
                -1]
        }
    }},
    {"$project": {
        "task_id": 1,
        "nkpts": {"$size": "$firstcalc_kpts.actual_points"}}},
]))
rv_map = {d["task_id"]: d["nkpts"] for d in rv}

from pymongo import UpdateOne
requests = []
for d in docs:
    requests.append(UpdateOne(
        {"task_ids": d["opt_id"]},
        {"$set": {"nkpts": rv_map[d["opt_id"]]}}
    ))
db_rw.materials.bulk_write(requests, ordered=False)
@mkhorton
Copy link
Member

mkhorton commented Mar 26, 2019 via email

utf referenced this issue in utf/emmet May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants