materialsproject / emmet

Be a master builder of databases of material properties. Avoid the Kragle.
https://materialsproject.github.io/emmet/
Other
53 stars 65 forks source link

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

Open dwinston opened 5 years ago

dwinston commented 5 years ago

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 commented 5 years ago

I think this is good information to report. We may want to modify this however so that we report reciprocal density rather than absolute number of k-points, since absolute number is only meaningful if you know both the size of the cell and also the symmetry. It’d be a bit more complex however since this won’t come from an aggregation, though we could build this information into the drone at the analysis step in future.

On Tue, Mar 26, 2019 at 09:44, Donny Winston notifications@github.com wrote:

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: image] https://user-images.githubusercontent.com/1497854/55015038-57a4db80-4fa9-11e9-82e6-6590bfa93b18.png

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}

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/materialsproject/emmet/issues/83, or mute the thread https://github.com/notifications/unsubscribe-auth/AC1rRGeb_M1zvqBwd-pul5GoqYQ20z_1ks5vak1jgaJpZM4cL7H5 .