tpreallocate arrays - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 220a48e1d79afa0ec97dba98f0fa4cdbe65a0131
(DIR) parent 3650114c55663dbb380a6c60844a6a34bf920054
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Wed, 13 Aug 2014 11:53:38 +0200
preallocate arrays
Diffstat:
M python/permeability-results.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
---
(DIR) diff --git a/python/permeability-results.py b/python/permeability-results.py
t@@ -15,13 +15,15 @@ sids = [
'permeability-dp=4000.0-c_phi=1.0-c_grad_p=0.5',
'permeability-dp=4000.0']
-K = numpy.array([])
-c_grad_p = numpy.array([])
+K = numpy.empty(len(sids))
+c_grad_p = numpy.empty_like(K)
+i = 0
for sid in sids:
pc = PermeabilityCalc(sid)
- K.append(pc.conductivity())
- c_grad_p.append(pc.c_grad_p())
+ K[i] = pc.conductivity()
+ c_grad_p[i] = pc.c_grad_p()
+ i += 1
fig = plt.figure()
plt.xlabel('Pressure gradient coefficient $c$ [-]')