amd / openmm-hip

15 stars 7 forks source link

big energy expression leads to wrong energies with hip #17

Open gorgW opened 1 month ago

gorgW commented 1 month ago

I am trying to use CustomCompoundBondForce or CustomCV force and the output for this force doesn't make sense and it exceeds the max that it should reach when the number of interactions is big, however it works fine with small number of interactions.

`for i, pair in enumerate(atom_pairs1): index_p1_1 = merged_flat.index(pair[0]) +1 index_p1_2 = merged_flat.index(pair[1]) +1 energy_expression += f'( 0.5 {N1_normal} {weights_7[i]} (1 / (1 + exp(10(distance(p{index_p1_1},p{index_p1_2}) - 1.3 * {native_dist1[i]} )))))' if i != len(atom_pairs1) - 1: energy_expression += '+' energy_expression += '-'

for i, pair in enumerate(atom_pairs2):

for i, pair in enumerate(atom_pairs2):

index_p2_1 = merged_flat.index(pair[0]) +1 index_p2_2 = merged_flat.index(pair[1]) +1

energy_expression += f'( 0.5 {N2_normal} {weights_8[i]} (1 / (1 + exp(10(distance(p{index_p2_1},p{index_p2_2}) - 1.3 * {native_dist2[i]} )))))'

if i != len(atom_pairs2) - 1: energy_expression += '-' force = mm.CustomCompoundBondForce(num_particles_per_bond,energy_expression)

force.addBond(merged_flat) system.addForce(force)

`

or it can be used as collective variable in CV force but still same problem like that

cvforce = mm.CustomCVForce('(cv)')

cvforce.addCollectiveVariable("cv", force)

system.addForce(cvforce)`

the final energy expression is composed of many terms that are added ( or other terms that are subtracted ) of total ~ 1000 term and it is normalized so the final term shouldn't exceed 1 "or go less than -1 ". However, some runs give number that makes sense and other runs produce something of order 10^36 or -10^24 and other random numbers.

this happens when using hip platform, when I use cpu, it produces the expected results.

So, is there a way that this can be fixed ?

Thanks.