Commit f7382959 authored by Matthieu Constant's avatar Matthieu Constant
Browse files

fix time.clock python

parent b613f0f7
......@@ -97,7 +97,7 @@ fluid.set_weak_boundary("Right","Wall")
#Set location of the grains in the mesh and compute the porosity in each computation cell
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
#Computation loop
while t < tEnd :
......@@ -128,4 +128,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -58,7 +58,7 @@ def genInitialPosition(filename, N, r, lx, ly, rhop) :
[nb_laid_particles, coors] = pre.depositInBox2D(radii,lx*4,ly/10)
#Add a grain at each centre position
for i in range(nb_laid_particles):
p.add_particle(coors[2*i:2*i+2], radii[i], radii[i]**2 * np.pi * rhop);
p.add_particle(coors[2*i:2*i+2], radii[i], radii[i]**2 * np.pi * rhop)
#Grains horizontal translation
p.position()[:, 0] += 0.1
......@@ -66,7 +66,7 @@ def genInitialPosition(filename, N, r, lx, ly, rhop) :
radii = pre.granulo_Random(N, Ra, Rb)
[nb_laid_particles, coors] = pre.depositInBox2D(radii,lx,ly)
for i in range(nb_laid_particles):
p.add_particle(coors[2*i:2*i+2], radii[i], radii[i]**2 * np.pi * rhop);
p.add_particle(coors[2*i:2*i+2], radii[i], radii[i]**2 * np.pi * rhop)
p.write_vtk(filename,0,0)
#Define output directory
......@@ -145,7 +145,7 @@ for i in range(len(x[:,0])):
s[i,3] = 1
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
#Computation loop
while t < tEnd :
......@@ -176,4 +176,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -111,7 +111,7 @@ for i in range(len(x[:,0])):
s[i,3] = 1
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
#Computation loop
while t < tEnd :
......@@ -142,4 +142,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -55,7 +55,7 @@ def genInitialPosition(filename, r, ly, lx, rhop) :
for i in range(len(x)) :
r1 = np.random.uniform(.95*r, 1.05*r)
#Args : add_particles(centre, radius, mass)
p.add_particle((x[i], y[i]), r1, r1**2 * np.pi * rhop);
p.add_particle((x[i], y[i]), r1, r1**2 * np.pi * rhop)
p.write_vtk(outputdir, 0, 0)
#Define output directory
......@@ -87,7 +87,7 @@ print("r = %g, m = %g\n" % (p.r()[0], p.mass()[0]))
print("RHOP = %g" % rhop)
outf = 200 #number of iterations between output files
tic = time.clock()
tic = time.time()
forces = np.zeros_like(p.velocity())
#Computation loop
while t < tEnd :
......@@ -108,6 +108,6 @@ while t < tEnd :
ioutput = int(ii/outf) + 1
p.write_vtk(outputdir, ioutput, t)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -159,7 +159,7 @@ fluid.set_weak_boundary("Outer","Wall")
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
#Computation loop
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
......@@ -188,4 +188,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -69,7 +69,7 @@ def genInitialPosition(filename, r, rout, rin, rhop) :
for i in range(x.shape[0]) :
if y[i]<0:
rhop1 = random.choice([rhop*.9,1.1*rhop,rhop])
p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop1);
p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop1)
p.write_vtk(filename,0,0)
......@@ -159,4 +159,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -58,7 +58,7 @@ def genInitialPosition(filename, r, H, ly, lx, rhop) :
y = y.flat
#Add a grain at each centre position
for i in range(len(x)) :
p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop);
p.add_particle((x[i], y[i]), r, r**2 * np.pi * rhop)
p.write_vtk(filename,0,0)
#Define output directory
......@@ -132,7 +132,7 @@ fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
#Computation loop
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
......@@ -161,4 +161,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -170,7 +170,7 @@ if init:
t = 0
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
#Computation loop
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
......@@ -201,4 +201,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -171,7 +171,7 @@ if init:
t = 0
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
#Computation loop
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
......@@ -202,4 +202,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
......@@ -61,7 +61,7 @@ def genInitialPosition(filename, r, rout, rhop, compacity) :
for i in range(x.shape[0]) :
#Add grains object with properties defined above
p.add_particle((x[i]+2*random.uniform(-e/2+r,e/2-r), y[i]+2*random.uniform(-e/2+r,e/2-r)), r, r**2 * np.pi * rhop);
p.add_particle((x[i]+2*random.uniform(-e/2+r,e/2-r), y[i]+2*random.uniform(-e/2+r,e/2-r)), r, r**2 * np.pi * rhop)
#Vertical shift of the grains to the top of the box
p.position()[:, 1] += 0.52
......@@ -165,7 +165,7 @@ if init:
t = 0
fluid.export_vtk(outputdir,0,0)
tic = time.clock()
tic = time.time()
#Computation loop
fluid.set_particles(p.mass(), p.volume(), p.position(), p.velocity())
while t < tEnd :
......@@ -196,4 +196,4 @@ while t < tEnd :
p.write_vtk(outputdir, ioutput, t)
fluid.export_vtk(outputdir, t, ioutput)
ii += 1
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.clock() - tic))
print("%i : %.2g/%.2g (cpu %.6g)" % (ii, t, tEnd, time.time() - tic))
Supports Markdown
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