Exemplo n.º 1
0
 def compute(self, nlist, positions, box, sample_weight):
     # get r
     r = htf.safe_norm(tensor=nlist[:, :, :3], axis=2)
     p_energy = self.lj(r)
     energy = tf.reduce_sum(input_tensor=p_energy, axis=1)
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 2
0
 def mol_compute(self, nlist, positions, mol_nlist, mol_positions, box):
     # assume particle (w) is 0
     r = tf.norm(mol_nlist, axis=3)
     rinv = tf.math.divide_no_nan(1.0, r)
     mol_p_energy = 4.0 / 2.0 * (rinv**12 - rinv**6)
     total_e = tf.reduce_sum(input_tensor=mol_p_energy)
     forces = htf.compute_nlist_forces(nlist, total_e)
     return forces
Exemplo n.º 3
0
 def compute(self, nlist, positions, box, sample_weight):
     # get r
     rinv = htf.nlist_rinv(nlist)
     inv_r6 = rinv**6
     # pairwise energy. Double count -> divide by 2
     p_energy = 4.0 / 2.0 * (inv_r6 * inv_r6 - inv_r6)
     # sum over pairwise energy
     energy = tf.reduce_sum(input_tensor=p_energy, axis=1)
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 4
0
 def compute(self, nlist, positions, box, sample_weight):
     # get r
     r = tf.norm(tensor=nlist[:, :, :3], axis=2)
     # compute 1 / r while safely treating r = 0.
     # pairwise energy. Double count -> divide by 2
     inv_r6 = tf.math.divide_no_nan(1., r**6)
     p_energy = 4.0 / 2.0 * (inv_r6 * inv_r6 - inv_r6)
     # sum over pairwise energy
     energy = tf.reduce_sum(input_tensor=p_energy, axis=1)
     tf.print(energy)
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 5
0
 def compute(self, nlist, positions, box, sample_weight):
     rinv = htf.nlist_rinv(nlist)
     # closest neighbors have largest value in 1/r, take top
     top_n = tf.sort(rinv, axis=1, direction='DESCENDING')[
         :, :self.top_neighs]
     # run through NN
     # make sure shape is definite
     top_n = tf.reshape(top_n, (-1, self.top_neighs))
     x = self.dense1(top_n)
     x = self.dense2(x)
     energy = self.last(x)
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 6
0
 def compute(self, nlist, positions, box, sample_weight):
     # get r
     r = tf.norm(tensor=nlist[:, :, :3], axis=2)
     # compute 1 / r while safely treating r = 0.
     # pairwise energy. Double count -> divide by 2
     inv_r6 = tf.math.divide_no_nan(1., r**6)
     p_energy = 4.0 / 2.0 * (inv_r6 * inv_r6 - inv_r6)
     # get rdf
     rdf, rs = htf.compute_rdf(nlist, [3, 5], positions[:, 3])
     # also compute without types
     _, _ = htf.compute_rdf(nlist, [3, 5])
     # compute running mean
     self.avg_rdf.update_state(rdf, sample_weight=sample_weight)
     forces = htf.compute_nlist_forces(nlist, p_energy)
     return forces
Exemplo n.º 7
0
    def compute(self, nlist, positions, training):
        rinv = htf.nlist_rinv(nlist)
        # closest neighbors have largest value in 1/r, take top
        top_n = tf.sort(rinv, axis=1, direction='DESCENDING')[
            :, :self.top_neighs]
        # run through NN
        x = self.dense1(top_n)
        x = self.dense2(x)
        energy = self.last(x)
        if training:
            energy *= 2

        forces = htf.compute_nlist_forces(nlist, energy)
        if self.output_zero:
            energy *= 0.
        return forces, tf.reduce_sum(energy)
Exemplo n.º 8
0
 def compute(self, nlist):
     rinv = htf.nlist_rinv(nlist)
     energy = rinv
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 9
0
 def compute(self, nlist):
     r = htf.safe_norm(nlist[:, :3], axis=2)
     rbf = self.rbf(r)
     energy = tf.reduce_sum(self.dense(rbf))
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces
Exemplo n.º 10
0
 def compute(self, nlist):
     energy = self.wca(nlist)
     forces = htf.compute_nlist_forces(nlist, energy)
     return forces