Commit 73ce15d3 authored by Lars Stietz's avatar Lars Stietz
Browse files

updated plot routine

parent d24427fb
......@@ -7,12 +7,13 @@ import time
# Creating quadrature nodes and collocation
num_nodes = 10
t_interval = [0,1]
t_interval = [0,1]
coll = CollGaussLobatto(num_nodes,t_interval[0],t_interval[1])
# initialize Vector
u_0 = 1
l = -1
l = -5j
u = u_0*np.ones(num_nodes, dtype = np.complex64)
strt = True
nd = True
......@@ -27,11 +28,6 @@ if coll.nodes[-1] != t_interval[1]:
nd = False
u = np.append(u,1)
# intial data
u_0 = 1
l = -1
# RHS of ODE
def f(u):
return l*u
......@@ -73,7 +69,7 @@ def res(u, Qmat,u_0):
"""
adjustment for strt/nd=False still needed
"""
r = u_0 + Qmat[1:,1:]@f(u)-u
r = u_0 + Qmat[1:,1:]@f(u).real-u
return r
......@@ -83,33 +79,39 @@ if solving == 1:
# SDC straight forward approach
k_max = 100
k_max = 10
res_2 = 2
res_it = np.empty(0)
res_itM = np.empty(0)
j = 0
Q_slow = asmSlowMat(coll.delta_m)
u_Mat = deepcopy(u)
#while res_2 > 1e-14:
for it in range(k_max):
#u = sweep(u,coll.delta_m,coll.Smat,coll.Qmat,f)
u = sweepMat(u,coll.delta_m,coll.Qmat,Q_slow,f)
u = sweep(u,coll.delta_m,coll.Smat,coll.Qmat,f)
u_Mat = sweepMat(u_Mat,coll.delta_m,coll.Qmat,Q_slow,f)
r = res(u.real,coll.Qmat,u_0)
r_Mat = res(u_Mat.real,coll.Qmat,u_0)
res_2 = np.linalg.norm(r)
res_2M = np.linalg.norm(r_Mat)
res_it = np.append(res_it,res_2)
res_itM = np.append(res_itM,res_2M)
plt.figure(1)
plt.title('SDC solution vs exact solution')
plt.plot(coll.nodes,u.real,'b',label='SDC straight forward')
plt.plot(coll.nodes,y(coll.nodes).real,'r--',label = 'exact solution')
plt.plot(coll.nodes,u.real,'b',label='SDC sweep')
plt.plot(coll.nodes,u_Mat.real,'c*',label='SDC Mat')
plt.plot(coll.nodes,y(coll.nodes).real,'r-.',label = 'exact solution')
plt.xlabel('t')
plt.ylabel('u(t)')
plt.legend()
plt.figure(2)
plt.title('Update ans Residual')
#plt.semilogy(error_it,label= 'update difference (2-Norm)')
plt.semilogy(res_it,label='residual')
plt.semilogy(res_it,label='residual of sweep')
plt.semilogy(res_itM,label='residual of Matrix sweep')
plt.xlabel('iteration step')
plt.legend()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment