Commit 48472926 by Jigyasa Watwani

analytical solution rewriting

parent 10174caf
Showing with 6 additions and 6 deletions
......@@ -7,13 +7,13 @@
import numpy as np
import dolfin as df
import matplotlib.pyplot as plt
import progressbar
# import progressbar
from scipy.optimize import curve_fit
df.set_log_level(df.LogLevel.ERROR)
df.parameters['form_compiler']['optimize'] = True
def advection_diffusion(Nx, L, Nt, tmax, v, D):
def advection_diffusion(Nx, L, Nt, tmax, v, D, m):
# mesh, function space, function, test function
mesh = df.IntervalMesh(Nx, 0, L)
function_space = df.FunctionSpace(mesh, 'P', 1)
......@@ -37,7 +37,7 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
+ df.inner((u * c0).dx(0), tc)
+ D * df.inner(tc.dx(0), c.dx(0))) * df.dx(mesh)
for i in progressbar.progressbar(range(1, len(times))):
for i in range(1, len(times)):
v.t = times[i]
u.assign(df.project(v, function_space))
df.solve(form == 0, c)
......@@ -49,15 +49,15 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
return [c_array,x_array]
Nx, L, tmax, D, b, m = 100, 1, 1, 0.1, 0.01, 2
Nx, L, tmax, D, b, m = 100, 0.1, 1, 0.1, 0.01, 2
v = df.Expression('b*x[0]/(L + b*t)', b=b, L=L, t=0, degree=1)
Nt_array = np.array([5, 10, 15, 20, 25, 30])
Nt_array = np.array([10, 20, 30, 40, 50, 60, 70, 80, 90, 100])
# , 400, 800, 1600, 3200, 6400, 12800])
dt_array = tmax/(Nt_array)
error_in_c = np.zeros(len(Nt_array))
for i in range(len(Nt_array)):
c, x = advection_diffusion(Nx, L, Nt_array[i], tmax, v, D)
c, x = advection_diffusion(Nx, L, Nt_array[i], tmax, v, D, m)
times = np.linspace(0, tmax, Nt_array[i]+1)
c_exact = np.zeros((Nt_array[i]+1, Nx+1))
for j in range(0, Nt_array[i]+1):
......
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 sign in to comment