cmelab / cmeutils

Useful functions by and for the CME lab
GNU General Public License v3.0
3 stars 11 forks source link

Add frame_to_CG_freud system #83

Open marjanalbooyeh opened 6 months ago

marjanalbooyeh commented 6 months ago

Add a function to cmeutils that takes in a gsd snapshot of an atomistic system and the CG mapping (obtained from grits), and it creates a freud system based on the CG beads. The resulting freud system is used in cmeutils functions that calculate structural properties such as rdf, order parameter, MSD, etc.

This function needs to calculate COM positions for the snapshot based on the mapping. We already have a similar function called [frame_to_freud_system](https://github.com/cmelab/cmeutils/blob/master/cmeutils/gsd_utils.py#L13).

The benefit of having a function like that is that we can skip coarse graining the whole trajectory with grits and go straight to calculating our desired properties from the aa trajectories. Another benefit of this function is that it allows us to try on different mappings or smiles patterns for calculating properties.

chrisjonesBSU commented 6 months ago

The benefit of having a function like that is that we can skip coarse graining the whole trajectory with grits and go straight to calculating our desired properties from the aa trajectories. Another benefit of this function is that it allows us to try on different mappings or smiles patterns for calculating properties.

To add some examples for why this would be cool.

For a lot of structural analysis (RDFs, order parameters, structure factors, diffraction patterns) and dynamic analysis (MSD) we may want the measurements done on a coarse-grained representation of the system. Right now, like Marjan mentioned, we have to create the entire CG trajectory then pass that into the function (e.g. calculating an RDF between monomer pairs).

Instead, we could assign the mapping/bead matching directly in the cmeutils API. For example:

# RDF of pair distribution between thiophene rings of P3HT monomers, obtained from an atomistic trajectory

rdf, N = gsd_rdf(
    gsd_file="p3ht-atomistic.gsd",
    beads={"A": "c1cscc1", "B": "CCC"},
    A_type="A",
    B_type="A",
    start=-20,
    stop=-1
) 

# RDF of pair distribution between rings and  tails of P3HT monomers, obtained from an atomistic trajectory

rdf, N = gsd_rdf(
    gsd_file="p3ht-atomistic.gsd",
    beads={"A": "c1cscc1", "B": "CCC"},
    A_type="A",
    B_type="B",
    start=-20,
    stop=-1
) 

# MSD of PPS monomers obtained from an atomistic trajectory
msd = gsd_msd(gsd_file="pps-atomistic.gsd", beads={"A": "c1cc(S)ccc1"}, start=-20, stop=-1)

After talking with Marjan, the thought process is 1) use GRiTS under the hood to get the coarse-grained mapping, then make a function that takes an atomistic trajectory + a CG mapping, and creates a freud system of the CG representation, all while not having to save an entire coarse-grained trajectory file.