[DNM] add espaloma converter ... - #164
Draft
lilyminium wants to merge 3 commits into
Draft
lilyminium wants to merge 3 commits into
lilyminium wants to merge 3 commits into
Conversation
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. |
lilyminium
commented
Aug 20, 2026
|
|
||
| # --- 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"] |
Contributor
Author
There was a problem hiding this comment.
just hardcoded this assumption that it's called epsilon and sigma
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.