Commit d5b0265d by Jigyasa Watwani

1D/2D/3D solutions for all three growth models. Problem in the linear solution.

parents 28c84ab6 8b2e5a8c
......@@ -47,34 +47,37 @@ class GrowthDiffusion(object):
+ self.Dc * df.inner(df.nabla_grad(self.c), df.nabla_grad(tc))
- df.inner(self.reaction_rate * self.c, tc) ) * df.dx
def solve(self):
times = np.arange(0, self.maxtime+self.timestep, self.timestep)
fname = params['timestamp'] + '_concentration'
cFile = df.XDMFFile(fname+ '.xdmf')
savesteps = int(self.savetime/self.timestep)
maxsteps = int(self.maxtime/self.timestep)
self.time = 0.0
cFile = df.XDMFFile('%s_concentration.xdmf' %params['timestamp'])
# initial condition
r2 = "+".join(['x['+str(i)+']*x['+str(i)+']' for i in range(self.dimension)])
c0 = '1 + 0.1*cos(pi*m*(%s)/L)' % r2
c0 = df.Expression(c0, pi=np.pi, m=1, L=self.system_size, degree=1)
self.c0.assign(df.project(c0, self.SFS))
# save data
cFile.write_checkpoint(self.c0, fname, times[0])
cFile.write_checkpoint(self.c0, 'concentration', self.time)
# time stepping
for i in progressbar.progressbar(range(1, len(times))):
for steps in progressbar.progressbar(range(1, maxsteps + 1)):
# get velocity
self.sigma.t = times[i-1]
self.sigma.t = self.time
self.velocity.assign(df.project(self.sigma*self.growth_direction, self.VFS))
# solve
df.solve(self.form == 0, self.c)
# update
self.c0.assign(self.c)
# save data
cFile.write_checkpoint(self.c0, fname, times[i], append=True)
if steps % savesteps == 0:
cFile.write_checkpoint(self.c0, 'concentration', self.time, append=True)
# move mesh
displacement = df.project(self.velocity*self.timestep, self.VFS)
df.ALE.move(self.mesh, displacement)
self.time += self.timestep
cFile.close()
......@@ -95,5 +98,5 @@ if __name__ == '__main__':
gd = GrowthDiffusion(params)
gd.solve()
with open(params['timestamp'] + '_parmeters.json', "w") as fp:
with open(params['timestamp'] + '_parameters.json', "w") as fp:
json.dump(params, fp, indent=4)
\ No newline at end of file
{
"dimension" : 2,
"resolution" : 5,
"resolution" : 15,
"system_size" : 1,
"Dc" : 0.1,
"growth" : "exponential",
"growth" : "linear",
"growth_parameter" : 0.1,
"reaction_rate" : 0.0,
"timestep" : 0.01,
"maxtime" : 1.0
"savetime": 0.1,
"maxtime" : 5.0
}
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