diff options
author | meta-androcto <meta.androcto1@gmail.com> | 2019-07-01 14:06:16 +0300 |
---|---|---|
committer | meta-androcto <meta.androcto1@gmail.com> | 2019-07-01 14:06:16 +0300 |
commit | 498d912a9d5854c0cfc1f54ed8b4216d442b89f1 (patch) | |
tree | 66e565094b4eec07c2e05c9106724ee5e4649454 /mesh_tissue/numba_functions.py | |
parent | fffaf5d2759d38d4166f608eab8871fcd59a7e11 (diff) |
mesh_tissue: initial update 2.80
Diffstat (limited to 'mesh_tissue/numba_functions.py')
-rw-r--r-- | mesh_tissue/numba_functions.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/mesh_tissue/numba_functions.py b/mesh_tissue/numba_functions.py new file mode 100644 index 00000000..1cb8e6b8 --- /dev/null +++ b/mesh_tissue/numba_functions.py @@ -0,0 +1,40 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +from numba import jit +import numpy as np + +@jit +def numba_reaction_diffusion(n_verts, a, b, diff_a, diff_b, f, k, dt, id0, id1, time_steps): + for i in range(time_steps): + lap_a = np.zeros(n_verts) + lap_b = np.zeros(n_verts) + lap_a0 = a[id1] - a[id0] # laplacian increment for first vertex of each edge + lap_b0 = b[id1] - b[id0] # laplacian increment for first vertex of each edge + + for i, j, la0, lb0 in zip(id0,id1,lap_a0,lap_b0): + lap_a[i] += la0 + lap_b[i] += lb0 + lap_a[j] -= la0 + lap_b[j] -= lb0 + ab2 = a*b**2 + #a += eval("(diff_a*lap_a - ab2 + f*(1-a))*dt") + #b += eval("(diff_b*lap_b + ab2 - (k+f)*b)*dt") + a += (diff_a*lap_a - ab2 + f*(1-a))*dt + b += (diff_b*lap_b + ab2 - (k+f)*b)*dt + return a, b |