élasticité expansion-réaction diffusion

L'installation Elasticité dynamique agit comme un filtre et génère de nouveaux espaces démultipliés, comme un empilement quasi infini d'horizons. Par principe de réflexion, la pièce absorbe l'image de l'environnement et accumule les points de vue ; le mouvement permanent requalifie continuellement ce qui est regardé et entendu.

Ce post étudie une reaction de reaction diffusion sur la structure.

In [11]:
%load_ext autoreload
%autoreload 2
The autoreload extension is already loaded. To reload it, use:
  %reload_ext autoreload
In [12]:
import elasticite as el
import numpy as np
np.set_printoptions(precision=2, suppress=True)
import matplotlib.pyplot as plt
In [13]:
class EdgeGrid(el.EdgeGrid):
    def update_particles(self):
        self.particles[2,:] =  np.cos((self.t + np.linspace(0, 1., self.N_particles))*2*np.pi)

    def update(self):
        self.update_particles()

e = EdgeGrid(N_lame=25, grid_type='line')
e.animate()
[MoviePy] >>>> Building video /var/folders/3p/m0g52j9j69z3gj8ktpgg1dm00000gn/T/tmpko8i8esq.mp4
[MoviePy] Writing video /var/folders/3p/m0g52j9j69z3gj8ktpgg1dm00000gn/T/tmpko8i8esq.mp4
 10%|▉         | 20/201 [00:05<00:47,  3.82it/s]WARNING:py.warnings:/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

                                                 
[MoviePy] Done.
[MoviePy] >>>> Video ready: /var/folders/3p/m0g52j9j69z3gj8ktpgg1dm00000gn/T/tmpko8i8esq.mp4 


Out[13]:
In [14]:
CC = e.particles[:, :, np.newaxis]-e.particles[:, np.newaxis, :] # 2xNxN ; en metres
distance = np.sqrt(np.sum(CC**2, axis=0))# NxN ; en metres
print(distance)
print(np.tanh(np.linspace(-2, 2, 15)))
d_min, d_max = .2, 1.
f = lambda d: 900./ e.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
print(f(np.linspace(0, 2, 15)))
[[ 0.    0.43  0.87 ...,  6.72  7.02  7.34]
 [ 0.43  0.    0.43 ...,  6.87  7.15  7.46]
 [ 0.87  0.43  0.   ...,  7.04  7.31  7.59]
 ..., 
 [ 6.72  6.87  7.04 ...,  0.    0.44  0.88]
 [ 7.02  7.15  7.31 ...,  0.44  0.    0.44]
 [ 7.34  7.46  7.59 ...,  0.88  0.44  0.  ]]
[-0.96 -0.94 -0.89 -0.82 -0.69 -0.52 -0.28  0.    0.28  0.52  0.69  0.82
  0.89  0.94  0.96]
[-75.   -29.64  -8.38   1.22   5.2    6.54   6.67   6.27   5.67   5.03
   4.42   3.86   3.36   2.92   2.53]
In [15]:
class EdgeGrid(el.EdgeGrid):
    def update_particles(self):
        CC = self.particles[:, :, np.newaxis]-self.particles[:, np.newaxis, :] # 2xNxN ; en metres
        distance = np.sqrt(np.sum(CC**2, axis=0))# NxN ; en metres
        d_min, d_max = .2, 1.5
        #f = lambda d: -100./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #f = lambda d: 100./ self.N_particles* (np.exp(-d/d_max) - np.exp(-d/d_min))
        f = lambda d: -20./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #R = lambda w: - 3.5*np.sin(2*np.pi*w)
        #R = lambda w: w*(1 - w**2)
        R = lambda w: .2*np.tanh(w) # (1+w)*(1-w)
        
        w = self.particles[2,:]
        #print('w_t', (np.dot(f(distance), w)).mean(), (np.dot(f(distance), w)).std())
        #w *= (1-self.dt)
        w += np.tanh(np.dot(f(distance), w) + R(w))*self.dt
        #print(w.min(), w.max())
        #w /= np.absolute(w).max()
        self.particles[2,:] = w

    def update(self):
        self.update_particles()

e = EdgeGrid(N_lame=25, grid_type='line')
#e.particles[2, :] = 0
#e.particles[2, 0] = -1.
#e.particles[2, -1] = 1.
#e.particles[2, :] = 2*np.random.rand(e.N_particles)-1
e.animate(duration=40, fps=10, fname='../files/2015-10-14_elasticite/reaction-diffusion.mp4')
WARNING:py.warnings:/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

[MoviePy] >>>> Building video ../files/2015-10-14_elasticite/reaction-diffusion.mp4
[MoviePy] Writing video ../files/2015-10-14_elasticite/reaction-diffusion.mp4
                                                 
[MoviePy] Done.
[MoviePy] >>>> Video ready: ../files/2015-10-14_elasticite/reaction-diffusion.mp4 


