forked from MarkWieczorek/ctplanet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCore-Moon.py
executable file
·234 lines (185 loc) · 9.1 KB
/
Core-Moon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#!/usr/bin/env python3
"""
Calculate the hydrostatic shape of the core of the Moon.
"""
import numpy as np
import pyshtools
from Hydrostatic import HydrostaticShapeLith
from Hydrostatic import HydrostaticShape
from InertiaTensor import InertiaTensor_from_shape
# ==== MAIN FUNCTION ====
def main():
lmax = 20
lmax_grid = 719
omega = pyshtools.constant.omega_moon.value
rem = pyshtools.constant.a_orbit_moon.value
mass_earth = pyshtools.constant.mass_egm2008.value
cthick = 34.e3 # 43.e3 or 34.0e3
rho_crust = 2550.
out_rc_fc = "figs/rc_fc_34_2550.dat"
out_rc_rhoc = "figs/rc_rhoc_34_2550.dat"
out_rc_beta = "figs/rc_beta_34_2550.dat"
sh_core = "figs/core_34.sh"
core_shape_wo_d1 = "figs/core_shape_wo_d1_330_34.dat"
core_shape = "figs/core_shape_330_34.dat"
rcore_int = 1.e3
rcore_start = 250.e3
rcore_end = 450.e3
rhocore_start = 5000.
rhocore_end = 8000.
rhocore_int = 1.
pot_file = 'Data/JGGRAIL_900C11A_SHA.TAB'
topo_file = 'Data/LOLA1500p.sh'
potential = pyshtools.SHGravCoeffs.from_file(pot_file, header_units='km')
topo = pyshtools.SHCoeffs.from_file(topo_file, lmax=900)
r0 = topo.coeffs[0, 0, 0]
r_sigma = r0 - cthick
ismr2 = 0.3927280 # Williams et al. (2014)
ismr2 = ismr2 * (1738.e3 / r0)**2
print("Mean planetary radius (km) = {:e}".format(r0 / 1.e3))
print("Is/MR2 (solid Moon using mean radius) = {:e}".format(ismr2))
print("Lmax of Gravitational potential = {:d}".format(potential.lmax))
print("Reference radius of potential model (km) = {:e}"
.format(potential.r0/1.e3))
print("GM = {:e}".format(potential.gm))
mass = potential.gm / pyshtools.constant.G.value
print("Mass (kg) = {:e}".format(mass))
print("Omega = {:e}".format(omega))
print("Period (days) = {:e}".format(2. * np.pi / omega / 60. / 60. / 24.))
print("Average crustal thickness (km) = {:e}".format(cthick / 1.e3))
print("Crustal density (kg/m3) = {:e}".format(rho_crust))
radius = np.zeros(4)
radius[0] = 0.
radius[2] = r0 - cthick
radius[3] = r0
rho = np.zeros(4)
rho[2] = rho_crust
mass_crust = 4. * np.pi / 3. * rho_crust * (radius[3]**3 - radius[2]**3)
n = 3
i_lith = 2
i_core = 1
# For each core radius, find rho_mantle and rho_core that fit total mass
# and moment of inertia
f_rc_fc = open(out_rc_fc, 'w')
f_rc_rhoc = open(out_rc_rhoc, 'w')
f_rc_beta = open(out_rc_beta, 'w')
for r_core in np.arange(rcore_start, rcore_end + rcore_int, rcore_int,
dtype=float):
radius[1] = r_core
first = True
for rho_core in np.arange(rhocore_start, rhocore_end + rhocore_int,
rhocore_int, dtype=float):
mass_core = 4. * np.pi / 3. * rho_core * r_core**3
mass_mantle = mass - mass_crust - mass_core
rho_mantle = mass_mantle * 3. / np.pi / 4. / (radius[2]**3 -
r_core**3)
rho[0] = rho_core
rho[1] = rho_mantle
if rho_mantle >= rho_core:
continue
ismr2_model = moi_solid(radius, rho, n)
if first is True:
diff_old = ismr2 - ismr2_model
first = False
else:
diff_new = ismr2 - ismr2_model
if diff_new * diff_old <= 0.:
# interpolate to get the best fitting core density
rho_core_final = (rho_core - rhocore_int) - diff_old * \
(rhocore_int) / (diff_new - diff_old)
rho[0] = rho_core_final
mass_core = 4. * np.pi / 3. * rho[0] * r_core**3
mass_mantle = mass - mass_crust - mass_core
rho_mantle = mass_mantle * 3. / np.pi / 4. / \
(radius[2]**3 - r_core**3)
rho[1] = rho_mantle
hlm, clm_hydro, mass_model = \
HydrostaticShapeLith(radius, rho, i_lith,
potential, topo, rho_crust,
r_sigma, omega, lmax,
rp=rem, mp=mass_earth)
# set degree-1 terms to zero
hlm[1].coeffs[:, 1, :] = 0.
a = hlm[1].expand(lat=0., lon=0., lmax_calc=lmax)
b = hlm[1].expand(lat=0., lon=90., lmax_calc=lmax)
c = hlm[1].expand(lat=90., lon=0., lmax_calc=lmax)
f_core = ((a+b)/2. - c) / ((a + b) / 2.)
beta_core = (a**2 - b**2) / (a**2 + b**2)
print(r_core/1.e3, rho[0], rho[1], f_core, beta_core)
f_rc_fc.write('{:e}, {:e}\n'.format(r_core/1.e3, f_core))
f_rc_rhoc.write('{:e}, {:e}\n'.format(r_core/1.e3, rho[0]))
f_rc_beta.write('{:e}, {:e}\n'
.format(r_core/1.e3, beta_core))
if r_core == 330.e3:
print("Rcore (km) = {:e}".format(r_core/1.e3))
print("A (km) = {:e}".format(a/1.e3))
print("B (km) = {:e}".format(b/1.e3))
print("C (km) = {:e}".format(c/1.e3))
print("rho_core (kg/m3) = {:e}".format(rho[0]))
II, AA, BB, CC, mass_model, RR, vec = \
InertiaTensor_from_shape(hlm, rho, 1, quiet=False)
grid = hlm[i_core].expand(lmax=lmax_grid, grid='DH2')
grid.to_file(core_shape_wo_d1)
print("Size of output grid = {:d}, {:d}"
.format(grid.nlat, grid.nlon))
print("Maximum = {:e}\nMinimum = {:e}"
.format(grid.max(), grid.min()))
hlm, clm_hydro, mass_model = \
HydrostaticShapeLith(radius, rho, i_lith,
potential, topo, rho_crust,
r_sigma, omega, lmax,
rp=rem, mp=mass_earth)
hlm_fluid, clm_fluid, mass_model = \
HydrostaticShape(radius, rho, omega, potential.gm,
potential.r0,
rp=rem, mp=mass_earth)
grid = hlm[i_core].expand(lmax=lmax_grid, grid='DH2')
grid_fluid = hlm_fluid[i_core].expand(lmax=lmax_grid,
grid='DH2')
a_fluid = hlm_fluid[1].expand(lat=0., lon=0.)
b_fluid = hlm_fluid[1].expand(lat=0., lon=90.)
c_fluid = hlm_fluid[1].expand(lat=90., lon=0.)
f_core_fluid = (((a_fluid+b_fluid)/2. - c_fluid)
/ ((a_fluid + b_fluid) / 2.))
beta_core_fluid = ((a_fluid**2 - b_fluid**2) /
(a_fluid**2 + b_fluid**2))
print('f_core for a fluid planet = ', f_core_fluid)
print('beta_core for a fluid planet = ',
beta_core_fluid)
diff = grid - grid_fluid
print('Maximuim and miniumum core relief for '
'a fluid planet (m) = ',
grid_fluid.max(), grid_fluid.min())
print('Maximuim and miniumum difference with respect '
'to a fluid planet (m) = ',
diff.max(), diff.min())
hlm[i_core].to_file(sh_core)
grid.to_file(core_shape)
print("Maximum = {:e}\nMinimum = {:e}"
.format(grid.max(), grid.min()))
for l in range(0, 4):
for m in range(0, l+1):
print(l, m, hlm[i_core].coeffs[0, l, m],
hlm[i_core].coeffs[1, l, m])
diff_old = diff_new
def moi_solid(radius, rho, n):
"""
Calculate the mean, normalized, moment of inertia of the solid portion
of the planet.
The radius and density are discretized into shells as in the hydrostatic
flattening routines:
radius[0] = 0
radius[1] = radius of core
radius[n] = surface
rho[i] = density from radius[i] to radius[i+1]
"""
moi_solid = 0.
mass = 4. * np.pi / 3. * rho[0] * radius[1]**3
for i in range(2, n+1):
mass += 4. * np.pi / 3. * rho[i-1] * (radius[i]**3 - radius[i-1]**3)
moi_solid += 8. * np.pi / 15. * rho[i-1] * (radius[i]**5 -
radius[i-1]**5)
return moi_solid / mass / radius[n]**2
# ==== EXECUTE SCRIPT ====
if __name__ == "__main__":
main()