def fun(r,y,p): # Eigenvalues F=p[0] speed=p[1] # PREM gravity and density in layer if model =='prem': density_seis=lp.premdensity(r*csb_radius)/density0 # dimensionless density elif model == 'ohtaki': _,density_seis = lp.ohtaki(r*csb_radius)/density0 gravity_seis=lp.premgravity(r*csb_radius)/csb_gravity # dimensionless gravity density_grad_seis=np.gradient(density_seis,r) gravity_grad_seis=np.gradient(gravity_seis,r) # r derivative of barodiffusion term term=gravity_seis*density_seis*np.exp(F*(csb_radius*r-icb_radius)/layer_thickness)* \ (F*csb_radius/layer_thickness+2/r-y[3]/y[0]+ \ gravity_grad_seis/gravity_seis+density_grad_seis/density_seis)/y[0] # liquidus (=dxi/dr) eq1=-(Lip*density_seis*gravity_seis+y[3]/y[0])*Rrho/(Lix*St*y[0]) # oxygen eqn (=dj/dr) eq2=(Lip*Rrho*term/(Lix*St*Pe*Rvol) - eq1*(Rrho*speed+y[2]) - \ 2*y[1]*y[2]/r)/y[1] # temp eqn (=d2T/dr2) eq3=-Pe/Le*((eq2+2/r*y[2])/St + \ (speed+2*Le/(r*Pe))*y[3]) return np.vstack([y[3],eq1,eq2,eq3])
def slurrydensity(radius,temp,xi,solidflux,mol_conc_oxygen_bulk, \ sedimentation_constant,mol_conc_SSi=8,model='prem'): # Density profile across slurry layer csb_radius = radius[-1] if model == 'prem': csb_density = premdensity(csb_radius) elif model == 'ohtaki': _, csb_density = ohtaki(csb_radius) # Solid fraction Kphi = getKphi(sedimentation_constant, radius, mol_conc_oxygen_bulk) phi = (-solidflux / Kphi)**(3 / 5) # Density fluctuations deltaV_solid_liquid = getchangevolmeltingFe(csb_density) temp_denFluc = -csb_density * alphaT * (temp - temp[-1]) xi_denFluc = -csb_density * alphaXi * (xi - xi[-1]) phi_denFluc = csb_density * (csb_density * deltaV_solid_liquid + alphaXi * xi) * (phi - phi[-1]) density_fluc = temp_denFluc + xi_denFluc + phi_denFluc # Hydrostatic density slurry_gravity = premgravity(radius) density_hydrostatic=1/(slurry_gravity*(radius-csb_radius)/bulk_modulus+ \ 1/csb_density) # Total density density_slurry = density_hydrostatic + density_fluc return (density_slurry, phi, temp_denFluc, xi_denFluc, phi_denFluc, density_fluc)
def getLip(csb_radius, model='prem'): gravity = premgravity(csb_radius) if model == 'prem': density = premdensity(csb_radius) elif model == 'ohtaki': _, density = ohtaki(csb_radius) Lip = deltaV_solidFe_liquidFe * gravity * density * csb_radius / latent_heat return Lip, gravity, density
def getKphi(sedimentation_constant, radius, mol_conc_oxygen_bulk, mol_conc_SSi=8): gravity = premgravity(radius) density = premdensity(radius) deltaV_solid_liquid = getchangevolmeltingFe(density[-1]) Kphi = sedimentation_constant * gravity * density * deltaV_solid_liquid return Kphi
def getdimensional(layer_thickness,Pe,St,Le, \ mol_conc_oxygen_bulk=8., mol_conc_SSi=8., \ self_diffusion=0.98e-8): csb_radius = getcsbradius(layer_thickness) density0 = premdensity(csb_radius) mass_conc_O, acore = getcsbmassoxygen(mol_conc_oxygen_bulk, mol_conc_SSi) freezing_speed = getfreezingspeedfromPe(Pe, csb_radius, self_diffusion) icb_heatflux = geticbheatflux(freezing_speed) csb_heatflux = getcsbheatflux(St, freezing_speed, density0, csb_radius) thermal_conductivity = getthermalconductivity(Le, density0) return (icb_heatflux, csb_heatflux, thermal_conductivity)
def heatflux(radius,temp,xi,solidflux,phi,temp_grad,xi_grad,density_slurry, \ icb_speed,icb_heatflux,layer_thickness,thermal_conductivity, \ csb_heatflux,n): csb_radius = radius[-1] # GRAVITATIONAL POWER # Gravitational potential radius_psi = np.linspace(icb_radius, cmb_radius) gravity_psi = premgravity(radius_psi) psi = np.zeros(radius_psi.size) for i in range(radius_psi.size - 1): psi[i] = -integrate.simps(gravity_psi[i:], radius_psi[i:]) # Slurry f = interpolate.interp1d(radius_psi, psi) psi_slurry = f(radius) oxygen_mass_slurry = 4 * np.pi * density_solidFe * layer_thickness**2 * icb_speed * xi[ -1] mass_slurry = integrate.simps(density_slurry * 4 * np.pi * radius**2, radius) Qg_slurry = -alphaXi*oxygen_mass_slurry/mass_slurry* \ integrate.simps(density_slurry*psi_slurry*4*np.pi*radius**2,radius) # print('Change in oxygen mass (slurry) is {}'.format(oxygen_mass_slurry)) # print('Mass of slurry is {}'.format(mass_slurry)) print('Qg slurry is {:.2f}TW'.format(Qg_slurry * 1e-12)) # Outer core radius_oc = np.linspace(csb_radius, cmb_radius) psi_oc = f(radius_oc) surf = -psi[0] * alphaXi * density_slurry[-1] * xi[ -1] * icb_speed * 4 * np.pi * csb_radius**2 # Mass of OC density_oc = premdensity(radius_oc) mass_oc = integrate.simps(density_oc * 4 * np.pi * radius_oc**2, radius_oc) oxygen_mass_oc = -density_slurry[ -1] * icb_speed * 4 * np.pi * csb_radius**2 * xi[-1] / mass_oc bulk = integrate.simps( alphaXi * psi_oc * oxygen_mass_oc * 4 * np.pi * radius_oc**2, radius_oc) # print('Change in oxygen mass (outer core) is {}'.format(oxygen_mass_oc)) # print('Mass of outer core is {}'.format(mass_oc)) print('Qg surface term in outer core is {:.2f}TW'.format(surf * 1e-12)) print('Qg bulk term in outer core is {:.5f}TW'.format(bulk * 1e-12)) # Total gravitational energy Qg_oc = surf + bulk Qg = Qg_slurry + Qg_oc print('Total Qg is {:.2f}TW'.format(Qg * 1e-12)) # LATENT HEAT Ql = 4 * np.pi * icb_radius**2 * density_solidFe * icb_speed * latent_heat print('Total Ql is {:.2f}TW'.format(Ql * 1e-12)) # SECULAR COOLING # Cooling rate csb_temp = temp[-1] cooling_rate, cmb_temp, temp_ad = get_cooling(icb_speed, csb_temp, radius_oc, csb_radius, cmb_radius) # Outer core Qs_oc = - heat_capacity*cooling_rate/cmb_temp \ *integrate.simps(density_oc*temp_ad*4*np.pi*radius_oc**2,radius_oc) print('Qs in outer core is {:.2f}TW'.format(Qs_oc * 1e-12)) # Slurry Qs_slurry = csb_heatflux - Qg_slurry - Ql print('Qs in slurry {:.2f}TW'.format(Qs_slurry * 1e-12)) Qs = Qs_slurry + Qs_oc print('Total Qs is {:.2f}TW'.format(Qs * 1e-12)) # CMB heat flux Q_cmb = csb_heatflux + Qs_oc + Qg_oc print('Qcmb is is {:.2f}TW'.format((Q_cmb) * 1e-12)) return (Q_cmb, Qs, Qs_slurry, Qs_oc, Ql, Qg, Qg_oc, Qg_slurry, cooling_rate, cmb_temp, temp_ad)
def plot_sensitivity(csb_temp, csb_oxygen, csb_temp0, csb_oxy0, saveOn, aspectRatio=0.75): w, h = plt.figaspect(aspectRatio) fig1, (ax1, ax2) = plt.subplots(1, 2, figsize=(2 * w, h), sharey=True) # Temperature nTemp = csb_temp.size colors = plt.cm.OrRd(np.linspace(0.4, 1, nTemp)) den_jump = [] for i in range(nTemp): filename = 'sensitivity/temp_{:.0f}'.format(csb_temp[i]).replace( '.', '_') with open(filename, 'rb') as f: (radius, temp, xi, solidFlux, density) = pickle.load(f) if i == 0 or i == nTemp - 1: ax1.plot(radius * 1e-3, density, color=colors[i], linewidth=2, label=r'$T^{{sl}}=${:.0f} K'.format(csb_temp[i])) # Reference case elif csb_temp[i] == csb_temp0: den_jump0 = density[0] - density[-1] ax1.plot(radius * 1e-3, density, color='silver', linewidth=2, label=r'$T^\mathregular{{sl}}=$5457 K') else: ax1.plot(radius * 1e-3, density, color=colors[i]) den_jump.append(density[0] - density[-1]) # PREM density_prem = premdensity(radius) ax1.plot(radius * 1e-3, density_prem, 'k', linestyle='--') ax1.legend(fontsize=11.5) ax1.set_xlim([radius[0] * 1e-3, radius[-1] * 1e-3]) ax1.set(xlabel="Radius (km)", ylabel="Density ($\mathrm{kg m^{-3}}$)") den_low = (den_jump[0] - den_jump0) / den_jump0 * 100 den_high = (den_jump[-1] - den_jump0) / den_jump0 * 100 print( 'Temperature: Density jump ranges from {:.2f}% to {:.2f}% of reference' .format(den_low, den_high)) # Oxygen nOxy = csb_oxygen.size colors = plt.cm.GnBu(np.linspace(0.4, 1, nOxy)) den_jump = [] for i in range(nOxy): filename = 'sensitivity/oxy_{:.1f}'.format(csb_oxygen[i]).replace( '.', '_') with open(filename, 'rb') as f: (radius, temp, xi, solidFlux, density) = pickle.load(f) if i == 0 or i == nOxy - 1: ax2.plot(radius * 1e-3, density, color=colors[i], linewidth=2, label=r'$\xi^{{sl}}=${:.1f} mol.%'.format(csb_oxygen[i])) # Reference case elif csb_oxygen[i] == csb_oxy0: den_jump0 = density[0] - density[-1] ax2.plot(radius * 1e-3, density, color='silver', linewidth=2, label=r'$\xi^{{sl}}=$8.0 mol.%') else: ax2.plot(radius * 1e-3, density, color=colors[i]) den_jump.append(density[0] - density[-1]) # PREM density_prem = premdensity(radius) ax2.plot(radius * 1e-3, density_prem, 'k', linestyle='--', label=r'PREM') ax2.legend(fontsize=11.5) ax2.set_xlim([radius[0] * 1e-3, radius[-1] * 1e-3]) ax2.set(xlabel="Radius (km)") den_low = (den_jump[0] - den_jump0) / den_jump0 * 100 den_high = (den_jump[-1] - den_jump0) / den_jump0 * 100 print('Oxygen: Density jump ranges from {:.2f}% to {:.2f}% of reference'. format(den_low, den_high)) ax1.set_title('(a)', x=0.95, y=1, fontsize=14) ax2.set_title('(b)', x=0.95, y=1, fontsize=14) if saveOn == 1: saveDir = 'figures/sensitivity/' if not os.path.exists(saveDir): os.makedirs(saveDir) fig1.savefig(saveDir + "temp_oxy.pdf", format='pdf', dpi=200, bbox_inches='tight') fig1.savefig(saveDir + "temp_oxy.png", format='png', dpi=200, bbox_inches='tight') print('Figure saved as {}'.format(saveDir + "temp_oxy.pdf"))
def plot_CD(layer_thickness, thermal_conductivity, icb_heatflux, csb_heatflux, saveOn, figAspect=0.75): w, h = plt.figaspect(figAspect) # fig, (ax1,ax2,ax3) = plt.subplots(3,1,figsize=(1.25*w,1.25*h),sharex=True) fig = plt.figure(constrained_layout=True, figsize=(1.25 * w, 2 * h)) spec = gridspec.GridSpec(ncols=1, nrows=3, figure=fig) ax1 = fig.add_subplot(spec[0, 0]) ax2 = ax1.twinx() ax3 = fig.add_subplot(spec[1, 0], sharex=ax1) n = layer_thickness.size*thermal_conductivity.size \ *icb_heatflux.size*csb_heatflux.size if n != 1: fig_label = [r'high $Le$', r'low $Le$'] start = 0.2 stop = 0.5 cm_subsection = np.linspace(start, stop, n) colors = [cm.gray_r(x) for x in cm_subsection] # Load data k = 0 for w, x, y, z in [(w, x, y, z) for w in layer_thickness for x in icb_heatflux for y in csb_heatflux for z in thermal_conductivity]: foldername, filename = get_outputDir(w, x, y, z) inputDir = "results/{}/{}/".format(foldername, filename) try: inputs, outputs, profiles = readdata(inputDir) except: print('{} does not exist'.format(inputDir)) return # Calculate bulk modulus from PREM bulk_modulus = premvp(profiles.r)**2 * premdensity(profiles.r) # Calculate vp using slurry density and PREM bulk modulus vp_slurry = np.sqrt(bulk_modulus / profiles.density) # Calculate FVW P wave speed (Ohtaki et al. 2015, fig 11a) x = profiles.r / earth_radius vp_fvw = 3.3 * x[0] - 3.3 * x + 10.33 max_diff = np.max((vp_fvw - vp_slurry * 1e-3) / vp_fvw * 100) print('Maximum difference with Ohtaki et al. (2015) is {:.2f}%'.format( max_diff)) max_diff = np.max( (premvp(profiles.r) - vp_slurry) / premvp(profiles.r) * 100) print('Maximum difference with PREM is {:.2f}%'.format(max_diff)) print('Density on slurry side of ICB is {:.2f}'.format( profiles.density[0])) density_jump = profiles.density[0] - profiles.density.iloc[-1] print('Density jump is {:.2f}'.format(density_jump)) rho_bod = density_solidFe - profiles.density[0] print('Delta rho bod is {:.2f}'.format(rho_bod)) rho_mod = rho_bod + density_jump print('Delta rho mod is {:.2f}'.format(rho_mod)) # Plot P wave speed if n == 1: ax3.plot(profiles.r * 1e-3, vp_slurry * 1e-3, color='darkgrey', lw=2, label='slurry density') #(km/s) ax3.vlines(profiles.r[0] * 1e-3, vp_slurry[0] * 1e-3, 10.4, color='darkgrey', lw=2) else: ax3.plot(profiles.r * 1e-3, vp_slurry * 1e-3, color=colors[k], lw=2, label=fig_label[k]) #(km/s) ax3.vlines(profiles.r[0] * 1e-3, vp_slurry[0] * 1e-3, 10.4, color=colors[k], lw=2) # Check density # ax3.plot(profiles.r*1e-3,premdensity(profiles.r),'k--') # ax3.plot(profiles.r*1e-3,profiles.density) k += 1 # Plot temperature and composition ax1.plot(profiles.r * 1e-3, profiles.temp, lw=2, color='red', label='temperature') (mass_conc_O, acore) = getcsbmassoxygen(inputs.oxygen_bulk) acore = float(acore) ax2.plot(profiles.r * 1e-3, profiles.oxygen * acore / aO * 100, lw=2, color='blue', label='oxygen') # Plot FVW, PREM and AK135 ax3.plot(profiles.r * 1e-3, vp_fvw, color='black', lw=2, ls=':', label='Ohtaki et al. (2015)') ax3.vlines(profiles.r[0] * 1e-3, vp_fvw[0], 10.4, color='black', ls=':', lw=2) ax3.plot(profiles.r * 1e-3, premvp(profiles.r) * 1e-3, color='k', ls='--', label='PREM') ax3.vlines(profiles.r[0] * 1e-3, premvp(profiles.r[0]) * 1e-3, 10.4, 'k', linestyle='--') # ax3.plot(radius_ak135*1e-3,vp_ak135*1e-3,'k',label='ak135') # ax3.vlines(radius_ak135[0]*1e-3,vp_ak135[0]*1e-3,10.4, 'k') ax3.legend(fontsize=11.5, loc='upper right') ax1.set(ylabel="Temperature (K)") ax1.spines["right"].set_edgecolor('red') ax1.spines["right"].set_edgecolor('blue') ax1.yaxis.label.set_color('red') ax2.set(ylabel="Oxygen (mol.%)") ax2.spines["left"].set_edgecolor('red') ax2.spines["right"].set_edgecolor('blue') ax2.yaxis.label.set_color('blue') ax2.tick_params(axis='y', colors='blue') ax1.tick_params(axis='y', which='both', colors='red') ax3.set(xlabel="Radius (km)") ax3.set(ylabel="P wave speed (km/s)") ax3.set_xlim([1200, profiles.r.iloc[-1] * 1e-3]) ax3.set_ylim([10.25, 10.4]) major_xticks = np.arange(1200, 1370, 20) minor_xticks = np.arange(1200, 1370, 5) ax1.set_xticks(major_xticks) ax1.set_xticks(minor_xticks, minor=True) ax2.set_xticks(major_xticks) ax2.set_xticks(minor_xticks, minor=True) ax3.set_xticks(major_xticks) ax3.set_xticks(minor_xticks, minor=True) major_yticks = np.arange(5500, 5751, 100) minor_yticks = np.arange(5500, 5751, 20) ax1.set_yticks(major_yticks) ax1.set_yticks(minor_yticks, minor=True) ax1.grid(which='minor', alpha=0.2) ax1.grid(which='major', alpha=0.5) ax1.tick_params(which='major', length=7) ax1.tick_params(which='minor', length=3.5) # major_yticks = np.arange(6.5,8.1,0.5) # minor_yticks = np.arange(6.5,8.1,0.1) # ax2.set_yticks(major_yticks) # ax2.set_yticks(minor_yticks, minor=True) # ax2.grid(which='minor', alpha=0.2) # ax2.grid(which='major', alpha=0.5) # ax2.tick_params(which='major',length = 7) # ax2.tick_params(which='minor',length = 3.5) major_yticks = np.arange(10.25, 10.4, 0.05) minor_yticks = np.arange(10.25, 10.4, 0.01) ax3.set_yticks(major_yticks) ax3.set_yticks(minor_yticks, minor=True) ax3.grid(which='minor', alpha=0.2) ax3.grid(which='major', alpha=0.5) ax3.tick_params(which='major', length=7) ax3.tick_params(which='minor', length=3.5) if saveOn == 1: saveDir = 'figures/seismic/' if not os.path.exists(saveDir + foldername): os.makedirs(saveDir + foldername) fig.savefig(saveDir + foldername + "/" + filename + "_CD.pdf", format='pdf', dpi=200, bbox_inches='tight') fig.savefig(saveDir + foldername + "/" + filename + "_CD.png", format='png', dpi=200, bbox_inches='tight') print('Figure saved as {}'.format(saveDir + foldername + "/" + filename + "_CD.pdf")) plt.show() return profiles.r, vp_slurry, profiles.density, vp_fvw
def plot_compare(layer_thickness, csb_heatflux, icb_heatflux, thermal_conductivity, saveOn, saveTag, mol_conc_oxygen_bulk=8., mol_conc_SSi=8., self_diffusion=0.98e-8, aspectRatio=0.75, tempMin=5400, tempMax=5800, xiMin=6, xiMax=8, jMin=-3.5e-7, jMax=0, denMin=11900, denMax=12250): w, h = plt.figaspect(aspectRatio) * 2 fig = plt.figure() fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, figsize=(w, h)) colors = plt.cm.tab10(np.linspace(0, 1, layer_thickness.size)) plt.rcParams["axes.prop_cycle"] = plt.cycler("color", plt.cm.tab10.colors) for i in (range(layer_thickness.size)): foldername, filename = get_outputDir(layer_thickness[i], icb_heatflux, csb_heatflux, thermal_conductivity) inputDir = foldername + "/" + filename data_in, data_out, data_profiles = readdata(inputDir) radius = (data_profiles['r']) * 1e-3 oxygen = data_profiles['oxygen'] (mass_conc_O, acore) = getcsbmassoxygen(data_in.oxygen_bulk) acore = float(acore) ax1.plot(radius, data_profiles['temp'], label='_nolegend_') #, color=colors[i]) ax2.plot(radius, oxygen * acore / aO * 100) #, color=colors[i]) ax3.plot(radius, data_profiles['solidflux']) #,color=colors[i]) ax4.plot(radius, data_profiles['density'], label='{:.0f} km'.format(layer_thickness[i] * 1e-3)) #,color=colors[i]) # Liquidus radius_liquidus = np.linspace(icb_radius, icb_radius + 400e3) temp_liquidus = liquidus(radius_liquidus) ax1.plot(radius_liquidus * 1e-3, temp_liquidus, 'k--', label='Liquidus (Davies et al. 2015)') # PREM radius_prem = np.linspace(icb_radius, icb_radius + 400e3) density_prem = premdensity(radius_prem) ax4.plot(radius_prem * 1e-3, density_prem, 'k--', label='PREM') ax4.set(xlabel="Radius (km)", ylabel="Density ($\mathrm{kg m^{-3}}$)") # Axis titles ax1.set(ylabel="Temperature (K)") ax2.set(ylabel="Oxygen (mol.%)") ax3.set(xlabel="Radius (km)", ylabel="Solid flux ($\mathrm{kg m^{-2} s^{-1}}$)") # Legend ax1.legend(fontsize=11.5, loc=1) ax4.legend(fontsize=11.5, loc=1) # Axis limits ax1.set_ylim([tempMin, tempMax]) ax2.set_ylim([xiMin, xiMax]) ax3.set_ylim([jMin, jMax]) ax4.set_ylim([denMin, denMax]) ax1.set_xlim([1220, (icb_radius + 400e3) * 1e-3]) # Subfigure labels ax1.text(1225, tempMax - 23, '(a)', fontsize=14) ax2.text(1225, xiMax - 0.12, '(b)', fontsize=14) ax3.text(1225, jMax - .2e-7, '(c)', fontsize=14) ax4.text(1225, denMax - 20, '(d)', fontsize=14) plt.tight_layout() if saveOn == 1: if not os.path.exists('figures/profiles'): os.makedirs('figures/profiles') saveName = foldername + "_" + filename + saveTag plt.savefig('figures/profiles/' + saveName + '.pdf', format='pdf', dpi=200) plt.show()
def plot_seismic_dark(layer_thickness, thermal_conductivity, icb_heatflux, csb_heatflux, saveOn, figAspect=0.75): w, h = plt.figaspect(figAspect) fig, ax = plt.subplots(1, 1, figsize=(1.25 * w, 1.25 * h)) n = layer_thickness.size*thermal_conductivity.size \ *icb_heatflux.size*csb_heatflux.size if n != 1: fig_label = [r'high $Le$', r'low $Le$'] start = 0.2 stop = 0.5 cm_subsection = np.linspace(start, stop, n) colors = [cm.gray_r(x) for x in cm_subsection] # Load data k = 0 for w, x, y, z in [(w, x, y, z) for w in layer_thickness for x in icb_heatflux for y in csb_heatflux for z in thermal_conductivity]: foldername, filename = get_outputDir(w, x, y, z) inputDir = "results/{}/{}/".format(foldername, filename) try: inputs, outputs, profiles = readdata(inputDir) except: print('{} does not exist'.format(inputDir)) return # Calculate bulk modulus from PREM bulk_modulus = premvp(profiles.r)**2 * premdensity(profiles.r) # Calculate vp using slurry density and PREM bulk modulus vp_slurry = np.sqrt(bulk_modulus / profiles.density) # Calculate FVW P wave speed (Ohtaki et al. 2015, fig 11a) x = profiles.r / earth_radius vp_fvw = 3.3 * x[0] - 3.3 * x + 10.33 max_diff = np.max((vp_fvw - vp_slurry * 1e-3) / vp_fvw * 100) print('Maximum difference with Ohtaki et al. (2015) is {:.2f}%'.format( max_diff)) max_diff = np.max( (premvp(profiles.r) - vp_slurry) / premvp(profiles.r) * 100) print('Maximum difference with PREM is {:.2f}%'.format(max_diff)) print('Density on slurry side of ICB is {:.2f}'.format( profiles.density[0])) density_jump = profiles.density[0] - profiles.density.iloc[-1] print('Density jump is {:.2f}'.format(density_jump)) rho_bod = density_solidFe - profiles.density[0] print('Delta rho bod is {:.2f}'.format(rho_bod)) rho_mod = rho_bod + density_jump print('Delta rho mod is {:.2f}'.format(rho_mod)) # Plot P wave speed if n == 1: ax.plot(profiles.r * 1e-3, vp_slurry * 1e-3, color='darkgrey', lw=2, label='slurry') #(km/s) ax.vlines(profiles.r[0] * 1e-3, vp_slurry[0] * 1e-3, 10.4, color='darkgrey', lw=2) else: ax.plot(profiles.r * 1e-3, vp_slurry * 1e-3, color=colors[k], lw=2, label=fig_label[k]) #(km/s) ax.vlines(profiles.r[0] * 1e-3, vp_slurry[0] * 1e-3, 10.4, color=colors[k], lw=2) # Check density # ax1.plot(profiles.r*1e-3,premdensity(profiles.r),'k--') # ax1.plot(profiles.r*1e-3,profiles.density) k += 1 # Look up AK135 radius_ak135 = ak135radius() vp_ak135 = ak135vp(radius_ak135) ax.plot(profiles.r * 1e-3, vp_fvw, color='blue', lw=2, ls=':', label='Ohtaki et al. (2015)') ax.vlines(profiles.r[0] * 1e-3, vp_fvw[0], 10.4, color='blue', lw=2, ls=':') ax.plot(profiles.r * 1e-3, premvp(profiles.r) * 1e-3, color='white', ls='--', label='PREM') ax.vlines(profiles.r[0] * 1e-3, premvp(profiles.r[0]) * 1e-3, 10.4, 'white', linestyle='--') ax.plot(radius_ak135 * 1e-3, vp_ak135 * 1e-3, 'white', label='ak135') ax.vlines(radius_ak135[0] * 1e-3, vp_ak135[0] * 1e-3, 10.4, 'white') ax.legend(fontsize=11.5) ax.set(xlabel="Radius (km)") ax.set(ylabel="P wave speed (km/s)") ax.set_xlim([1200, profiles.r.iloc[-1] * 1e-3]) ax.set_ylim([10.1, 10.4]) plt.yticks(np.arange(10.1, 10.41, 0.1)) if saveOn == 1: saveDir = 'figures/seismic/' if not os.path.exists(saveDir + foldername): os.makedirs(saveDir + foldername) fig.savefig(saveDir + foldername + "/" + filename + "_dark.pdf", format='pdf', dpi=200, bbox_inches='tight') fig.savefig(saveDir + foldername + "/" + filename + "_dark.png", format='png', dpi=200, bbox_inches='tight') print('Figure saved as {}'.format(saveDir + foldername + "/" + filename + ".pdf")) plt.show() return profiles.r, vp_slurry, profiles.density
def plot_profile(inputDir): # Read data try: # print(inputDir) inputs, outputs, profiles = readdata(inputDir) except: print('Folder does not exist') # print('State = {}'.format(outputs.state.iloc[0])) # Plots csb_radius = pd.to_numeric(profiles.r.iloc[-1]) radius = (profiles.r) * 1e-3 w, h = plt.figaspect(0.75) * 2 # Temperature fig1 = plt.figure fig1, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, sharex=True, figsize=(w, h)) ax1.plot(radius, profiles.temp) ax1.set(ylabel="Temperature (K)") # Oxygen (mass_conc_O, acore) = getcsbmassoxygen(inputs.oxygen_bulk) acore = float(acore) ax2.plot(radius, profiles.oxygen * acore / aO * 100) ax2.set(ylabel="Oxygen (mol.%)") ax3.plot(radius, profiles.solidflux) ax3.set(xlabel="Radius (km)", ylabel="Solid flux ($\mathrm{kg m^{-2} s^{-1}}$)") # Density ax4.plot(radius, profiles.density) ax4.set(xlabel="Radius (km)", ylabel="Density ($\mathrm{kg m^{-3}}$)") # Liquidus radius_liquidus = np.linspace(icb_radius, csb_radius) temp_liquidus = liquidus(radius_liquidus) ax1.plot(radius_liquidus * 1e-3, temp_liquidus, 'k--', label='Liquidus (Davies et al. 2015)') ax1.legend() # Seismology radius_prem = np.linspace(icb_radius, csb_radius) density_prem = premdensity(radius_prem) ax4.plot(radius_prem * 1e-3, density_prem, 'k--') ax4.set(xlabel="Radius (km)", ylabel="Density ($\mathrm{kg m^{-3}}$)") ax1.set(ylabel="Temperature (K)") ax2.set(ylabel="Oxygen (mol.%)") ax3.set(xlabel="Radius (km)", ylabel="Solid flux ($\mathrm{kg m^{-2} s^{-1}}$)") ax1.set_xlim([radius.iloc[0], radius.iloc[-1]]) plt.tight_layout() plt.show()
def plot_sedimentation(sed_con, saveOn, mol_conc_oxygen_bulk=8, figAspect=0.75): nSed = sed_con.size colors = plt.cm.gnuplot_r(np.linspace(0.4, 1, nSed)) w, h = plt.figaspect(figAspect) fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, figsize=(w, 2 * h)) # Format function for scientific notation in legend my_fun = mticker.ScalarFormatter(useOffset=False, useMathText=True) for i in range(nSed): filename = 'sensitivity/sed_{:.0f}'.format(np.log10( sed_con[i])).replace('.', '_') with open(filename, 'rb') as f: (radius, temp, xi, solidFlux, density) = pickle.load(f) # FIX: # ax1.plot(radius*1e-3,density,label=r'$k_\phi =$ {} $\mathrm{{kgm^{{-3}}s}}$'.format(my_fun.format_data(sed_con[i])), # color=colors[i]) ax1.plot(radius * 1e-3, density, label=r'$k_\phi = {} \mathrm{{kgm^{{-3}}s}}$'.format( my_fun.format_data(sed_con[i])).replace('{', '{{').replace( '}', '}}'), color=colors[i]) ax1.plot(radius * 1e-3, density, color=colors[i]) Kphi = getKphi(sed_con[i], radius, mol_conc_oxygen_bulk) phi = getphi(Kphi, solidFlux) ax2.plot(radius * 1e-3, phi, color=colors[i]) # PREM density_prem = premdensity(radius) ax1.plot(radius * 1e-3, density_prem, 'k--', label='PREM') ax1.set(ylabel="Density ($\mathrm{kg m^{-3}}$)") #,yscale="log") ax2.set(xlabel="Radius (km)", ylabel="Solid fraction", yscale='log') ax2.axhline(0.6, color='k', linestyle='--') # rheological transition # labels = ['$k_\phi =${} $\mathrm{{kgm^{{-3}}s}}$'.format(my_fun.format_data(sed_con[i])), # '1','2','3','4'] fig.legend(loc='center right', bbox_to_anchor=(1.4, 0.5), fontsize=11.5) ax1.set_xlim([radius[0] * 1e-3, radius[-1] * 1e-3]) ax2.set_ylim([1e-4, 1]) ax1.set_title('(a)', x=0.95, y=1, fontsize=14) ax2.set_title('(b)', x=0.95, y=1, fontsize=14) if saveOn == 1: saveDir = 'figures/sensitivity/' if not os.path.exists(saveDir): os.makedirs(saveDir) fig.savefig(saveDir + "sedimentation.pdf", format='pdf', dpi=200, bbox_inches='tight') fig.savefig(saveDir + "sedimentation.png", format='png', dpi=200, bbox_inches='tight') print('Figure saved as {}'.format(saveDir + "sedimentation.pdf")) plt.show()