Commit aa16cc8f authored by Nathan Coppin's avatar Nathan Coppin
Browse files

valdiating

parent 7686246c
Pipeline #8254 passed with stages
in 3 minutes and 21 seconds
......@@ -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_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")
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")
return fn + fn2 + fn3 + fn4 + ft + ft2 + ft3 + ft4
class Weight(unittest.TestCase) :
......@@ -113,18 +113,18 @@ class Weight(unittest.TestCase) :
# COMPUTATION LOOP
#
forces = g*p.mass()
def accumulate(bnd_forces) :
bnd_forces += total_boundary_force(p)
def accumulate(bnd_impulses) :
bnd_impulses += total_boundary_impulse(p)
while t < tEnd :
bnd_forces = np.zeros((2,))
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_forces))
after_sub_iter = lambda subdt : accumulate(bnd_impulses))
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_forces/dt)**2)
error = np.sqrt(sum(sum(forces) - bnd_impulses/dt)**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