Skip to content

[DNM] add espaloma converter ... - #164

Draft
lilyminium wants to merge 3 commits into
mainfrom
add-convert-espaloma
Draft

lilyminium wants to merge 3 commits into
mainfrom
add-convert-espaloma

Conversation

@lilyminium

@lilyminium lilyminium commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

Is this suitable for mapping the espaloma experiments to smee/descent/dimsim ...?

Just prototyping code, wouldn't suggest merging this while espaloma is under heavy development.

This basically works by assigning each bond/angle/... its own unique types. It assumes that torsions have 4 cosines but you can set that.

@lilyminium

lilyminium commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

For python formatting/highlighting, could look like below:

dhmix_property = DataEntry(type="hmix", smiles_a="CCO", smiles_b="O", x_a=0.5, x_b=0.5, ...) # mapped smiles
thermo_dataset = descent.targets.thermo.create_dataset(dhmix_property, ...)
mapped_smiles = descent.targets.thermo.extract_smiles(thermo_dataset)
graphs = ... # convert to Graph

for epoch in range(n_epochs):
    for gas_batch in gas_dataloader:
        # gas-phase stuff ...
        # you could potentially throw to smee here if you can include nonbonded energies
        # just going to assume iterating over gas_batches yields graphs
        predicted_params = [model(graph) for graph in gas_batch]

        ff, topos = convert_espaloma(list(gas_batch), predicted_params, charges=...) # could pre-compute charges by predicting with espaloma or just look up NAGL charges

        # could either compute energy the current way or potentially use smee
        for topo, params, graph in zip(topos, predicted_params, gas_batch):
            coords  = graph.pos #?units?
            E_pred = smee.compute_energy(topo, ff, coords)
            F_pred = -torch.autograd.grad(E_pred.sum(), coords, create_graph=True)[0]
        loss_gas = ...

    if not epoch % 100: # probably too slow to run every epoch        
        params = [model(graph) for graph in graphs]
        charges = ... # predict or cache
        ff_thermo, topos = convert_espaloma(graphs, params, charges=charges)
        topologies_dict = dict(zip(mapped_smiles, topos))
    
        # note the descent predict() function actually runs simulations
        # or reads them from a cached directory, either way
        # the defaults in descent are not very good, 256 mol boxes and very short equilibration/production times.
        # this is where dimsim has the most value in replacing and abstracting compute!
        y_ref, _, y_pred, _ = descent.targets.thermo.predict(
            thermo_dataset, ff_thermo, topologies_dict, output_dir, cached_dir
        )
        loss_thermo = ...

but this is super untested obviously.


# --- determine which nonbonded terms to include ---
include_vdw = any(
p.get("atom") is not None and "epsilon" in p["atom"] and "sigma" in p["atom"]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just hardcoded this assumption that it's called epsilon and sigma

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant