Commit cb5f1fc5 by Jigyasa Watwani

error not zero in the extended run between 0.5 and 1. All ok for runs where extend is beyond 1

parent cd0d54e3
import dolfin as df
import numpy as np
np.set_printoptions(precision=16)
c1File = df.XDMFFile('121223-065916_concentration.xdmf')
c2File = df.XDMFFile('121223-065829_concentration.xdmf')
c1File = df.XDMFFile('171223-153055_concentration.xdmf')
c2File = df.XDMFFile('171223-153002_concentration.xdmf')
mesh = df.IntervalMesh(128, -0.5, 0.5)
times = np.arange(0.0, 1.1, 0.1)
......
......@@ -2,6 +2,7 @@ import numpy as np
import dolfin as df
import progressbar
np.set_printoptions(precision=16)
df.set_log_level(df.LogLevel.ERROR)
df.parameters['form_compiler']['optimize'] = True
......@@ -25,6 +26,7 @@ class diffusion(object):
self.c0.interpolate(df.Expression('1 + 0.2 * cos(pi*x[0]/L)', pi=np.pi, L=self.L, degree=1))
else:
self.c0 = df.project(initc, self.function_space)
# print('c0=', self.c0.compute_vertex_values(self.mesh))
def setup_weak_forms(self):
self.form = (df.inner((self.c - self.c0)/self.timestep, self.tc)
......@@ -36,8 +38,9 @@ class diffusion(object):
self.cFile = df.XDMFFile('%s_concentration.xdmf' % self.timestamp)
# time-variables
self.time = initTime
maxsteps = int(self.maxtime/self.timestep)
self.time = round(initTime, 1)
# print('time=', self.time)
maxsteps = round(self.maxtime/self.timestep)
self.setup_initial_conditions(initc)
self.setup_weak_forms()
......@@ -48,8 +51,10 @@ class diffusion(object):
for steps in progressbar.progressbar(range(1, maxsteps + 1)):
self.time += self.timestep
# print('time=', self.time)
df.solve(self.form == 0, self.c)
self.cFile.write_checkpoint(self.c, 'concentration', self.time, append=True)
# print('c=', self.c.compute_vertex_values(self.mesh))
self.c0.assign(self.c)
self.cFile.close()
......
......@@ -5,5 +5,4 @@
"timestep": 0.1,
"maxtime": 1
}
\ No newline at end of file
import json, datetime
import os
from extend_for_diffusion import diffusion
from viz_extend_for_diffusion import visualize
import argparse
import dolfin as df
......@@ -30,7 +31,7 @@ else:
print('Extending run...')
parametersFile = args.jsonfile
steps = int(parameters['maxtime']/parameters['timestep'])
steps = round(parameters['maxtime']/parameters['timestep'])
mesh = df.IntervalMesh(parameters['resolution'],
- parameters['L']/2,
......@@ -54,5 +55,4 @@ if extend:
with open(parametersFile, "w") as jsonFile:
json.dump(parameters, jsonFile, indent=4, sort_keys=True)
from viz_extend_for_diffusion import visualize
visualize(parameters, DIR='')
......@@ -6,7 +6,7 @@ import progressbar
import matplotlib.pyplot as plt
def visualize(params, DIR=''):
savesteps = int(params['maxtime']/params['timestep'])
savesteps = round(params['maxtime']/params['timestep'])
times = np.arange(savesteps+1) * params['timestep']
mesh = df.IntervalMesh(params['resolution'],
......
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