Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Troubled Cell Detection
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
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
52ac1084
Commit
52ac1084
authored
2 years ago
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Added derivative basis to Basis class.
parent
749be65c
No related branches found
No related tags found
Loading
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Snakefile
+1
-0
1 addition, 0 deletions
Snakefile
scripts/tcd/Basis_Function.py
+94
-0
94 additions, 0 deletions
scripts/tcd/Basis_Function.py
with
95 additions
and
0 deletions
Snakefile
+
1
−
0
View file @
52ac1084
...
@@ -29,6 +29,7 @@ TODO: ASk whether cfl number should be absolute value
...
@@ -29,6 +29,7 @@ TODO: ASk whether cfl number should be absolute value
Urgent:
Urgent:
TODO: Add Burgers class completely
TODO: Add Burgers class completely
TODO: Add 'update_time_step()' to Burgers -> Done
TODO: Add 'update_time_step()' to Burgers -> Done
TODO: Add derivative basis to Basis class -> Done
TODO: Add 'solve_exactly()' to Burgers
TODO: Add 'solve_exactly()' to Burgers
TODO: Add 'update_right_hand_side()' to Burgers
TODO: Add 'update_right_hand_side()' to Burgers
TODO: Add initialization to Burgers
TODO: Add initialization to Burgers
...
...
This diff is collapsed.
Click to expand it.
scripts/tcd/Basis_Function.py
+
94
−
0
View file @
52ac1084
...
@@ -28,6 +28,8 @@ class Basis(ABC):
...
@@ -28,6 +28,8 @@ class Basis(ABC):
Array of basis.
Array of basis.
wavelet : ndarray
wavelet : ndarray
Array of wavelet.
Array of wavelet.
derivative: ndarray
Array of derivative basis.
inv_mass : ndarray
inv_mass : ndarray
Inverse mass matrix.
Inverse mass matrix.
basis_projection : Tuple[ndarray, ndarray]
basis_projection : Tuple[ndarray, ndarray]
...
@@ -111,6 +113,29 @@ class Basis(ABC):
...
@@ -111,6 +113,29 @@ class Basis(ABC):
"""
"""
pass
pass
@property
@cache
def
derivative
(
self
)
->
ndarray
:
"""
Return derivative basis vector.
"""
return
self
.
_build_derivative_vector
(
x
)
@abstractmethod
def
_build_derivative_vector
(
self
,
eval_point
:
float
)
->
ndarray
:
"""
Construct derivative basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
ndarray
Vector containing derivative basis evaluated at evaluation point.
"""
pass
@property
@property
@cache
@cache
def
inverse_mass_matrix
(
self
)
->
ndarray
:
def
inverse_mass_matrix
(
self
)
->
ndarray
:
...
@@ -261,6 +286,55 @@ class Legendre(Basis):
...
@@ -261,6 +286,55 @@ class Legendre(Basis):
vector
.
append
(
poly
)
vector
.
append
(
poly
)
return
np
.
array
(
vector
)
return
np
.
array
(
vector
)
def
_build_derivative_vector
(
self
,
eval_point
:
float
)
->
ndarray
:
"""
Construct derivative basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
ndarray
Vector containing derivative basis evaluated at evaluation point.
"""
return
self
.
_calculate_derivative_legendre_vector
(
eval_point
)
def
_calculate_derivative_legendre_vector
(
self
,
eval_point
:
float
)
->
ndarray
:
"""
Construct derivative Legendre vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
ndarray
Vector containing derivative Legendre polynomial evaluated at
evaluation point.
"""
derivative_vector
=
[]
leg_vector
=
self
.
_calculate_legendre_vector
(
eval_point
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
):
if
degree
==
0
:
derivative_vector
.
append
(
0
*
eval_point
)
else
:
if
degree
==
1
:
derivative_vector
.
append
(
1.0
+
0
*
eval_point
)
else
:
poly
=
((
2.0
*
degree
-
1
)
/
degree
)
*
(
leg_vector
[
degree
-
1
]
+
(
eval_point
*
derivative_vector
[
-
1
]))
-
(
(
degree
-
1
)
/
degree
)
*
\
derivative_vector
[
-
2
]
derivative_vector
.
append
(
poly
)
return
np
.
array
(
derivative_vector
)
class
OrthonormalLegendre
(
Legendre
):
class
OrthonormalLegendre
(
Legendre
):
"""
Class for orthonormal Legendre basis.
"""
"""
Class for orthonormal Legendre basis.
"""
...
@@ -348,6 +422,26 @@ class OrthonormalLegendre(Legendre):
...
@@ -348,6 +422,26 @@ class OrthonormalLegendre(Legendre):
raise
ValueError
(
'
Invalid value: Alpert
\'
s wavelet is only available
\
raise
ValueError
(
'
Invalid value: Alpert
\'
s wavelet is only available
\
up to degree 4 for this application
'
)
up to degree 4 for this application
'
)
def
_build_derivative_basis_vector
(
self
,
eval_point
):
"""
Construct derivative basis vector.
Parameters
----------
eval_point : float
Evaluation point.
Returns
-------
ndarray
Vector containing derivative Legendre polynomial evaluated at
evaluation point.
"""
derivative_leg_vector
=
self
.
_calculate_derivative_legendre_vector
(
eval_point
)
return
np
.
array
([
derivative_leg_vector
[
degree
]
*
np
.
sqrt
(
degree
+
0.5
)
for
degree
in
range
(
self
.
_polynomial_degree
+
1
)])
def
_build_inverse_mass_matrix
(
self
)
->
ndarray
:
def
_build_inverse_mass_matrix
(
self
)
->
ndarray
:
"""
Construct inverse mass matrix.
"""
Construct inverse mass matrix.
...
...
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