Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung | |||
ss17:musterbildende_chemische_systeme [2017/06/08 17:29] fmbk25 |
ss17:musterbildende_chemische_systeme [2017/06/08 17:31] (aktuell) fmbk25 |
||
---|---|---|---|
Zeile 18: | Zeile 18: | ||
- | Protokoll 1.6.17:\\ | ||
- | Diffusionscode: \\ | ||
- | <code> | ||
- | import matplotlib.pyplot as plt | ||
- | import numpy as np | ||
- | from copy import deepcopy | ||
- | x0=0 | ||
- | x1=10 | ||
- | dx = 0.1 | ||
- | dt=0.0001 | ||
- | D= 10.0 | ||
- | def init(): | ||
- | #sin | ||
- | sigma = 0.8 | ||
- | a = np.linspace(x0,x1,(x1-x0)/dx) | ||
- | #sin | ||
- | #a = 10*np.sin(a) | ||
- | #gauss | ||
- | a = 1/sigma*np.exp(-0.5*((a-(x1-x0)/2)/sigma)**2) | ||
- | return a | ||
- | |||
- | |||
- | def getnewtimestep(a): | ||
- | b=[0]*len(a) | ||
- | for i in range(1,len(a)-1): | ||
- | b[i] = a[i] + D*dt/dx**2*(a[i+1]+a[i-1]-2*a[i]) | ||
- | b[0] = a[0] +D*dt/dx**2 * (a[1]-2*a[0]) #Randpunkte muessen gesondert behandelt werden | ||
- | b[-1] = a[-1] + D*dt/dx**2 * ( a[-2] - 2*a[-1]) #Randpunkte muessen gesondert behandelt werden | ||
- | return b | ||
- | |||
- | |||
- | |||
- | |||
- | a= init() | ||
- | N = 10000 | ||
- | |||
- | for i in range(N): | ||
- | if i % (N/10)==0: | ||
- | plt.plot(a, label="t= " + str(i)) | ||
- | a = getnewtimestep(a) | ||
- | plt.legend() | ||
- | #plt.ylim([0,10]) | ||
- | plt.show() | ||
- | </code> | ||
- | |||
- | Ansonsten: den Diffusionscode verändert (Betrag, Gerade, Anfangswerte verändert) | ||
- | game of life angefangen | ||
- | |||
- | Protokoll 08.06.17: | ||
- | |||
- | Lotta Volterra Pfeilmodell im iPython notebook : | ||
- | <code> | ||
- | import matplotlib.pyplot as plt | ||
- | import numpy as np | ||
- | def LotkaVolterra(N1,N2): | ||
- | eps1 = 6 | ||
- | eps2 = 9 | ||
- | gamma1 = 12 | ||
- | gamma2 = 18 | ||
- | |||
- | return [ N1*(eps1-gamma1*N2),-N2*(eps2-gamma2*N1)] | ||
- | x = np.linspace(0,2,num =25) | ||
- | y = np.linspace(0,2,num =25) | ||
- | X,Y = np.meshgrid(x,y) | ||
- | U,V = LotkaVolterra(X,Y) | ||
- | plt.quiver(X,Y,U,V,linewidths=.1) | ||
- | plt.axis('equal') | ||
- | plt.ylabel("Jaeger") | ||
- | plt.xlabel("Beute") | ||
- | |||
- | plt.grid() | ||
- | plt.show() | ||
- | </code> | ||
- | |||
- | Fitz-Hugh-Nagumo Modell (auch mit Pfeilen): | ||
- | <code> | ||
- | import matplotlib.pyplot as plt | ||
- | import numpy as np | ||
- | |||
- | def Fitz_Hugh(a,b): | ||
- | alpha = 0.2 | ||
- | beta = 5 | ||
- | |||
- | return [ a - a**3 - b + alpha, beta * (a -b)] | ||
- | | ||
- | x = np.linspace(0,2,num =25) | ||
- | y = np.linspace(0,2,num =25) | ||
- | X,Y = np.meshgrid(x,y) | ||
- | U,V = Fitz_Hugh(X,Y) | ||
- | plt.quiver(X,Y,U,V,linewidths=0.1) | ||
- | plt.axis('equal') | ||
- | plt.ylabel("Produkte") | ||
- | plt.xlabel("Edukte") | ||
- | |||
- | plt.grid() | ||
- | plt.show() | ||
- | </code> | ||
- | |||
- | Lotka-Volterra mit Populationen-Zeit-Graph: | ||
- | <code> | ||
- | import matplotlib.pyplot as plt | ||
- | import numpy as np | ||
- | from copy import deepcopy | ||
- | |||
- | # r fuer beute | ||
- | # b fuer raeuber | ||
- | def lv(r0,b0): | ||
- | epsilonR = 1 | ||
- | epsilonB = 1 | ||
- | gammaR = 1 | ||
- | gammaB = 1 | ||
- | delta = 0.1 | ||
- | r=[r0] | ||
- | b=[b0] | ||
- | akt_r=r0 | ||
- | akt_b=b0 | ||
- | for i in range (100): | ||
- | r.append(akt_r*(epsilonR-gammaR*akt_b)*delta+akt_r) | ||
- | b.append( -akt_b*(epsilonB-gammaB*akt_r)*delta+akt_b) | ||
- | akt_r = r[-1] | ||
- | akt_b = b[-1] | ||
- | return r, b | ||
- | |||
- | r,b=lv(3,3) | ||
- | |||
- | plt.plot(b,label = "Raeuber") | ||
- | plt.plot(r, label ="Beute") | ||
- | plt.legend() | ||
- | plt.show() | ||
- | </code> | ||
- | |||
- | Fitz-Hugh-Nagumo Konzentrations-Zeit-Diagramm: | ||
- | <code> | ||
- | #!/usr/bin/env python | ||
- | # -*- coding: utf-8 -*- | ||
- | import matplotlib.pyplot as plt | ||
- | import numpy as np | ||
- | from copy import deepcopy | ||
- | |||
- | # a für stoff 1 | ||
- | # b für stoff 2 | ||
- | def fhl(a0,b0): | ||
- | delta = 0.1 | ||
- | a=[a0] | ||
- | b=[b0] | ||
- | akt_a=a0 | ||
- | akt_b=b0 | ||
- | alpha = 1 | ||
- | beta = 1 | ||
- | for i in range (100): | ||
- | a.append(((akt_a - akt_a**3 -akt_b + alpha)*delta + akt_a)) | ||
- | b.append(beta * (akt_a- akt_b) * delta + akt_b) | ||
- | akt_a = a[-1] | ||
- | akt_b = b[-1] | ||
- | return a, b | ||
- | |||
- | a,b=fhl(2,4) | ||
- | |||
- | plt.plot(a,label = "Stoff1") | ||
- | plt.plot(b, label ="Stoff2") | ||
- | plt.legend() | ||
- | plt.show() | ||
- | </code> |