lanl / hippynn

python library for atomistic machine learning
https://lanl.github.io/hippynn/
Other
59 stars 22 forks source link

mliap interface works with hipnn-coulomb architecture #38

Closed sakibmatin closed 11 months ago

sakibmatin commented 11 months ago

The mliap interface uses per-atom energies. The CombineEnergy node (PR contribution) now allows the addition of per-atom energies from two nodes, e.g. HEnergy with CoulombEnergy or ScreenedCoulombEnergy

Updated sketch of how to utilize this code when building hipnn models :

# Screened Coulomb Energy using predicted charges
  coulomb_energy = physics.ScreenedCoulombEnergyNode(
      "coulomb_Energy",
      (atom_charges,
          pairfinder.pair_dist, pairfinder.pair_first, pairfinder.pair_second,
          padidxer.mol_index, padidxer.n_molecules),
      energy_conversion=energy_conv, 
      screening=combined_screening, 
      cutoff_distance=coulomb_r_max
  )

# Short range Energy contribution
Henergy = targets.HEnergyNode("HEnergy", network_energy) 

# Combined Energy
sys_energy = physics.CombineEnergyNode("sysEnergy", 
    (Henergy, coulomb_energy),  # Padding Indexer is automatically extracted from connected graph. 
    db_name="energy"
)

Then the sys_energy is energy node when constructing calculators for ASE or Lammps.

lubbersnick commented 11 months ago

Please do not worry about the job failures for the moment, they are a reflection of the fact that I do not yet know how to put the settings properly.

sakibmatin commented 11 months ago

I believe that this PR is ready to be merged.

lubbersnick commented 11 months ago

Made some parent expansion changes to the node building. If this doesn't work right let me know. It should now work to make the coulomb node with only the charge as parents, e.g.

coul = CoulombEnergyNode("coulomb energy",hcharge,energy_conversion=1)

Before there was a bug so this form of construction couldn't work.

sakibmatin commented 11 months ago

Your commits works with the physics.CombineEnergyNode. I've also tested that the screened coulomb energy node can be constructed from just the charge node.

 screen_coul = physics.ScreenedCoulombEnergy(
     "screened coulomb energy",
     (hcharge), 
     energy_conversion=1,
     screening=screening,
     cutoff_distance=coulomb_cutoff
 )

I believe, that this PR can be merged.