Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jigyasa Watwani
/
growth-pattern-control
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c2cf59f8
authored
Oct 13, 2022
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sth wrong with the numerical solution
parent
0034bd0f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
moving_domain/moving_time_dependent_alpha.py
moving_domain/moving_time_dependent_alpha.py
View file @
c2cf59f8
...
...
@@ -29,7 +29,7 @@ def advection_diffusion(Nx, L, Nt, tmax, D):
c_array
[
0
]
=
c0
.
compute_vertex_values
(
mesh
)
# velocity
alpha
=
df
.
Expression
(
'times <
5 ? 0.01 : 0.0'
,
times
=
0
,
degree
=
0
)
alpha
=
df
.
Expression
(
'times <
1 ? alpha0 : 0'
,
times
=
0
,
alpha0
=
alpha
0
,
degree
=
0
)
v
=
df
.
Expression
(
'alpha*x[0]'
,
alpha
=
alpha
,
degree
=
1
)
u
=
df
.
interpolate
(
v
,
SFS
)
...
...
@@ -41,24 +41,24 @@ def advection_diffusion(Nx, L, Nt, tmax, D):
# solve
for
i
in
progressbar
.
progressbar
(
range
(
1
,
Nt
+
1
)):
alpha
.
times
=
times
[
i
]
df
.
solve
(
cform
==
0
,
c
)
c_array
[
i
]
=
c
.
compute_vertex_values
(
mesh
)
c0
.
assign
(
c
)
df
.
ALE
.
move
(
mesh
,
df
.
Expression
(
'v*dt'
,
v
=
v
,
dt
=
dt
,
degree
=
1
))
x_array
[
i
]
=
mesh
.
coordinates
()[:,
0
]
alpha
.
times
=
times
[
i
]
return
c_array
,
x_array
# plot c(x,t) numerical and analytical for given dt
dx
,
L
,
dt
,
tmax
,
D
=
0.0
01
,
1
,
0.001
,
20
,
0.0
1
alpha0
,
tc
=
0.01
,
5
dx
,
L
,
dt
,
tmax
,
D
=
0.0
1
,
1
,
0.01
,
10
,
0.
1
alpha0
,
tc
=
1
,
1
Nx
=
int
(
L
/
dx
)
Nt
=
int
(
tmax
/
dt
)
times
=
np
.
linspace
(
0
,
tmax
,
Nt
+
1
)
x
=
advection_diffusion
(
Nx
,
L
,
Nt
,
tmax
,
D
)[
1
]
# numerical solution
c
=
advection_diffusion
(
Nx
,
L
,
Nt
,
tmax
,
D
)[
0
]
...
...
@@ -66,11 +66,13 @@ c = advection_diffusion(Nx, L, Nt, tmax, D)[0]
c_exact
=
np
.
zeros
((
Nt
+
1
,
Nx
+
1
))
for
j
in
range
(
0
,
len
(
times
)):
if
times
[
j
]
<=
tc
:
# diffusion on moving domain with velocity alpha0*x
alpha
=
alpha0
l
=
L
*
np
.
exp
(
alpha
*
times
[
j
])
beta
=
(
-
D
*
np
.
pi
**
2
/
(
2
*
alpha
*
L
**
2
))
*
(
1
-
np
.
exp
(
-
2
*
alpha
*
times
[
j
]))
c_exact
[
j
]
=
np
.
exp
(
-
alpha
*
times
[
j
])
*
(
1
+
0.2
*
np
.
cos
(
np
.
pi
*
x
[
j
]
/
l
)
*
np
.
exp
(
beta
))
else
:
# diffusion on fixed domain of length L = L0*exp(alpha0 * tc) with initial condition to be the profile at tc
l
=
L
*
np
.
exp
(
alpha0
*
tc
)
beta
=
-
D
*
np
.
pi
**
2
*
times
[
j
]
/
l
**
2
-
np
.
pi
**
2
*
D
/
(
2
*
l
**
2
*
alpha0
)
*
(
1
-
np
.
exp
(
-
2
*
alpha0
*
tc
))
c_exact
[
j
]
=
np
.
exp
(
-
alpha0
*
tc
)
*
(
1
+
0.2
*
np
.
exp
(
beta
)
*
np
.
cos
(
np
.
pi
*
x
[
j
]
/
l
))
...
...
@@ -80,17 +82,17 @@ fig, ax = plt.subplots(1,1,figsize=(8,6))
ax
.
set_xlabel
(
r'$x$'
)
ax
.
set_ylabel
(
r'$c(x,t)$'
)
ax
.
set_xlim
(
np
.
min
(
x
),
np
.
max
(
x
)
+
2
)
ax
.
set_ylim
(
np
.
min
(
c
)
-
1
,
np
.
max
(
c
)
+
1
)
ax
.
set_ylim
(
min
(
np
.
min
(
c
),
np
.
min
(
c_exact
)),
max
(
np
.
max
(
c
),
np
.
max
(
c_exact
))
)
cplot
,
=
ax
.
plot
(
x
[
0
],
c
[
0
],
'--'
,
label
=
'Numerical solution'
)
c_exactplot
,
=
ax
.
plot
(
x
[
0
],
c_exact
[
0
],
label
=
'Exact solution'
)
#
c_exactplot, = ax.plot(x[0], c_exact[0],label = 'Exact solution')
def
update
(
value
):
ti
=
np
.
abs
(
times
-
value
)
.
argmin
()
cplot
.
set_xdata
(
x
[
ti
])
cplot
.
set_ydata
(
c
[
ti
])
c_exactplot
.
set_xdata
(
x
[
ti
])
c_exactplot
.
set_ydata
(
c_exact
[
ti
])
#
c_exactplot.set_xdata(x[ti])
#
c_exactplot.set_ydata(c_exact[ti])
plt
.
draw
()
sax
=
plt
.
axes
([
0.1
,
0.92
,
0.7
,
0.02
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment