Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- a=1
- x0=5
- L=10
- J=101
- cf= 0.5
- u = []
- un = []
- #definisco gaussiana
- def gaussian(a, b):
- return np.exp(-np.power(a-b,2))
- #calcolo vettore x
- deltax= L/(J-1)
- x_val= np.arange(0,L,deltax)
- #calcolo vettore u
- for i in x_val:
- u.append(gaussian(i,x0))
- #salvo gaussiana statica
- plt.plot(x_val,u)
- plt.savefig("staticgaussian.png")
- deltat= (deltax * cf)/a
- for j in range(0,len(u)):
- if j==0:
- umin=-1
- umax=j+1
- if j==J-1:
- umin=j-1
- umax=0
- else:
- umin=j-1
- umax=j+1
- # val= 0.5*( (u[umin]) + (u[umax]) ) - ( (a*deltat)/(2*deltax) )*( (u[umax]) - (u[umin]) )
- # un.append(val)
- print(j)
- print(un)
- #plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement