Diffusion forward.py

From Werner KRAUTH

(Difference between revisions)
Jump to: navigation, search
Revision as of 13:29, 6 June 2024
Werner (Talk | contribs)

← Previous diff
Revision as of 13:31, 6 June 2024
Werner (Talk | contribs)

Next diff →
Line 1: Line 1:
import random import random
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
- +
N = 5 N = 5
pos = [] pos = []

Revision as of 13:31, 6 June 2024

import random
import matplotlib.pyplot as plt

N = 5
pos = []
for stat in range(10000):
   posit = set(range(N))
   t = 0
   while True:
      t += 1
      posit = set([min(max(b + random.choice([-1, 0, 1]), 0), N - 1) for b in posit])
      if len(posit) == 1: break
   pos.append(posit.pop())
plt.title('Forward coupling: 1-d with walls: position of the coupled config.')
plt.hist(pos,bins=N,range=(-0.5, N - 0.5), density=True)
plt.savefig('ForwardCoupling.png')
plt.show()
Personal tools