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
ceefbb2e
authored
Sep 26, 2022
by
Jigyasa Watwani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nx larger
parent
c6647133
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
euler_error/diffusion_fixed_domain_euler_errors.py
euler_error/diffusion_fixed_domain_euler_errors.py
View file @
ceefbb2e
...
...
@@ -44,8 +44,8 @@ def advection_diffusion(Nx, L, Nt, tmax, D):
return
c_array
# parameters
Nx
,
L
,
D
,
tmax
=
32
,
1
,
0.1
,
0.25
nt_array
=
np
.
array
([
5
,
10
,
15
,
20
,
25
,
50
,
100
,
200
,
400
,
800
,
1600
])
Nx
,
L
,
D
,
tmax
=
256
,
1
,
0.1
,
0.25
nt_array
=
np
.
array
([
2
,
3
,
4
,
5
,
10
,
15
,
20
,
25
,
50
,
100
,
200
,
400
,
800
,
1600
])
dt_array
=
tmax
/
nt_array
mesh
=
df
.
IntervalMesh
(
Nx
,
0
,
L
)
x
=
mesh
.
coordinates
()[:,
0
]
...
...
@@ -63,7 +63,7 @@ for i in range(0, len(nt_array)):
c
=
advection_diffusion
(
Nx
,
L
,
nt_array
[
i
],
tmax
,
D
)
error
[
i
]
=
np
.
max
(
np
.
abs
(
c
[
-
1
]
-
c_exact
[
-
1
]))
print
(
'dt,t,error='
,
tmax
/
400
,
tmax
,
error
[
-
3
])
print
(
'dt,t,error='
,
tmax
/
800
,
tmax
,
error
[
-
2
])
popt
,
pcov
=
curve_fit
(
linear_func
,
np
.
log
(
dt_array
),
np
.
log
(
error
))
print
(
'The slope of the graph of log(error) vs log(dt) is'
,
popt
[
0
])
fig
,
ax
=
plt
.
subplots
(
1
)
...
...
@@ -72,3 +72,6 @@ ax.loglog(dt_array, error, 'bo')
ax
.
set_xlabel
(
'log(dt)'
)
ax
.
set_ylabel
(
'log(error)'
)
plt
.
show
()
# |u_{exact} - u_{Nt}| < |u_{exact} - u_{Nx}| + |u_{Nx} - u_{Nt}| + floating point errors
# to get the correct error in time, ensure first term small. That can be done by taking Nx large enough
\ No newline at end of file
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