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
a7a203bf
authored
Aug 30, 2022
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
with the correct exact solution
parent
926941c1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
euler_error/euler_error_moving_domain_diffusion_advection.py
euler_error/euler_error_moving_domain_diffusion_advection.py
View file @
a7a203bf
...
@@ -18,15 +18,16 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
...
@@ -18,15 +18,16 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
times
=
np
.
linspace
(
0
,
tmax
,
Nt
+
1
)
times
=
np
.
linspace
(
0
,
tmax
,
Nt
+
1
)
dt
=
times
[
1
]
-
times
[
0
]
dt
=
times
[
1
]
-
times
[
0
]
c0
=
df
.
interpolate
(
df
.
Expression
(
'1 + 0.2*cos(pi*x[0]/L)'
,
pi
=
np
.
pi
,
L
=
L
,
degree
=
1
),
function_space
)
c0
=
df
.
interpolate
(
df
.
Expression
(
'1 + 0.2*cos(pi*x[0]/L)'
,
pi
=
np
.
pi
,
L
=
L
,
degree
=
1
),
function_space
)
# form
# form
u
=
df
.
interpolate
(
v
,
function_space
)
u
=
df
.
interpolate
(
v
,
function_space
)
form
=
(
df
.
inner
((
c
-
c0
)
/
dt
,
tc
)
+
df
.
inner
((
u
*
c
)
.
dx
(
0
),
tc
)
+
D
*
df
.
inner
(
tc
.
dx
(
0
),
c
.
dx
(
0
)))
*
df
.
dx
(
mesh
)
for
_
in
progressbar
.
progressbar
(
range
(
1
,
len
(
times
)
+
1
)):
form
=
(
df
.
inner
((
c
-
c0
)
/
dt
,
tc
)
+
df
.
inner
((
u
*
c
)
.
dx
(
0
),
tc
)
+
D
*
df
.
inner
(
tc
.
dx
(
0
),
c
.
dx
(
0
)))
*
df
.
dx
(
mesh
)
for
_
in
progressbar
.
progressbar
(
range
(
1
,
len
(
times
))):
df
.
solve
(
form
==
0
,
c
)
df
.
solve
(
form
==
0
,
c
)
df
.
ALE
.
move
(
mesh
,
df
.
Expression
(
'v*dt'
,
v
=
v
,
dt
=
dt
,
degree
=
1
))
df
.
ALE
.
move
(
mesh
,
df
.
Expression
(
'v*dt'
,
v
=
v
,
dt
=
dt
,
degree
=
1
))
x
=
mesh
.
coordinates
()
x
=
mesh
.
coordinates
()
...
@@ -36,16 +37,22 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
...
@@ -36,16 +37,22 @@ def advection_diffusion(Nx, L, Nt, tmax, v, D):
Nx
,
L
,
tmax
,
D
,
k
=
2000
,
1
,
1
,
1
,
1
Nx
,
L
,
tmax
,
D
,
k
=
2000
,
1
,
1
,
1
,
1
v
=
df
.
Expression
(
'k*x[0]'
,
k
=
k
,
degree
=
1
)
v
=
df
.
Expression
(
'k*x[0]'
,
k
=
k
,
degree
=
1
)
nt_array
=
np
.
array
([
50
,
100
,
200
,
400
,
800
])
nt_array
=
np
.
array
([
50
,
100
,
200
,
400
,
800
,
1600
,
3200
,
6400
,
12800
])
# , 1600, 3200, 6400, 12800])
dt_array
=
tmax
/
(
nt_array
-
1
)
dt_array
=
tmax
/
(
nt_array
-
1
)
error_in_c
=
np
.
zeros
(
len
(
nt_array
))
error_in_c
=
np
.
zeros
(
len
(
nt_array
))
for
i
in
range
(
len
(
nt_array
)):
for
i
in
range
(
len
(
nt_array
)):
x
=
advection_diffusion
(
Nx
,
L
,
nt_array
[
i
],
tmax
,
v
,
D
)[
-
1
]
x
=
advection_diffusion
(
Nx
,
L
,
nt_array
[
i
],
tmax
,
v
,
D
)[
-
1
]
ss_c_exact
=
2
*
np
.
exp
(
-
k
*
tmax
)
*
(
1
+
0.2
*
np
.
cos
(
np
.
pi
*
x
*
np
.
exp
(
-
k
*
tmax
))
*
np
.
exp
(
-
np
.
pi
**
2
*
(
D
/
(
2
*
k
))
*
(
1
-
np
.
exp
(
-
2
*
k
*
tmax
))))
ss_c
=
advection_diffusion
(
Nx
,
L
,
nt_array
[
i
],
tmax
,
v
,
D
)[
0
]
ss_c
=
advection_diffusion
(
Nx
,
L
,
nt_array
[
i
],
tmax
,
v
,
D
)[
0
]
xprime
=
x
/
(
L
*
np
.
exp
(
k
*
tmax
))
tprime
=
(
D
/
(
2
*
k
*
L
**
2
))
*
(
1
-
np
.
exp
(
-
2
*
k
*
tmax
))
int
=
np
.
exp
(
-
k
*
tmax
)
ss_c_exact
=
int
*
(
1
+
0.2
*
np
.
cos
(
np
.
pi
*
xprime
)
*
np
.
exp
(
-
np
.
pi
**
2
*
tprime
))
error_in_c
[
i
]
=
np
.
max
(
np
.
abs
(
ss_c
-
ss_c_exact
))
error_in_c
[
i
]
=
np
.
max
(
np
.
abs
(
ss_c
-
ss_c_exact
))
plt
.
scatter
(
dt_array
,
error_in_c
)
plt
.
scatter
(
dt_array
,
error_in_c
)
plt
.
show
()
plt
.
show
()
# bug: tmax = 1 -- trend ok, not for any other tmax
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