Example #1
0



################## Excercise 2 ######################
fnum=1
for p in range(1,4,1):
  f = fcns['f%d'%p]
  v = fcns['v%d'%p]
  fn = fcns['n%d_f'%p]
  vn = fcns['n%d_v'%p]
  title = fn+'\n'+vn+'\n'

  print "------------\nsolving explicit Euler with:\n"+title+"------------"
  a1 = heq.explicitEuler(f,v,\
                       nt,ot,dt,\
                       nx,ox,dx,\
                       a=1.0)
  sol1 = a1.solve()
  display2d(nt,ot,dt,nx,ox,dx,sol1,fnum,title)
  j = int(0.2/dt)
  graph_A(sol1,nx,ox,dx,j,fnum+1,dt,title)
  fnum+=2


############### Exercise 3 #######################
print "Exercise 2.3: controled solution"
exact = fhw01.u_exact(nt,nx)
display2d(nt,ot,dt,nx,ox,dx,exact,fnum,"Exact solution")
a1 = heq.explicitEuler(fhw01.f_exact,fhw01.v_exact,\
                       nt,ot,dt,\
                       nx,ox,dx,\
Example #2
0
      a[ix] = x
    else:
      a[ix] = 1.0 -x
  return a

    

M = 501
N = 11
ot,dt,nt = ganesh2Toto(1.,M)
ox,dx,nx = ganesh2Toto(1.,N)


# Exercise sheet 2
a1 = heq.explicitEuler(f1,v1,\
                       nt,ot,dt,\
                       nx,ox,dx,\
                       a=1.0)
sol1 = a1.solve()


display2d(nt,ot,dt,nx,ox,dx,sol1,1)
display2d(nt,ot,dt,nx,ox,dx,f1(nx,nt),2)

graph_f(v1(nx),nx,ox,dx,3)




a2 = heq.implicitEuler(f1,v1,\
                       nt,ot,dt,\
                       nx,ox,dx,\