Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

ss17:protokolle

Protokoll 1.6.17:
Diffusionscode:

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()

Ansonsten: den Diffusionscode verändert (Betrag, Gerade, Anfangswerte verändert) game of life angefangen

ss17/protokolle.txt · Zuletzt geändert: 2017/06/08 17:33 von fmbk25