Commit 4a7b546f authored by Nathan Coppin's avatar Nathan Coppin
Browse files

correcting names and validation

parent c80fde53
Pipeline #8483 failed with stages
in 1 minute and 46 seconds
......@@ -235,8 +235,8 @@ class ParticleProblem :
"""Returns the contact forces on each grain."""
return (self._get_matrix("ContactForces",self._dim))
def get_boundary_impulses(self,tag="default") :
"""Returns the net normal and tangential impulses acting on a boundary because of the contacts.
def get_boundary_forces(self,tag="default") :
"""Returns the net normal and tangential forces acting on a boundary because of the contacts.
Keyword arguments:
tag -- Name of the boundary
"""
......@@ -316,7 +316,7 @@ class ParticleProblem :
return self._lib.particleProblemIterate(self._p, c_double(np.min(self.r()) if self.r().size != 0 else tol), c_double(dt), c_double(tol), c_int(-1),c_int(force_motion),_np2c(forces))
def get_contacts(self,contact_type) :
"""Gives the contact forces. Warning : during the resolution fo the contacts,
"""Gives the contact forces. Warning : during the resolution of the contacts,
the considered quantities are impulses, while forces are written and read.
"""
ctype = {"particle_particle":0,"particle_disk":1,"particle_segment":2,"particle_triangle":3}[contact_type]
......
......@@ -81,7 +81,7 @@ p2.write_vtk(outputdir, 0, 0)
# COMPUTATION LOOP
#
def accumulate(F,nsub):
F+=np.sum(p2.get_boundary_impulses("Inner"),axis=0)/nsub
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)/nsub
while t < tEnd :
state2 = p2.state()
p2.forced_flag()[(state2.x[:,1] + p2.r()[:,0] <= -0.5)] = 1
......
......@@ -91,7 +91,7 @@ p2.write_vtk(outputdir, 0, 0)
# COMPUTATION LOOP
#
def accumulate(F,nsub):
F+=np.sum(p2.get_boundary_impulses("Inner"),axis=0)/nsub
F+=np.sum(p2.get_boundary_forces("Inner"),axis=0)/nsub
while t < tEnd :
state2 = p2.state()
p2.forced_flag()[(state2.x[:,1] + p2.r()[:,0] <= -0.5)] = 1
......
......@@ -98,7 +98,7 @@ p.write_vtk(outputdir, 0, 0)
#
opened = 0
def accumulate(F):
F+=np.sum(p.get_boundary_impulses("Inner"),axis=0)
F+=np.sum(p.get_boundary_forces("Inner"),axis=0)
while t < tEnd :
if t>=10 and opened == 0:
opened = 1
......
......@@ -65,11 +65,11 @@ def genInitialPosition(filename, rmin, rmax, H, lx, ly, rhop) :
p.add_particle((x[i], y[i]), r[i], r[i]**2 * np.pi * rhop)
p.write_vtk(filename,0,0)
def total_boundary_impulse(p):
fn, ft = p.get_boundary_impulses("left")
fn2, ft2 = p.get_boundary_impulses("right")
fn3, ft3 = p.get_boundary_impulses("bottom")
fn4, ft4 = p.get_boundary_impulses("top")
def total_boundary_force(p):
fn, ft = p.get_boundary_forces("left")
fn2, ft2 = p.get_boundary_forces("right")
fn3, ft3 = p.get_boundary_forces("bottom")
fn4, ft4 = p.get_boundary_forces("top")
return fn + fn2 + fn3 + fn4 + ft + ft2 + ft3 + ft4
class Weight(unittest.TestCase) :
......@@ -115,18 +115,18 @@ class Weight(unittest.TestCase) :
# COMPUTATION LOOP
#
forces = g*p.mass()
def accumulate(bnd_impulses) :
bnd_impulses += total_boundary_impulse(p)
def accumulate(bnd_forces,nsub) :
bnd_forces += total_boundary_force(p)/nsub
while t < tEnd :
bnd_impulses = np.zeros((2,))
time_integration.iterate(None,p,dt,min_nsub=1,external_particles_forces=forces,
after_sub_iter = lambda subdt : accumulate(bnd_impulses))
after_sub_iter = lambda nsub : accumulate(bnd_forces,nsub))
t += dt
if ii %outf == 0 :
ioutput = int(ii/outf) + 1
#p.write_vtk(outputdir, ioutput, t)
print("%i : %.2g/%.2g" % (ii, t, tEnd))
error = np.sqrt(sum(sum(forces) - bnd_impulses/dt)**2)
error = np.sqrt(sum(sum(forces) - bnd_forces)**2)
error /= np.sqrt(sum(sum(forces)**2))
print(error*100,"%")
self.assertLess(error,.5/100., "error is too large in weight")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment