Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Geodynamik-Übungen
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
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Wegener, Johannes
Geodynamik-Übungen
Commits
e40ac829
Commit
e40ac829
authored
3 years ago
by
Wegener, Johannes
Browse files
Options
Downloads
Patches
Plain Diff
explicit and implicit
parent
efd34843
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
AdamsWilliamson.py
+19
-8
19 additions, 8 deletions
AdamsWilliamson.py
AdamsWilliamsonCMB.py
+42
-13
42 additions, 13 deletions
AdamsWilliamsonCMB.py
with
61 additions
and
21 deletions
AdamsWilliamson.py
+
19
−
8
View file @
e40ac829
from
cmath
import
pi
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
csv
...
...
@@ -23,20 +24,20 @@ def read_data(file):
return
np
.
column_stack
([
depth
]),
np
.
column_stack
([
rho
]),
np
.
column_stack
([
vp
]),
np
.
column_stack
([
vs
])
def
mass
(
r
,
rho_
r
):
def
mass
(
r
ho
,
r
):
'''
Calculates mass of earth inside sphere of radius r.
'''
return
(
4
/
3
)
*
np
.
pi
*
rho
_r
*
r
**
3
return
(
4
/
3
)
*
pi
*
rho
*
r
**
3
# Berechnung der Dichte
def
density_expansion
(
rho
,
vp
,
vs
,
r
1
,
r2
):
def
density_expansion
(
rho
_old
,
vp
,
vs
,
r
_new
,
r_old
):
'''
Returns Euler approximation for rho at r2.
Method:
rho(r+h) = rho(r) + h*d(rho)/dr(r)
'''
G
=
6.67
*
10
**
(
-
11
)
# Gravitationskonstante
phi
=
vp
**
2
-
(
4
/
3
)
*
vs
**
2
rho_
r
=
rho
+
(
r
2
-
r1
)
*
(
-
G
*
mass
(
r
1
,
rho
)
*
rho
/
(
r
1
**
2
*
phi
))
return
rho_
r
rho_
new
=
rho
_old
+
(
r
_new
-
r_old
)
*
(
-
G
*
mass
(
r
_old
,
rho
_old
)
*
rho
_old
/
(
r
_old
**
2
*
phi
))
return
rho_
new
file
=
os
.
getcwd
()
+
r
"
\VpVs-valuesak135.csv
"
...
...
@@ -52,13 +53,23 @@ rho_0 = 3000 # kg/m^3
M_0
=
5.973
*
10
**
24
# Masse in 18km Tiefe
rho
=
np
.
zeros
(
len
(
density
))
rho
[
8
]
=
rho_0
rho
[
:
9
]
=
rho_0
for
i
in
range
(
9
,
len
(
rho
)):
rho
[
i
]
=
density_expansion
(
rho
[
i
-
1
],
vp
[
i
-
1
],
vs
[
i
-
1
],
r
[
i
-
1
],
r
[
i
])
rho
[
i
]
=
density_expansion
(
rho
[
i
-
1
],
vp
[
i
-
1
],
vs
[
i
-
1
],
r
[
i
],
r
[
i
-
1
])
print
(
rho
)
def
corrected_mass
(
rho
,
r
):
res
=
0
for
i
in
range
(
len
(
rho
)):
res
+=
(
4
/
3
)
*
pi
*
rho
[
i
]
*
(
r
[
i
]
**
3
-
r
[
i
-
1
]
**
3
)
return
res
print
(
corrected_mass
(
rho
,
r
))
plt
.
plot
(
rho
,
r
)
plt
.
plot
(
density
,
r
)
plt
.
show
()
# Berechnung von rho und M für jede Schicht
# for i in range(8, len(rho) - 1): # Die ersten Werte werden weg gelassen
...
...
This diff is collapsed.
Click to expand it.
AdamsWilliamsonCMB.py
+
42
−
13
View file @
e40ac829
from
cmath
import
pi
import
numpy
as
np
import
matplotlib.pyplot
as
plt
import
csv
...
...
@@ -25,13 +26,11 @@ def read_data(file):
def
mass
(
r
,
rho_r
):
'''
Calculates mass of earth inside sphere of radius r.
'''
mass
=
(
4
/
3
)
*
np
.
pi
*
rho_r
*
r
**
3
return
mass
return
(
4
/
3
)
*
np
.
pi
*
rho_r
*
r
**
3
# Berechnung der Dichte
def
density_expansion
(
rho
,
vp
,
vs
,
r1
,
r2
):
'''
Returns Euler approximation for rho at r2.
def
density_expansion_explicit
(
rho
,
vp
,
vs
,
r1
,
r2
):
'''
Returns explicit Euler approximation for rho at r2.
Method:
rho(r+h) = rho(r) + h*d(rho)/dr(r)
'''
G
=
6.67
*
10
**
(
-
11
)
# Gravitationskonstante
...
...
@@ -40,6 +39,23 @@ def density_expansion(rho, vp, vs, r1, r2):
return
rho_r
def
density_expansion_implicit
(
rho
,
vp
,
vs
,
r1
,
r2
):
'''
Returns implicit Euler approximation (Heun method) for rho at r2.
Method:
rho(r+h) = rho(r) + h*d(rho)/dr(r+1) with d(rho)/dr(r+1) = d(rho)/dr(rho(r) + h*d(rho)/dr(r))
'''
G
=
6.67
*
10
**
(
-
11
)
# Gravitationskonstante
phi
=
vp
**
2
-
(
4
/
3
)
*
vs
**
2
rho_r
=
rho
+
(
r2
-
r1
)
*
(
-
G
*
mass
(
r2
,
density_expansion_explicit
(
rho
,
vp
,
vs
,
r1
,
r2
))
*
density_expansion_explicit
(
rho
,
vp
,
vs
,
r1
,
r2
)
/
(
r1
**
2
*
phi
))
return
rho_r
def
mass_correction
(
rho
,
r
):
res
=
0
for
i
in
range
(
1
,
len
(
r
)):
res
+=
(
4
/
3
)
*
pi
*
rho
[
i
]
*
-
(
r
[
i
]
**
3
-
r
[
i
-
1
]
**
3
)
return
res
file
=
os
.
getcwd
()
+
r
"
\VpVs-valuesak135.csv
"
# Einlesen der Daten
...
...
@@ -52,20 +68,33 @@ r = 6371 - depth
rho_0
=
3000
# kg/m^3
M_0
=
5.973
*
10
**
24
# Masse in 18km Tiefe
rho
=
np
.
zeros
(
len
(
density
))
rho_ex
=
np
.
zeros
(
len
(
density
))
rho_im
=
np
.
zeros
(
len
(
density
))
masse
=
np
.
zeros
(
len
(
density
))
masse
[
8
]
=
M_0
rho
[
8
]
=
rho_0
rho_ex
[
8
]
=
rho_0
rho_im
[
8
]
=
rho_0
for
i
in
range
(
9
,
len
(
rho
)):
for
i
in
range
(
9
,
len
(
rho
_ex
)):
if
depth
[
i
]
==
2891.5
:
rho
[
i
]
=
9400
rho_ex
[
i
]
=
9900
rho_im
[
i
]
=
9900
else
:
rho
[
i
]
=
density_expansion
(
rho
[
i
-
1
],
vp
[
i
-
1
],
vs
[
i
-
1
],
r
[
i
-
1
],
r
[
i
])
masse
[
i
]
=
mass
(
r
[
i
-
1
],
rho
[
i
-
1
])
rho_ex
[
i
]
=
density_expansion_explicit
(
rho_ex
[
i
-
1
],
vp
[
i
-
1
],
vs
[
i
-
1
],
r
[
i
-
1
],
r
[
i
])
rho_im
[
i
]
=
density_expansion_implicit
(
rho_im
[
i
-
1
],
vp
[
i
-
1
],
vs
[
i
-
1
],
r
[
i
-
1
],
r
[
i
])
masse
[
i
]
=
mass
(
r
[
i
-
1
],
rho_ex
[
i
-
1
])
print
(
"
Earth mass explicit:
"
,
mass_correction
(
rho_ex
,
r
))
print
(
"
Earth mass implicit:
"
,
mass_correction
(
rho_im
,
r
))
print
(
"
Earth mass exact:
"
,
mass_correction
(
density
,
r
))
print
(
rho
)
print
(
masse
)
plt
.
plot
(
depth
,
rho_ex
)
plt
.
plot
(
depth
,
rho_im
)
plt
.
plot
(
depth
,
density
)
plt
.
legend
([
"
ex
"
,
"
im
"
,
"
exact
"
])
plt
.
show
()
# Berechnung von rho und M für jede Schicht
# for i in range(8, len(rho) - 1): # Die ersten Werte werden weg gelassen
...
...
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