Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
fxdgm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Habscheid
fxdgm
Commits
5beeacdf
Commit
5beeacdf
authored
7 months ago
by
Jan Habscheid
Browse files
Options
Downloads
Patches
Plain Diff
Added Convergence test
parent
a7b5ddcc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/Convergence.py
+100
-0
100 additions, 0 deletions
examples/Convergence.py
with
100 additions
and
0 deletions
examples/Convergence.py
0 → 100644
+
100
−
0
View file @
5beeacdf
'''
Jan Habscheid
Jan.Habscheid@rwth-aachen.de
'''
# import the src file needed to solve the system of equations
import
sys
import
os
# Add the src directory to the sys.path
src_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'
..
'
,
'
src
'
)
sys
.
path
.
insert
(
0
,
src_path
)
from
Eq04
import
solve_System_4eq
# Remove the src directory from sys.path after import
del
sys
.
path
[
0
]
# Further imports
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
scipy.interpolate
import
interp1d
# Define the parameters and boundary conditions
z_A
,
z_C
=
-
1.0
,
1.0
y_A_right
,
y_C_right
=
1
/
3
,
1
/
3
phi_left
=
6.0
phi_right
=
0.0
p_right
=
0.0
Lambda2
=
8.553e-6
a2
=
7.5412e-4
K
=
'
incompressible
'
rtol
=
1e-8
# Define grid-sizes
number_cells_vec
=
[
10
,
100
,
1_000
,
10_000
,
100_000
,
1_000_000
]
refinement_style
=
'
uniform
'
y_A
,
y_C
,
y_S
,
phi
,
p
,
x
=
[],
[],
[],
[],
[],
[]
for
number_cells
in
number_cells_vec
:
y_A_
,
y_C_
,
phi_
,
p_
,
x_
=
solve_System_4eq
(
phi_left
,
phi_right
,
p_right
,
z_A
,
z_C
,
y_A_right
,
y_C_right
,
K
,
Lambda2
,
a2
,
number_cells
,
refinement_style
=
refinement_style
,
rtol
=
rtol
,
max_iter
=
1000
,
return_type
=
'
Vector
'
)
y_A
.
append
(
y_A_
)
y_C
.
append
(
y_C_
)
y_S
.
append
(
1
-
y_A_
-
y_C_
)
phi
.
append
(
phi_
)
p
.
append
(
p_
)
x
.
append
(
x_
)
# Interpolate solution vector
y_A_interp1d
=
[
interp1d
(
x
[
i
],
y_A
[
i
])
for
i
in
range
(
len
(
number_cells_vec
))]
y_C_interp1d
=
[
interp1d
(
x
[
i
],
y_C
[
i
])
for
i
in
range
(
len
(
number_cells_vec
))]
y_S_interp1d
=
[
interp1d
(
x
[
i
],
y_S
[
i
])
for
i
in
range
(
len
(
number_cells_vec
))]
phi_interp1d
=
[
interp1d
(
x
[
i
],
phi
[
i
])
for
i
in
range
(
len
(
number_cells_vec
))]
p_interp1d
=
[
interp1d
(
x
[
i
],
p
[
i
])
for
i
in
range
(
len
(
number_cells_vec
))]
# Calculate L2-error
y_A_error_L2
,
y_C_error_L2
,
y_S_error_L2
,
phi_error_L2
,
p_error_L2
=
[],
[],
[],
[],
[]
for
i
in
range
(
len
(
number_cells_vec
)
-
1
):
y_A_error_L2
.
append
(
np
.
trapz
((
y_A_interp1d
[
i
](
x
[
i
])
-
y_A_interp1d
[
-
1
](
x
[
i
]))
**
2
,
x
[
i
]))
y_C_error_L2
.
append
(
np
.
trapz
((
y_C_interp1d
[
i
](
x
[
i
])
-
y_C_interp1d
[
-
1
](
x
[
i
]))
**
2
,
x
[
i
]))
y_S_error_L2
.
append
(
np
.
trapz
((
y_S_interp1d
[
i
](
x
[
i
])
-
y_S_interp1d
[
-
1
](
x
[
i
]))
**
2
,
x
[
i
]))
phi_error_L2
.
append
(
np
.
trapz
((
phi_interp1d
[
i
](
x
[
i
])
-
phi_interp1d
[
-
1
](
x
[
i
]))
**
2
,
x
[
i
]))
p_error_L2
.
append
(
np
.
trapz
((
p_interp1d
[
i
](
x
[
i
])
-
p_interp1d
[
-
1
](
x
[
i
]))
**
2
,
x
[
i
]))
# Log-log plot of L2-error
plt
.
figure
()
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_A_error_L2
,
'
o-
'
,
label
=
'
$y_A$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_C_error_L2
,
'
o-
'
,
label
=
'
$y_C$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_S_error_L2
,
'
o-
'
,
label
=
'
$y_S$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
phi_error_L2
,
'
o-
'
,
label
=
'
$
\\
varphi$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
p_error_L2
,
'
o-
'
,
label
=
'
$p$
'
)
plt
.
legend
()
plt
.
xlabel
(
'
log(nx)
'
)
plt
.
ylabel
(
'
log($L_2$)
'
)
plt
.
grid
()
plt
.
tight_layout
()
plt
.
show
()
# Calculate infinity error
y_A_error_inf
,
y_C_error_inf
,
y_S_error_inf
,
phi_error_inf
,
p_error_inf
=
[],
[],
[],
[],
[]
for
i
in
range
(
len
(
number_cells_vec
)
-
1
):
y_A_error_inf
.
append
(
np
.
max
(
np
.
abs
(
y_A_interp1d
[
i
](
x
[
i
])
-
y_A_interp1d
[
-
1
](
x
[
i
]))))
y_C_error_inf
.
append
(
np
.
max
(
np
.
abs
(
y_C_interp1d
[
i
](
x
[
i
])
-
y_C_interp1d
[
-
1
](
x
[
i
]))))
y_S_error_inf
.
append
(
np
.
max
(
np
.
abs
(
y_S_interp1d
[
i
](
x
[
i
])
-
y_S_interp1d
[
-
1
](
x
[
i
]))))
phi_error_inf
.
append
(
np
.
max
(
np
.
abs
(
phi_interp1d
[
i
](
x
[
i
])
-
phi_interp1d
[
-
1
](
x
[
i
]))))
p_error_inf
.
append
(
np
.
max
(
np
.
abs
(
p_interp1d
[
i
](
x
[
i
])
-
p_interp1d
[
-
1
](
x
[
i
]))))
# Log-log plot of infinity error
plt
.
figure
()
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_A_error_inf
,
'
o-
'
,
label
=
'
$y_A$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_C_error_inf
,
'
o-
'
,
label
=
'
$y_C$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
y_S_error_inf
,
'
o-
'
,
label
=
'
$y_S$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
phi_error_inf
,
'
o-
'
,
label
=
'
$
\\
varphi$
'
)
plt
.
loglog
(
number_cells_vec
[:
-
1
],
p_error_inf
,
'
o-
'
,
label
=
'
$p$
'
)
plt
.
legend
()
plt
.
xlabel
(
'
log(nx)
'
)
plt
.
ylabel
(
'
log($L_\infty$)
'
)
plt
.
grid
()
plt
.
tight_layout
()
plt
.
show
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment