Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iRMB
VirtualFluids
Commits
6e03e315
Commit
6e03e315
authored
4 years ago
by
Sven Marcus
Browse files
Options
Downloads
Patches
Plain Diff
Refactor l2 norm test
parent
65876888
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!6
Proper Python simulation tests
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Python/poiseuille/test_poiseuille_l2.py
+18
-34
18 additions, 34 deletions
Python/poiseuille/test_poiseuille_l2.py
with
18 additions
and
34 deletions
Python/poiseuille/test_poiseuille_l2.py
+
18
−
34
View file @
6e03e315
import
shutil
import
unittest
import
math
import
pyvista
as
pv
import
matplotlib.pyplot
as
plt
import
pyvista
as
pv
from
pyfluids.parameters
import
GridParameters
,
PhysicalParameters
,
RuntimeParameters
from
norms
import
root_mean_squared_error
,
l2_norm_error
from
norms
import
l2_norm_error
from
poiseuille.analytical
import
poiseuille_at_heights
,
PoiseuilleSettings
from
poiseuille.simulation
import
run_simulation
from
vtk_utilities
import
vertical_column_from_mesh
,
get_values_from_indices
...
...
@@ -20,47 +18,33 @@ class TestPoiseuilleFlow(unittest.TestCase):
WHEN comparing the simulation results to the analytical solution THEN the L2-Norm should be less than 1e-4
"""
# self.skipTest("Skipping test! This test is not implemented correctly")
plt
.
ion
()
channel_height
=
10
number_of_nodes
=
[
8
,
16
,
32
]
number_of_timesteps
=
[
10_000
,
20_000
,
40_000
]
viscosities
=
[
5e-3
,
1e-2
,
2e-2
]
l2_norm_results
=
[]
physical_params
=
PhysicalParameters
()
physical_params
.
lattice_viscosity
=
0.005
runtime_params
=
RuntimeParameters
()
runtime_params
.
number_of_threads
=
4
runtime_params
.
timestep_log_interval
=
1000
runtime_params
.
number_of_timesteps
=
10000
nodes_in_column
=
8
grid_params
=
create_grid_params_with_nodes_in_column
(
nodes_in_column
,
delta_x
=
channel_height
/
nodes_in_column
)
l2_norm_result_100
=
get_l2_norm_for_simulation
(
grid_params
,
physical_params
,
runtime_params
)
runtime_params
.
number_of_timesteps
*=
2
physical_params
.
lattice_viscosity
*=
2
nodes_in_column
*=
2
grid_params
=
create_grid_params_with_nodes_in_column
(
nodes_in_column
,
delta_x
=
channel_height
/
nodes_in_column
)
l2_norm_result_200
=
get_l2_norm_for_simulation
(
grid_params
,
physical_params
,
runtime_params
)
runtime_params
.
number_of_timesteps
*=
12
physical_params
.
lattice_viscosity
*=
2
nodes_in_column
*=
2
grid_params
=
create_grid_params_with_nodes_in_column
(
nodes_in_column
,
delta_x
=
channel_height
/
nodes_in_column
)
l2_norm_result_400
=
get_l2_norm_for_simulation
(
grid_params
,
physical_params
,
runtime_params
)
nodes
=
[
8
,
16
,
32
]
l2_results
=
[
l2_norm_result_100
,
l2_norm_result_200
,
l2_norm_result_400
]
plt
.
plot
(
nodes
,
l2_results
)
plt
.
show
()
self
.
assertTrue
(
l2_norm_result_200
<=
l2_norm_result_100
)
self
.
assertTrue
(
l2_norm_result_400
<=
l2_norm_result_200
)
for
test_number
,
nodes_in_column
in
enumerate
(
number_of_nodes
):
runtime_params
.
number_of_timesteps
=
number_of_timesteps
[
test_number
]
physical_params
.
lattice_viscosity
=
viscosities
[
test_number
]
delta_x
=
channel_height
/
nodes_in_column
grid_params
=
create_grid_params_with_nodes_in_column
(
nodes_in_column
,
delta_x
)
l2_norm_result
=
get_l2_norm_for_simulation
(
grid_params
,
physical_params
,
runtime_params
)
l2_norm_results
.
append
(
l2_norm_result
)
plt
.
plot
(
number_of_nodes
,
l2_norm_results
)
plt
.
show
()
def
get_delta_x
(
number_of_nodes
,
height
):
return
height
/
number_of_nodes
self
.
assertTrue
(
l2_norm_results
[
1
]
<=
l2_norm_results
[
0
])
self
.
assertTrue
(
l2_norm_results
[
2
]
<=
l2_norm_results
[
1
])
def
run_simulation_with_settings
(
grid_params
,
physical_params
,
runtime_params
,
output_folder
):
...
...
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