Skip to content
Snippets Groups Projects
Commit 71c96de5 authored by Ivan Kondov's avatar Ivan Kondov
Browse files

replaced subs() with xreplace() for more speed

parent ab7fb70c
No related branches found
No related tags found
No related merge requests found
Pipeline #158447 failed
......@@ -184,11 +184,11 @@ class ManyParticlePhysicalSystem:
def get_potential_energy(self, qval):
""" evaluate the potential energy numerically """
return float(self.potential_energy.subs(list(zip(self.q, qval))))
return float(self.potential_energy.xreplace(dict(zip(self.q, qval))))
def get_kinetic_energy(self, pval):
""" evaluate the kinetic energy numerically """
return float(self.kinetic_energy.subs(list(zip(self.p, pval))))
return float(self.kinetic_energy.xreplace(dict(zip(self.p, pval))))
def get_total_energy(self, qval, pval):
""" evaluate the total energy numerically """
......@@ -196,7 +196,7 @@ class ManyParticlePhysicalSystem:
def get_forces_subs(self, q):
""" evaluate the forces numerically, subs version, very slow """
return self.forces.subs(list(zip(self.q, q)))
return self.forces.xreplace(dict(zip(self.q, q)))
def get_forces_nopbc(self, qval):
return np.array(self.get_forces_val(qval), dtype=float)
......@@ -223,7 +223,7 @@ class MPPS1D(ManyParticlePhysicalSystem):
def find_mic(self, qval):
""" works for only two particles """
micval = qval.copy()
r = float(self.ff[0].r_cart.subs(list(zip(self.q, qval))))
r = float(self.ff[0].r_cart.xreplace(dict(zip(self.q, qval))))
r -= np.rint(r*self.inv_cell)*self.cell
micval[1] = qval[0] + np.abs(r)
return micval, np.abs(r)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment