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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Laura Christine Kühle
Troubled Cell Detection
Commits
26a9a147
Commit
26a9a147
authored
May 20, 2020
by
Laura Christine Kühle
Browse files
Options
Downloads
Patches
Plain Diff
Upload Initial_Condition.py (as of March 16 2020)
parent
3e74bd0d
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Initial_Condition.py
+142
-0
142 additions, 0 deletions
Initial_Condition.py
with
142 additions
and
0 deletions
Initial_Condition.py
0 → 100644
+
142
−
0
View file @
26a9a147
# -*- coding: utf-8 -*-
"""
@author: Laura C. Kühle
TODO: Rename initial conditions -> Renamed returned names
"""
import
numpy
as
np
class
InitialCondition
(
object
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
self
.
left_bound
=
left_bound
self
.
right_bound
=
right_bound
self
.
interval_len
=
self
.
right_bound
-
self
.
left_bound
pass
def
get_name
(
self
):
return
self
.
function_name
def
calculate
(
self
,
x
):
while
(
x
<
self
.
left_bound
):
x
=
x
+
self
.
interval_len
while
(
x
>
self
.
right_bound
):
x
=
x
-
self
.
interval_len
return
self
.
_get_point
(
x
)
def
_get_point
(
self
,
x
):
pass
class
InitialCondition1
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
Sine
'
self
.
factor
=
config
.
pop
(
'
factor
'
,
2
)
pass
def
_get_point
(
self
,
x
):
return
np
.
sin
(
self
.
factor
*
np
.
pi
*
x
)
class
InitialCondition2
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
Box
'
pass
def
_get_point
(
self
,
x
):
if
(
x
<
-
1
):
x
=
x
+
2
if
(
x
>
1
):
x
=
x
-
2
if
((
x
>=
-
0.5
)
&
(
x
<=
0.5
)):
return
1
else
:
return
0
class
InitialCondition3
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
FourMixedTypes
'
self
.
alpha
=
10
self
.
delta
=
0.005
self
.
beta
=
np
.
log
(
2
)
/
(
36
*
self
.
delta
**
2
)
self
.
a
=
0.5
self
.
z
=
-
0.7
pass
def
_get_point
(
self
,
x
):
if
((
x
>=
-
0.8
)
&
(
x
<=
-
0.6
)):
return
1
/
6
*
(
self
.
_G
(
x
,
self
.
z
-
self
.
delta
)
+
self
.
_G
(
x
,
self
.
z
+
self
.
delta
)
+
4
*
self
.
_G
(
x
,
self
.
z
))
if
((
x
>=
-
0.4
)
&
(
x
<=
-
0.2
)):
return
1
if
((
x
>=
0
)
&
(
x
<=
0.2
)):
return
1
-
abs
(
10
*
(
x
-
0.1
))
if
((
x
>=
0.4
)
&
(
x
<=
0.6
)):
return
1
/
6
*
(
self
.
_F
(
x
,
self
.
a
-
self
.
delta
)
+
self
.
_F
(
x
,
self
.
a
+
self
.
delta
)
+
4
*
self
.
_F
(
x
,
self
.
a
))
return
0
def
_G
(
self
,
x
,
z
):
return
np
.
exp
(
-
self
.
beta
*
(
x
-
z
)
**
2
)
def
_F
(
self
,
x
,
a
):
return
np
.
sqrt
(
max
(
1
-
self
.
alpha
**
2
*
(
x
-
a
)
**
2
,
0
))
class
InitialCondition4
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
Linear
'
self
.
factor
=
config
.
pop
(
'
factor
'
,
1
)
pass
def
_get_point
(
self
,
x
):
return
self
.
factor
*
x
class
InitialCondition5
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
LinearAbsolut
'
self
.
factor
=
config
.
pop
(
'
factor
'
,
1
)
pass
def
_get_point
(
self
,
x
):
return
self
.
factor
*
abs
(
x
)
class
InitialCondition6
(
InitialCondition
):
def
__init__
(
self
,
left_bound
,
right_bound
,
config
):
super
().
__init__
(
left_bound
,
right_bound
,
config
)
# Set name of function
self
.
function_name
=
'
ConstantWithDiscontinuity
'
self
.
x0
=
config
.
pop
(
'
x0
'
,
0
)
self
.
left_factor
=
config
.
pop
(
'
left_factor
'
,
1
)
self
.
right_factor
=
config
.
pop
(
'
right_factor
'
,
0.5
)
pass
def
_get_point
(
self
,
x
):
return
self
.
left_factor
*
(
x
<=
self
.
x0
)
\
+
self
.
right_factor
*
(
x
>
self
.
x0
)
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
sign in
to comment