def velocities_at_boundaries(self): bounds = self.get_boundaries()[:-1] phases = self.compositions vels = [] for i,bound in enumerate(bounds): p_bound = self.pressure[bound] t_bound = self.temperature[bound] lower_phase = phases[i] upper_phase = phases[i+1] lower_phase.set_state(p_bound,t_bound) upper_phase.set_state(p_bound,t_bound) r = self.boundaries[i] rho1, vp1, vs1, vphi1, K1, G1 = burnman.velocities_from_rock(lower_phase,\ np.array([p_bound]), np.array([t_bound])) rho2, vp2, vs2, vphi2, K2, G2 = burnman.velocities_from_rock(upper_phase,\ np.array([p_bound]), np.array([t_bound])) if vs1 < 0. or np.isnan(vs1): vs1 = 0. if vs2 < 0. or np.isnan(vs2): vs2 = 0. if G1 < 0. or np.isnan(G1): G1 = 0. if G2 < 0. or np.isnan(G2): G2 = 0. vel = np.array([[r]+ [float(x) for x in [rho1, vp1, vs1, vphi1, K1, G1] ],\ [r] +[float(x) for x in [rho2, vp2, vs2, vphi2, K2, G2] ] ] ) vels.append(vel) return vels
def evaluate_eos(self, pressures, temperatures, radii): densities = np.empty_like(radii) for i in range(len(radii)): if radii[i] > self.cmb: density, vp, vs, vphi, K, G = burnman.velocities_from_rock(self.ol, np.array([pressures[i]]), np.array([temperatures[i]])) densities[i] = density else: density, vp, vs, vphi, K, G = burnman.velocities_from_rock(self.fe, np.array([pressures[i]]), np.array([temperatures[i]])) densities[i] = density return densities
def evaluate_eos(self, pressures, temperatures, radii): ''' Find densities for a given set of pressures and temperatures args: pressures: array of starting pressures in Pa temperatures: array of constant temperatures in K radii: array of radii in m ''' assert(radii.max() <= self.boundaries[-1] and radii.min() >= 0. ) densities = np.empty_like(radii) # iterate over layers last = -1. for bound,comp in zip(self.boundaries,self.compositions): layer = (radii > last) & ( radii <= bound) rrange = radii[ layer ] drange = np.empty_like(rrange) prange = pressures[ layer ] trange = temperatures[ layer ] for i in range(len(rrange)): density, vp, vs, vphi, K, G = burnman.velocities_from_rock(comp, np.array([prange[i]]), np.array([trange[i]])) drange[i] = density densities[layer] = drange last = bound # update last boundary return densities
def calc_velocities(mg_pv_K, mg_pv_K_prime, mg_pv_G, mg_pv_G_prime, fe_pv_K, fe_pv_K_prime, fe_pv_G, fe_pv_G_prime): method = 'slb3' #slb3|slb2|mgd3|mgd2 amount_perovskite = 0.95 rock = burnman.composite([ (minerals.SLB_2005.mg_fe_perovskite(0.1), amount_perovskite), (minerals.SLB_2005.ferropericlase(0.5), 1.0 - amount_perovskite) ]) mg_pv = rock.staticphases[0].mineral.base_materials[0] fe_pv = rock.staticphases[0].mineral.base_materials[1] mg_pv.params['K_0'] = mg_pv_K mg_pv.params['Kprime_0'] = mg_pv_K_prime mg_pv.params['G_0'] = mg_pv_G mg_pv.params['Gprime_0'] = mg_pv_G_prime fe_pv.params['K_0'] = fe_pv_K fe_pv.params['Kprime_0'] = fe_pv_K_prime fe_pv.params['G_0'] = fe_pv_G fe_pv.params['Gprime_0'] = fe_pv_G_prime rock.set_method(method) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock( rock, seis_p, temperature) return mat_vp, mat_vs, mat_rho
def misfit(phase_1_fraction): # Here we define the rock as before. phase_2_fraction = 1.0-phase_1_fraction rock = burnman.Composite([phase_1_fraction, phase_2_fraction], [minerals.SLB_2011.stishovite(), minerals.SLB_2011.wuestite()]) # Just as in step 1, we want to set which equation of state we use, # then call burnman.velocities_from_rock, which evaluates the # elastic properties and seismic velocities at the predefined # pressures and temperatures rock.set_method('slb3') density, vp, vs, vphi, K, G = burnman.velocities_from_rock(rock, pressure, temperature) # Since we will call this misfit function many times, we may be interested # in a status report. These lines print some debug output so we # can keep track of what the script is doing. print "Calculations are done for:" rock.debug_print() # Here we integrate an L2 difference with depth between our calculated seismic # profiles and PREM. We then return those misfits. [vs_err, vphi_err, rho_err]=burnman.compare_l2(depths,[vs,vphi,density],[seis_vs,seis_vphi,seis_rho]) return vs_err, vphi_err, rho_err
def calc_velocities(a,b,c): amount_perovskite = a rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite], [minerals.SLB_2005.mg_fe_perovskite(b), minerals.SLB_2005.ferropericlase(c)]) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock(rock,seis_p, temperature) return mat_vp, mat_vs, mat_rho
def eval(uncertain): rock = burnman.composite ( [ (my_perovskite(uncertain), 1.0) ]) rock.set_method('slb3') temperature = burnman.geotherm.adiabatic(seis_p,1900*uncertain[8],rock) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.voigt_reuss_hill()) return seis_p, mat_vs, mat_vphi, mat_rho
def calc_velocities(a,b,c): method = 'slb3' #slb3|slb2|mgd3|mgd2 amount_perovskite = a rock = burnman.composite( [ ( minerals.SLB_2005.mg_fe_perovskite(b), amount_perovskite ), (minerals.SLB_2005.ferropericlase(c), 1.0-amount_perovskite) ] ) rock.set_method(method) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock(rock,seis_p, temperature) return mat_vp, mat_vs, mat_rho
def test_1(self): rock = burnman.composite ( ( (mypericlase(), 1.0),) ) rock.set_method('slb3') rho, v_p, v_s, v_phi, K_vrh, G_vrh = \ burnman.velocities_from_rock(rock, [10e9,], [300,]) self.assertAlmostEqual(3791.392, rho[0], 2) self.assertAlmostEqual(10285.368, v_p[0], 2) self.assertAlmostEqual(6308.811, v_s[0], 2) self.assertAlmostEqual(7260.900, v_phi[0], 2) self.assertAlmostEqual(199.884, K_vrh[0]/1.e9, 2) self.assertAlmostEqual(150.901, G_vrh[0]/1.e9, 2)
def test_two_different(self): rock = burnman.composite ( [ (minerals.SLB_2005.periclase(), 1.0), (minerals.SLB_2005.fe_perovskite(), 0.0) ] ) rock.set_method('slb3') rho, v_p, v_s, v_phi, K_vrh, G_vrh = \ burnman.velocities_from_rock(rock,[10e9,], [300,]) self.assertAlmostEqual(3791.392, rho[0], 2) self.assertAlmostEqual(10285.368, v_p[0], 2) self.assertAlmostEqual(6308.811, v_s[0], 2) self.assertAlmostEqual(7260.900, v_phi[0], 2) self.assertAlmostEqual(199.884, K_vrh[0]/1.e9, 2) self.assertAlmostEqual(150.901, G_vrh[0]/1.e9, 2)
def _evaluate_eos(self, pressures, temperatures, radii): #Evaluates the equation of state for each radius slice of the model. #Returns density, bulk sound speed, and shear speed. rho = np.empty_like(radii) bulk_sound_speed = np.empty_like(radii) shear_velocity = np.empty_like(radii) for i in range(len(radii)): density = vp = vs = vphi = K = G = 0. if radii[i] > self.cmb: density, vp, vs, vphi, K, G = burnman.velocities_from_rock(self.mantle, np.array([pressures[i]]), np.array([temperatures[i]])) else: density, vp, vs, vphi, K, G = burnman.velocities_from_rock(self.core, np.array([pressures[i]]), np.array([temperatures[i]])) rho[i] = density bulk_sound_speed[i] = vphi shear_velocity[i] = vs return rho, bulk_sound_speed, shear_velocity
def __init__(self): w = [.2,0.,.8]; m = np.array([mS,mSi,mFe]) x = w_to_x(w,m) molar_mass = np.sum( x * m ) / 1000. lFe = liquid_iron() lFeS10 = liquid_iron_sulfide10() p = 0. t = lFeS10.params['T_0'] lFe.set_method('slb3');lFeS10.set_method('slb3') burnman.velocities_from_rock(lFe,np.array([p]),np.array([t])) burnman.velocities_from_rock(lFeS10,np.array([p]),np.array([t])) # mol fraction of each f = w_to_x([.1,0.,.9],m)[0] / x[0] Kp0 = lFe.params['Kprime_0']; Kp10 = lFeS10.params['Kprime_0'] V20 = ( lFeS10.V - (1.-f)*lFe.V ) / f K20 = ( lFeS10.K_T - (1.-f)*lFe.K_T ) / f # Kp20 = ( Kp0 - (1.-f)*Kp10 ) / f gamma20 = lFeS10.grueneisen_parameter() self.params = { 'equation_of_state':'slb3', 'T_0': t, 'V_0': V20, 'K_0': K20, 'Kprime_0': 3.7,# manually chose to reproduce 10 wt % result 'G_0': 0., 'Gprime_0': 0., 'molar_mass': molar_mass, 'n': 1, 'Debye_0': 10., # C_v -> 3R 'grueneisen_0': gamma20, 'q_0': 1.4, 'eta_s_0': 0. , 'mole_fraction' : x[0], 'weight_percent' : w[0]}
def calc_velocities(a, b, c): method = 'slb3' #slb3|slb2|mgd3|mgd2 amount_perovskite = a rock = burnman.composite([ (minerals.SLB_2005.mg_fe_perovskite(b), amount_perovskite), (minerals.SLB_2005.ferropericlase(c), 1.0 - amount_perovskite) ]) rock.set_method(method) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock( rock, seis_p, temperature) return mat_vp, mat_vs, mat_rho
def evaluate_eos(self): ''' Find densities for a given set of pressures, temperatures This does not require the radii to have been determined yet. ''' # assert(self.radius[-1] == self.boundaries[-1] and self.radius[0] == 0. ) for c in self.compositions: assert( isinstance(c,burnman.Material) ), "Expected burnman.Material object" # iterate over layers last = -1. for bound,comp in zip(self.massBelowBoundary,self.compositions): if bound == 0.: comp = self.compositions[1] layer = (self.int_mass > last) & ( self.int_mass <= bound) mrange = self.int_mass[ layer ] #range in int_mass within the layer drange = np.empty_like(mrange) vprange = np.empty_like(mrange) vsrange = np.empty_like(mrange) vphirange = np.empty_like(mrange) Krange = np.empty_like(mrange) Grange = np.empty_like(mrange) prange = self.pressure[ layer ] trange = self.temperature[ layer ] for i in range(len(mrange)): rho, vp, vs, vphi, K, G = burnman.velocities_from_rock(comp, np.array([prange[i]]), np.array([trange[i]])) drange[i] = rho vprange[i] = vp vsrange[i] = vs vphirange[i] = vphi Krange[i] = K Grange[i] = G # print rho, vp, vs, vphi, K, G # set the self.density within the layer self.density[layer] = drange self.vp[layer] = vprange self.vs[layer] = vsrange self.vphi[layer] = vphirange self.K[layer] = Krange self.G[layer] = Grange last = bound # update last boundary
def calculate_forward_problem(frac, pressures): print frac rock = burnman.composite([ (minerals.SLB_2011.mg_perovskite(), frac[2] * frac[0]), (minerals.SLB_2011.fe_perovskite(), frac[2] * (1.0 - frac[0])), (minerals.SLB_2011.periclase(), (1.0 - frac[2])), (minerals.SLB_2011.wuestite(), 0.0 * (1.0 - frac[2]) * (1.0 - frac[0])) ]) rock.set_method('slb3') temperature = burnman.geotherm.self_consistent(pressures, frac[1], rock) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock( rock, pressures, temperature) return mat_rho, mat_vs, mat_vphi
def calc_velocities(ref_rho, K_0, K_prime, G_0, G_prime): rock = burnman.Mineral() rock.params['V_0'] = 10.e-6 rock.params['molar_mass'] = ref_rho*rock.params['V_0'] rock.params['K_0'] = K_0 rock.params['Kprime_0'] = K_prime rock.params['G_0'] = G_0 rock.params['Gprime_0'] = G_prime rock.set_method('bm3') temperature = np.empty_like(seis_p) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock(rock,seis_p, temperature) return mat_rho, mat_vphi, mat_vs
def material_error(amount_perovskite): rock = burnman.composite ( [ (minerals.Murakami_etal_2012.fe_perovskite(), amount_perovskite), (minerals.Murakami_etal_2012.fe_periclase(), 1.0 - amount_perovskite) ] ) rock.set_method(method) print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.voigt_reuss_hill()) #[rho_err,vphi_err,vs_err]=burnman.compare_chifactor([mat_vs,mat_vphi,mat_rho],[seis_vs,seis_vphi,seis_rho]) [rho_err,vphi_err,vs_err]=burnman.compare_l2(depths,[mat_vs,mat_vphi,mat_rho],[seis_vs,seis_vphi,seis_rho]) return vs_err, vphi_err
def material_error(amount_perovskite): #Define composition using the values from Murakami et al. 2012 (Note: fe_perovskite and fe_periclase do not represent pure iron #endmembers here, but contain 6% and 20% Fe respectively. rock = burnman.Composite([amount_perovskite, 1.0-amount_perovskite], [minerals.Murakami_etal_2012.fe_perovskite(), minerals.Murakami_etal_2012.fe_periclase()]) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.VoigtReussHill()) print "Calculations are done for:" rock.debug_print() [vs_err, vphi_err, rho_err] = \ burnman.compare_l2(depths, [mat_vs,mat_vphi,mat_rho], [seis_vs,seis_vphi,seis_rho]) return vs_err, vphi_err
def calc_velocities(ref_rho, K_0, K_prime, G_0, G_prime): test = burnman.minerals_base.material() test.params['V_0'] = 10.e-6 test.params['molar_mass'] = ref_rho*test.params['V_0'] test.params['K_0'] = K_0 test.params['Kprime_0'] = K_prime test.params['G_0'] = G_0 test.params['Gprime_0'] = G_prime rock = burnman.composite( [(test, 1.0 )] ) rock.set_method('bm3') temperature = np.empty_like(seis_p) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock(rock,seis_p, temperature) return mat_rho, mat_vphi, mat_vs
def eval_material(amount_perovskite): # rock = burnman.composite ( [ (minerals.Murakami_etal_2012.fe_perovskite(), amount_perovskite), # (minerals.Murakami_etal_2012.fe_periclase(), 1.0 - amount_perovskite) ] ) rock = burnman.composite ( [ (minerals.SLB_2011_ZSB_2013.mg_fe_perovskite(0.07), amount_perovskite), (minerals.SLB_2011.ferropericlase(0.2), 1.0 - amount_perovskite) ] ) # rock = burnman.composite ( [ (minerals.SLB_2011.mg_fe_perovskite(0.), amount_perovskite), # (minerals.SLB_2011.ferropericlase(1.0), 1.0 - amount_perovskite) ] ) rock.set_method(method) temperature = burnman.geotherm.adiabatic(seis_p,1900,rock) print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.voigt_reuss_hill()) #[rho_err,vphi_err,vs_err]=burnman.compare_chifactor(mat_vs,mat_vphi,mat_rho,seis_vs,seis_vphi,seis_rho) return seis_p, mat_vs, mat_vphi, mat_rho
def eval_material(amount_perovskite): # rock = burnman.composite ( [ (minerals.Murakami_etal_2012.fe_perovskite(), amount_perovskite), # (minerals.Murakami_etal_2012.fe_periclase(), 1.0 - amount_perovskite) ] ) rock = burnman.composite([ (minerals.SLB_2011.mg_fe_perovskite(0.08), amount_perovskite), (minerals.SLB_2011.ferropericlase(0.21), 1.0 - amount_perovskite) ]) # rock = burnman.composite ( [ (minerals.SLB_2011.mg_fe_perovskite(0.), amount_perovskite), # (minerals.SLB_2011.ferropericlase(1.0), 1.0 - amount_perovskite) ] ) rock.set_method(method) temperature = burnman.geotherm.adiabatic(seis_p, 1900, rock) print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.voigt_reuss_hill()) #[rho_err,vphi_err,vs_err]=burnman.compare_chifactor(mat_vs,mat_vphi,mat_rho,seis_vs,seis_vphi,seis_rho) return seis_p, mat_vs, mat_vphi, mat_rho
def calc_velocities(mg_pv_K,mg_pv_K_prime,mg_pv_G,mg_pv_G_prime,fe_pv_K,fe_pv_K_prime,fe_pv_G,fe_pv_G_prime): method = 'slb3' #slb3|slb2|mgd3|mgd2 amount_perovskite = 0.95 rock = burnman.composite( [ ( minerals.SLB_2005.mg_fe_perovskite(0.1), amount_perovskite ), (minerals.SLB_2005.ferropericlase(0.5), 1.0-amount_perovskite) ] ) mg_pv = rock.staticphases[0].mineral.base_materials[0] fe_pv = rock.staticphases[0].mineral.base_materials[1] mg_pv.params['K_0'] = mg_pv_K mg_pv.params['Kprime_0'] = mg_pv_K_prime mg_pv.params['G_0'] = mg_pv_G mg_pv.params['Gprime_0'] = mg_pv_G_prime fe_pv.params['K_0'] = fe_pv_K fe_pv.params['Kprime_0'] = fe_pv_K_prime fe_pv.params['G_0'] = fe_pv_G fe_pv.params['Gprime_0'] = fe_pv_G_prime rock.set_method(method) mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock(rock,seis_p, temperature) return mat_vp, mat_vs, mat_rho
# which contains the logic to switch between two other minerals based on the # current pressure. The mineral is implemented similar to the following lines: # # class Murakami_fe_periclase(helper_spin_transition): # def __init__(self): # helper_spin_transition.__init__(self, 63.0e9, Murakami_fe_periclase_LS(), Murakami_fe_periclase_HS()) # # Note the reference to the low spin and high spin minerals (_LS and _HS). # Set method, here set to 'slb2' as the shear wave moduli in # Murakami et al. 2012 were fit to second order rock.set_method("slb2") # Now we calculate the velocities mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = burnman.velocities_from_rock( rock, seis_p, temperature, burnman.averaging_schemes.VoigtReussHill() ) print "Calculations are done for:" rock.debug_print() # plot example 1 plt.subplot(2, 2, 1) plt.plot( seis_p / 1.0e9, mat_vs / 1.0e3, color="b", linestyle="-", marker="o", markerfacecolor="b", markersize=4,
periclasite = burnman.composite(((ferropericlase(0.21), 1.0), )) periclasite.set_method(method) #pyrolite (80% perovskite) pyrolite = burnman.composite( ((perovskite(0.06), 0.834), (ferropericlase(0.21), 0.166))) pyrolite.set_method(method) #preferred mixture? amount_perovskite = 0.92 preferred_mixture = burnman.composite( ((perovskite(0.06), amount_perovskite), (ferropericlase(0.21), 1.0 - amount_perovskite))) preferred_mixture.set_method(method) mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = burnman.velocities_from_rock( perovskitite, seis_p, temperature_bs) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = burnman.velocities_from_rock( periclasite, seis_p, temperature_bs) mat_rho_3, mat_vp_3, mat_vs_3, mat_vphi_3, mat_K_3, mat_G_3 = burnman.velocities_from_rock( pyrolite, seis_p, temperature_bs) mat_rho_4, mat_vp_4, mat_vs_4, mat_vphi_4, mat_K_4, mat_G_4 = burnman.velocities_from_rock( preferred_mixture, seis_p, temperature_bs) ### HERE IS THE STEP WITH THE INCORRECT MIXING ### # comment this out to have correct phase averaging, leave it in to have incorrect phase averaging mat_vs_3_wr = 0.5 * ( (0.834 * mat_vs_1 + 0.166 * mat_vs_2) + np.ones_like(mat_vs_1) / (0.834 / mat_vs_1 + 0.166 / mat_vs_2)) mat_vs_4_wr = 0.5 * ( (0.92 * mat_vs_1 + 0.08 * mat_vs_2) + np.ones_like(mat_vs_1) /
#input second pressure range. Same as the first for comparison seis_p_2 = seis_p_1 #input your geotherm. temperature_2 = burnman.geotherm.brown_shankland(seis_p_2) #Now we'll calculate the models. mat_rho_pyro, mat_vp_pyro, mat_vs_pyro, mat_vphi_pyro, mat_K_pyro, mat_G_pyro = \ burnman.velocities_from_rock(pyrolite, seis_p_1, temperature_1, \ burnman.averaging_schemes.VoigtReussHill()) print "Calculations are done for:" pyrolite.debug_print() mat_rho_enst, mat_vp_enst, mat_vs_enst, mat_vphi_enst, mat_K_enst, mat_G_enst = \ burnman.velocities_from_rock(enstatite, seis_p_2, temperature_2, \ burnman.averaging_schemes.VoigtReussHill()) print "Calculations are done for:" enstatite.debug_print() ##let's create PREM for reference
# At this point we want to tell the rock which equation of state to use for # its thermoelastic calculations. In general, we recommend the 'slb3' # equation of state as the most self-consistent model. The parameters from # the SLB_2011 mineral library are fit using this model. rock.set_method('slb3') # Here is the step which does the heavy lifting. burnman.velocities_from_rock # sets the state of the rock at each of the pressures and temperatures defined, # then calculates the elastic moduli and density of each individual phase. After that, # it performs elastic averaging on the phases to get a single bulk and shear # modulus for the rock. This averaging scheme defaults to Voigt-Reuss-Hilli, # but see example_averaging.py for other options. Finally, it calculates the seismic # wave speeds for the whole rock. It returns a tuple of density, p-wave velocity # s-wave velocity, bulk sound speed, bulk modulus, and shear modulus. density, vp, vs, vphi, K, G = burnman.velocities_from_rock( rock, pressure, temperature) # All the work is done except the plotting! Here we want to plot the seismic wave # speeds and the density against PREM using the matplotlib plotting tools. We make # a 2x2 array of plots. The fourth subplot plots the geotherm used for this calculation. # First, we plot the s-wave speed verses the PREM s-wave speed plt.subplot(2, 2, 1) plt.plot(pressure / 1.e9, vs / 1.e3, color='b', linestyle='-', marker='o', markerfacecolor='b', markersize=4, label='computation')
#input second pressure range. Same as the first for comparison seis_p_2 = seis_p_1 #input your geotherm. temperature_2 = burnman.geotherm.brown_shankland(seis_p_2) #Now we'll calculate the models. pyrolite.set_method(method) mat_rho_pyro, mat_vp_pyro, mat_vs_pyro, mat_vphi_pyro, mat_K_pyro, mat_G_pyro = \ burnman.velocities_from_rock(pyrolite, seis_p_1, temperature_1, \ burnman.averaging_schemes.voigt_reuss_hill()) print "Calculations are done for:" pyrolite.debug_print() enstatite.set_method(method) print "Calculations are done for:" enstatite.debug_print() mat_rho_enst, mat_vp_enst, mat_vs_enst, mat_vphi_enst, mat_K_enst, mat_G_enst = \ burnman.velocities_from_rock(enstatite, seis_p_2, temperature_2, \ burnman.averaging_schemes.voigt_reuss_hill()) ##let's create PREM for reference s = burnman.seismic.prem()
i+=1 plt.savefig('good.png') #plt.show() figsize=(8,6) figure=plt.figure(dpi=150,figsize=figsize) for fit in goodfits: print fit print names rock, anchor_t = array_to_rock(fit, names) temperature = burnman.geotherm.adiabatic(pressure, anchor_t, rock) rho, vp, vs, vphi, K, G = \ burnman.velocities_from_rock(rock, pressure, temperature, burnman.averaging_schemes.hashin_shtrikman_average()) print "." plt.plot(pressure/1.e9,vs/1.e3,linestyle="-",color='r',linewidth=1.0) plt.plot(pressure/1.e9,vphi/1.e3,linestyle="-",color='b',linewidth=1.0) plt.plot(pressure/1.e9,rho/1.e3,linestyle="-",color='g',linewidth=1.0) print "done!" #plot v_s plt.plot(pressure/1.e9,seis_vs/1.e3,linestyle="--",color='k',linewidth=2.0,label='PREM') #plot v_phi plt.plot(pressure/1.e9,seis_vphi/1.e3,linestyle="--",color='k',linewidth=2.0,label='PREM')
# class Murakami_fe_periclase(helper_spin_transition): # def __init__(self): # helper_spin_transition.__init__(self, 63.0e9, Murakami_fe_periclase_LS(), Murakami_fe_periclase_HS()) # # Note the reference to the low spin and high spin minerals (_LS and _HS). # Set method, here set to 'slb2' as the shear wave moduli in # Murakami et al. 2012 were fit to second order rock.set_method('slb2') # Now we calculate the velocities print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, seis_p, temperature, burnman.averaging_schemes.voigt_reuss_hill()) # plot example 1 plt.subplot(2,2,1) plt.plot(seis_p/1.e9,mat_vs/1.e3,color='b',linestyle='-',marker='o',\ markerfacecolor='b',markersize=4,label='Vs') plt.plot(seis_p/1.e9,mat_vphi/1.e3,color='r',linestyle='-',marker='o',\ markerfacecolor='r',markersize=4, label='Vp') plt.plot(seis_p/1.e9,mat_rho/1.e3,color='k',linestyle='-',marker='o',\ markerfacecolor='k',markersize=4, label='rho') plt.title("ferropericlase (Murakami et al. 2012)") plt.xlim(min(seis_p)/1.e9,max(seis_p)/1.e9) plt.ylim(5,12) plt.legend(loc='upper left') # example 2: Here we show the effects of using purely High Spin or Low Spin
# Now we get an array of temperatures at which will be used for computing # the seismic properties of the rock. Here we use the Brown+Shankland (1981) # geotherm for mapping pressure to temperature temperature = burnman.geotherm.brown_shankland(pressure) # Here is the step which does the heavy lifting. burnman.velocities_from_rock # sets the state of the rock at each of the pressures and temperatures defined, # then calculates the elastic moduli and density of each individual phase. After that, # it performs elastic averaging on the phases to get a single bulk and shear # modulus for the rock. This averaging scheme defaults to Voigt-Reuss-Hilli, # but see example_averaging.py for other options. Finally, it calculates the seismic # wave speeds for the whole rock. It returns a tuple of density, p-wave velocity # s-wave velocity, bulk sound speed, bulk modulus, and shear modulus. density, vp, vs, vphi, K, G = burnman.velocities_from_rock(rock, pressure, temperature) # All the work is done except the plotting! Here we want to plot the seismic wave # speeds and the density against PREM using the matplotlib plotting tools. We make # a 2x2 array of plots. The fourth subplot plots the geotherm used for this calculation. # First, we plot the s-wave speed verses the PREM s-wave speed plt.subplot(2,2,1) plt.plot(pressure/1.e9,vs/1.e3,color='b',linestyle='-',marker='o', markerfacecolor='b',markersize=4,label='computation') plt.plot(pressure/1.e9,seis_vs/1.e3,color='k',linestyle='-',marker='o', markerfacecolor='k',markersize=4,label='reference') plt.title("S wave speed (km/s)") plt.xlim(min(pressure)/1.e9,max(pressure)/1.e9) plt.legend(loc='lower right') plt.ylim(5,8.0)
depths = np.linspace(700e3, 2800e3, number_of_points) #alternatively, we could use the values where prem is defined: #depths = seismic_model.internal_depth_list() pressures, seis_rho, seis_vp, seis_vs, seis_vphi = seismic_model.evaluate_all_at(depths) temperatures = burnman.geotherm.brown_shankland(pressures) print "Calculations are done for:" rock.debug_print() #calculate the seismic velocities of the rock using a whole battery of averaging schemes: # do the end members, here averaging scheme does not matter (though it defaults to Voigt-Reuss-Hill) rho_pv, vp_pv, vs_pv, vphi_pv, K_pv, G_pv = \ burnman.velocities_from_rock(perovskitite, pressures, temperatures) rho_fp, vp_fp, vs_fp, vphi_fp, K_fp, G_fp = \ burnman.velocities_from_rock(periclasite, pressures, temperatures) #Voigt Reuss Hill averaging rho_vrh, vp_vrh, vs_vrh, vphi_vrh, K_vrh, G_vrh = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.voigt_reuss_hill()) #Voigt averaging rho_v, vp_v, vs_v, vphi_v, K_v, G_v = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.voigt()) #Reuss averaging rho_r, vp_r, vs_r, vphi_r, K_r, G_r = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.reuss())
p, seis_rho, seis_vp, seis_vs, seis_vphi = seismic_model.evaluate_all_at(depths) # Now we get an array of temperatures at which will be used for computing # the seismic properties of the rock. T = np.linspace(1900,2400,15) print "pressures:\n", p print "temperatures:\n", T # turn grid into array: tarray=np.tile(T,len(p)) parray=np.repeat(p,len(T)) rock.set_method('slb3') density, vp, vs, vphi, K, G = burnman.velocities_from_rock(rock, parray, tarray) mat_vs = np.reshape(vs,[len(p),len(T)]); print mat_vs fig = plt.figure() ax = fig.gca(projection='3d') X,Y = np.meshgrid(p/1e9, T) print X.shape, Y.shape, mat_vs.shape surf = ax.plot_surface(X,Y, mat_vs.transpose(), rstride=1, cstride=1, linewidth=1, cmap=cm.coolwarm) plt.xlabel("Pressure (GPa)") plt.ylabel("Temperature")
print row, "& %g && %g && %g && %g & \\"%(val[0],val[1],val[2],val[3]) dashstyle2=(7,3) dashstyle3=(3,2) fit = [] lit = [] for n in names: fit.append(mymap[n]) lit.append(mymaplit[n]) rock, anchor_t = array_to_rock(fit, names) temperature = burnman.geotherm.adiabatic(pressure, anchor_t, rock) rho, vp, vs, vphi, K, G = \ burnman.velocities_from_rock(rock, pressure, temperature, burnman.averaging_schemes.HashinShtrikmanAverage()) err_vs, err_vphi, err_rho = burnman.compare_l2(depths/np.mean(depths), [vs/np.mean(seis_vs), vphi/np.mean(seis_vphi), rho/np.mean(seis_rho)], [seis_vs/np.mean(seis_vs), seis_vphi/np.mean(seis_vphi), seis_rho/np.mean(seis_rho)]) error = np.sum([err_rho, err_vphi, err_vs]) print "errors:", error, err_rho, err_vphi, err_vs figsize=(6,5) prop={'size':12} plt.rc('text', usetex=True)
depths = np.linspace(700e3, 2800e3, number_of_points) #alternatively, we could use the values where prem is defined: #depths = seismic_model.internal_depth_list() pressures, seis_rho, seis_vp, seis_vs, seis_vphi = seismic_model.evaluate_all_at(depths) temperatures = burnman.geotherm.brown_shankland(pressures) print "Calculations are done for:" rock.debug_print() #calculate the seismic velocities of the rock using a whole battery of averaging schemes: # do the end members, here averaging scheme does not matter (though it defaults to Voigt-Reuss-Hill) rho_pv, vp_pv, vs_pv, vphi_pv, K_pv, G_pv = \ burnman.velocities_from_rock(perovskitite, pressures, temperatures) rho_fp, vp_fp, vs_fp, vphi_fp, K_fp, G_fp = \ burnman.velocities_from_rock(periclasite, pressures, temperatures) #Voigt Reuss Hill averaging rho_vrh, vp_vrh, vs_vrh, vphi_vrh, K_vrh, G_vrh = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.VoigtReussHill()) #Voigt averaging rho_v, vp_v, vs_v, vphi_v, K_v, G_v = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.Voigt()) #Reuss averaging rho_r, vp_r, vs_r, vphi_r, K_r, G_r = \ burnman.velocities_from_rock(rock, pressures, temperatures, averaging_scheme=burnman.averaging_schemes.Reuss())
matas et al. 2007) or 'mgd2' (mie-gruneisen-debeye 2nd order shear modulus, matas et al. 2007) or 'bm2' (birch-murnaghan 2nd order, if you choose to ignore temperature (your choice in geotherm will not matter in this case)) or 'bm3' (birch-murnaghan 3rd order, if you choose to ignore temperature (your choice in geotherm will not matter in this case))""" rock.set_method('mgd3') temperature = burnman.geotherm.adiabatic(seis_p, T0, rock) print "Calculations are done for:" rock.debug_print() mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = \ burnman.velocities_from_rock(rock, seis_p, temperature, \ burnman.averaging_schemes.voigt_reuss_hill()) rock.set_method('slb2') temperature = burnman.geotherm.adiabatic(seis_p, T0, rock) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = \ burnman.velocities_from_rock(rock, seis_p, temperature, \ burnman.averaging_schemes.voigt_reuss_hill()) rock.set_method('slb3') temperature = burnman.geotherm.adiabatic(seis_p, T0, rock) mat_rho_3, mat_vp_3, mat_vs_3, mat_vphi_3, mat_K_3, mat_G_3 = \ burnman.velocities_from_rock(rock, seis_p, temperature, \ burnman.averaging_schemes.voigt_reuss_hill())
(minerals.Murakami_etal_2012.fe_periclase(), 1.0 - amount_perovskite_4))) rock_4.set_method(method) #input pressure range for first model. This could be from a seismic model or something you create. For this example we will create an array seis_p_4 = seis_p_1 #input your geotherm. Either choose one (See example_geotherms.py) or create one.We'll use Brown and Shankland. #Now we'll calculate the models. T0 = 1600. temperature_1 = burnman.geotherm.adiabatic(seis_p_1, T0, rock_1) mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = burnman.velocities_from_rock( rock_1, seis_p_1, temperature_bs) mat_rho_1a, mat_vp_1a, mat_vs_1a, mat_vphi_1a, mat_K_1a, mat_G_1a = burnman.velocities_from_rock( rock_1, seis_p_1, temperature_an) temperature_2 = burnman.geotherm.adiabatic(seis_p_1, T0, rock_2) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = burnman.velocities_from_rock( rock_2, seis_p_2, temperature_bs) mat_rho_2a, mat_vp_2a, mat_vs_2a, mat_vphi_2a, mat_K_2a, mat_G_2a = burnman.velocities_from_rock( rock_2, seis_p_2, temperature_an) temperature_3 = burnman.geotherm.adiabatic(seis_p_1, T0, rock_3) mat_rho_3, mat_vp_3, mat_vs_3, mat_vphi_3, mat_K_3, mat_G_3 = burnman.velocities_from_rock( rock_3, seis_p_3, temperature_bs)
# (minerals.Matas_periclase(), .1656 ), # (minerals.Matas_wuestite(), .0124 ))) #input pressure range for first model. This could be from a seismic model or something you create. For this example we will create an array rock.set_method(method) rock2.set_method(method) seis_p_1 = np.arange(28e9, 128e9, 4.8e9) temperature_bs = burnman.geotherm.brown_shankland(seis_p_1) #Now we'll calculate the models. T0 = 0. temperature_1 = burnman.geotherm.adiabatic(seis_p_1, T0, rock) mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = burnman.velocities_from_rock(rock,seis_p_1, temperature_1) temperature_2 = burnman.geotherm.adiabatic(seis_p_1, T0, rock2) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = burnman.velocities_from_rock(rock2,seis_p_1, temperature_2) prem=burnman.seismic.prem() depths=map(prem.depth,seis_p_1) prem_p, prem_rho, prem_vp, prem_vs, prem_vphi = prem.evaluate_all_at(depths) ##Now let's plot the comparison. You can conversely just output to a data file (see example_woutput.py) plt.subplot(2,2,2) plt.plot(seis_p_1/1.e9,prem_vs/1.e3,color='g',linestyle='-',label='ak135') plt.plot(seis_p_1/1.e9,mat_vs_1/1.e3,color='b',linestyle='-',label='rock') # plt.plot(seis_p_1/1.e9,mat_vs_2/1.e3,color='r',linestyle='-',label='rock2')
.078 / 1.46), (minerals.Matas_etal_2007.periclase(), .268), (minerals.Matas_etal_2007.wuestite(), .034 / 1.46))) #KD is 2... doesn't match either #rock2 = burnman.composite( ( (minerals.Matas_mg_perovskite(),.3574 ), # (minerals.Matas_fe_perovskite(), .0536 ), # (minerals.Matas_periclase(), .1656 ), # (minerals.Matas_wuestite(), .0124 ))) #input pressure range for first model. This could be from a seismic model or something you create. For this example we will create an array rock.set_method(method) rock2.set_method(method) seis_p_1 = np.arange(28e9, 128e9, 4.8e9) temperature_bs = burnman.geotherm.brown_shankland(seis_p_1) #Now we'll calculate the models. mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = burnman.velocities_from_rock( rock, seis_p_1, temperature_bs) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = burnman.velocities_from_rock( rock2, seis_p_1, temperature_bs) #Next, we calculate the velocites with 3rd order Birch-Murnaghan method = 'mgd2' rock.set_method(method) rock2.set_method(method) mat_rho_1_3, mat_vp_1_3, mat_vs_1_3, mat_vphi_1_3, mat_K_1_3, mat_G_1_3 = burnman.velocities_from_rock( rock, seis_p_1, temperature_bs) mat_rho_2_3, mat_vp_2_3, mat_vs_2_3, mat_vphi_2_3, mat_K_2_3, mat_G_2_3 = burnman.velocities_from_rock( rock2, seis_p_1, temperature_bs) # seismic velocities for comparison class ak135_table(burnman.seismic.radiustable): def __init__(self):
amount_perovskite = 0.95 rock = burnman.composite( [(minerals.SLB_2005.mg_fe_perovskite(0.7), amount_perovskite), (minerals.SLB_2005.ferropericlase(0.5), 1.0-amount_perovskite) ] ) #define some pressure range pressures = np.arange(25e9,130e9,5e9) temperature = burnman.geotherm.brown_shankland(pressures) rock.set_method(method) #append method of calculation to suite of minerals chosen #Begin calculating velocities and density as depth print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, pressures, temperature, \ burnman.averaging_schemes.voigt_reuss_hill()) #write to file: output_filename = "example_woutput.txt" f = open(output_filename, 'wb') f.write("#Pressure\tTemperature\tmat_rho\tmat_vs\tmat_vp\tmat_vphi\tmat_K\tmat_G\n") data = zip(pressures,temperature,mat_rho, mat_vs, mat_vp, mat_vphi, mat_K, mat_G) np.savetxt(f, data, fmt='%.10e', delimiter='\t') print "\nYour data has been saved as: ",output_filename
periclasite = burnman.Composite( ( (ferropericlase(0.21), 1.0),)) periclasite.set_method(method) #pyrolite (80% perovskite) pyrolite = burnman.Composite( ( (perovskite(0.06), 0.834), (ferropericlase(0.21), 0.166) ) ) pyrolite.set_method(method) #preferred mixture? amount_perovskite = 0.92 preferred_mixture = burnman.Composite( ( (perovskite(0.06), amount_perovskite), (ferropericlase(0.21), 1.0-amount_perovskite) ) ) preferred_mixture.set_method(method) mat_rho_1, mat_vp_1, mat_vs_1, mat_vphi_1, mat_K_1, mat_G_1 = burnman.velocities_from_rock(perovskitite,seis_p, temperature_bs) mat_rho_2, mat_vp_2, mat_vs_2, mat_vphi_2, mat_K_2, mat_G_2 = burnman.velocities_from_rock(periclasite,seis_p, temperature_bs) mat_rho_3, mat_vp_3, mat_vs_3, mat_vphi_3, mat_K_3, mat_G_3 = burnman.velocities_from_rock(pyrolite,seis_p, temperature_bs) mat_rho_4, mat_vp_4, mat_vs_4, mat_vphi_4, mat_K_4, mat_G_4 = burnman.velocities_from_rock(preferred_mixture,seis_p, temperature_bs) ### HERE IS THE STEP WITH THE INCORRECT MIXING ### # comment this out to have correct phase averaging, leave it in to have incorrect phase averaging mat_vs_3_wr = 0.5*((0.834*mat_vs_1 + 0.166*mat_vs_2) + np.ones_like(mat_vs_1)/(0.834/mat_vs_1 + 0.166/mat_vs_2)) mat_vs_4_wr = 0.5*((0.92*mat_vs_1 + 0.08*mat_vs_2) + np.ones_like(mat_vs_1)/(0.92/mat_vs_1 + 0.08/mat_vs_2)) plt.subplot(1,2,2) plt.ylim(5.2,7.4) plt.xlim(25,135)
pc=minerals.SLB_2011.ferropericlase() pv.set_composition([1.-fe_pv,fe_pv,0.]) pc.set_composition([1.-fe_pc,fe_pc]) rock = burnman.Composite( [amount_perovskite, 1.0-amount_perovskite], [pv,pc] ) #define some pressure range pressures = np.arange(25e9,130e9,5e9) temperature = burnman.geotherm.brown_shankland(pressures) #Begin calculating velocities and density as depth print "Calculations are done for:" rock.debug_print() mat_rho, mat_vp, mat_vs, mat_vphi, mat_K, mat_G = \ burnman.velocities_from_rock(rock, pressures, temperature, \ burnman.averaging_schemes.VoigtReussHill()) #write to file: output_filename = "example_woutput.txt" f = open(output_filename, 'wb') f.write("#Pressure\tTemperature\tmat_rho\tmat_vs\tmat_vp\tmat_vphi\tmat_K\tmat_G\n") data = zip(pressures,temperature,mat_rho, mat_vs, mat_vp, mat_vphi, mat_K, mat_G) np.savetxt(f, data, fmt='%.10e', delimiter='\t') print "\nYour data has been saved as: ",output_filename