Out[15]:
In [16]:
class EdgeGrid(el.EdgeGrid):
    def update_particles(self):
        CC = self.particles[:, :, np.newaxis]-self.particles[:, np.newaxis, :] # 2xNxN ; en metres
        distance = np.sqrt(np.sum(CC**2, axis=0))# NxN ; en metres
        d_min, d_max = .2, 1.5
        #f = lambda d: -100./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #f = lambda d: 100./ self.N_particles* (np.exp(-d/d_max) - np.exp(-d/d_min))
        f = lambda d: 20./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #R = lambda w: - 3.5*np.sin(2*np.pi*w)
        #R = lambda w: w*(1 - w**2)
        R = lambda w: -10.*np.tanh(w) # (1+w)*(1-w)
        
        w = self.particles[2,:]
        #print('w_t', (np.dot(f(distance), w)).mean(), (np.dot(f(distance), w)).std())
        #w *= (1-self.dt)
        w += np.tanh(np.dot(f(distance), w) + R(w))*self.dt
        #print(w.min(), w.max())
        #w /= np.absolute(w).max()
        self.particles[2,:] = w

    def update(self):
        self.update_particles()

e = EdgeGrid(N_lame=25, grid_type='line')
#e.particles[2, :] = 0
#e.particles[2, 0] = -1.
#e.particles[2, -1] = 1.
#e.particles[2, :] = 2*np.random.rand(e.N_particles)-1
e.animate(duration=40, fps=10, fname='../files/2015-10-14_elasticite/reaction-diffusion-up.mp4')
WARNING:py.warnings:/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

[MoviePy] >>>> Building video ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4
[MoviePy] Writing video ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4
                                                 
[MoviePy] Done.
[MoviePy] >>>> Video ready: ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4 


Out[16]:
In [17]:
class EdgeGrid(el.EdgeGrid):
    def update_particles(self):
        CC = self.particles[:, :, np.newaxis]-self.particles[:, np.newaxis, :] # 2xNxN ; en metres
        distance = np.sqrt(np.sum(CC**2, axis=0))# NxN ; en metres
        d_min, d_max = .2, 1.5
        #f = lambda d: -100./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #f = lambda d: 100./ self.N_particles* (np.exp(-d/d_max) - np.exp(-d/d_min))
        f = lambda d: 20./ self.N_particles* (np.exp(-d/d_max)/d_max - np.exp(-d/d_min)/d_min)
        #R = lambda w: - 3.5*np.sin(2*np.pi*w)
        #R = lambda w: w*(1 - w**2)
        R = lambda w: -10.*np.tanh(w) # (1+w)*(1-w)
        
        w = self.particles[2,:]
        #print('w_t', (np.dot(f(distance), w)).mean(), (np.dot(f(distance), w)).std())
        #w *= (1-self.dt)
        w += np.tanh(np.dot(f(distance), w) + R(w))*self.dt
        #print(w.min(), w.max())
        #w /= np.absolute(w).max()
        self.particles[2,:] = w

    def update(self):
        self.update_particles()

e = EdgeGrid(N_lame=25, grid_type='line')
#e.particles[2, :] = 0
#e.particles[2, 0] = -1.
#e.particles[2, -1] = 1.
#e.particles[2, :] = 2*np.random.rand(e.N_particles)-1
e.animate(duration=40, fps=10, fname='../files/2015-10-14_elasticite/reaction-diffusion-up.mp4')
WARNING:py.warnings:/usr/local/lib/python3.5/site-packages/matplotlib/pyplot.py:516: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)

[MoviePy] >>>> Building video ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4
[MoviePy] Writing video ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4
                                                 
[MoviePy] Done.
[MoviePy] >>>> Video ready: ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4 


Out[17]:

git

In [18]:
!git s
 M ../files/2015-10-14_elasticite/reaction-diffusion-up.mp4
 M ../files/2015-10-14_elasticite/reaction-diffusion.mp4
 M "2015-10-14 \303\251lasticit\303\251, Fresnel.ipynb"
 M "2015-10-27 \303\251lasticit\303\251 expansion-r\303\251action diffusion.ipynb"
?? __temp_ipython__.png
?? anim.gif
In [19]:
!git commit -am' expansion - équation de reaction diffusion'
[master c4c5757]  expansion - équation de reaction diffusion
 4 files changed, 823 insertions(+), 43 deletions(-)
 rewrite files/2015-10-14_elasticite/reaction-diffusion-up.mp4 (98%)
 rewrite files/2015-10-14_elasticite/reaction-diffusion.mp4 (75%)
In [20]:
! git push
Counting objects: 9, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 13.05 MiB | 10.68 MiB/s, done.
Total 9 (delta 6), reused 0 (delta 0)
To git@git.framasoft.org:laurentperrinet/elasticte.git
   6f0f09b..c4c5757  master -> master
In [21]:
!git pull
Already up-to-date.