Source code for burnman.mineral_helpers

# This file is part of BurnMan - a thermoelastic and thermodynamic toolkit for the Earth and Planetary Sciences# Copyright (C) 2012 - 2017 by the BurnMan team, released under the GNU# GPL v2 or later."""This module provides several helper minerals/materials."""from__future__importabsolute_importfrom__future__importprint_functionfrom.materialimportMaterialfrom.compositeimportCompositefrom.materialimportMaterial,material_propertyclassHelperRockSwitcher(Material):""" A Helper that represents a Material that switches between different rocks based on a user specified select_rock() function based on current temperature and pressure. This class can be used in several ways: 1. By creating an instance and setting select_rock to a lambda that returns a rock 2. By deriving from this class and implementing select_rock. """def__init__(self):self.current_rock=NoneMaterial.__init__(self)defselect_rock(self):raiseNotImplementedError("Need to implement select_rock() in derived class!")defset_method(self,method):raiseNotImplementedError("Need to implement select_rock() in derived class!")defdebug_print(self,indent=""):print("%sHelperRockSwitcher"%(indent))defset_state(self,pressure,temperature):Material.set_state(self,pressure,temperature)self.current_rock=self.select_rock()self.current_rock.set_state(pressure,temperature)defunroll(self):returnself.current_rock.unroll()@material_propertydefinternal_energy(self):returnself.current_rock.internal_energy@material_propertydefmolar_gibbs(self):returnself.current_rock.molar_gibbs@material_propertydefmolar_helmholtz(self):returnself.current_rock.molar_helmholtz@material_propertydefmolar_mass(self):returnself.current_rock.molar_mass@material_propertydefmolar_volume(self):returnself.current_rock.molar_volume@material_propertydefdensity(self):returnself.current_rock.density@material_propertydefmolar_entropy(self):returnself.current_rock.molar_entropy@material_propertydefmolar_enthalpy(self):returnself.current_rock.molar_enthalpy@material_propertydefisothermal_bulk_modulus(self):returnself.current_rock.isothermal_bulk_modulus@material_propertydefadiabatic_bulk_modulus(self):returnself.current_rock.adiabatic_bulk_modulus@material_propertydefisothermal_compressibility(self):returnself.current_rock.isothermal_compressibility@material_propertydefadiabatic_compressibility(self):returnself.current_rock.adiabatic_compressibility@material_propertydefshear_modulus(self):returnself.current_rock.shear_modulus@material_propertydefp_wave_velocity(self):returnself.current_rock.p_wave_velocity@material_propertydefbulk_sound_velocity(self):returnself.current_rock.bulk_sound_velocity@material_propertydefshear_wave_velocity(self):returnself.current_rock.shear_wave_velocity@material_propertydefgrueneisen_parameter(self):returnself.current_rock.grueneisen_parameter@material_propertydefthermal_expansivity(self):returnself.current_rock.thermal_expansivity@material_propertydefheat_capacity_v(self):returnself.current_rock.heat_capacity_v@material_propertydefheat_capacity_p(self):returnself.current_rock.heat_capacity_pclassHelperLowHighPressureRockTransition(HelperRockSwitcher):""" A Helper that represents a Material that switches between two given rocks based on a given transition pressure. """def__init__(self,transition_pressure,low_pressure_rock,high_pressure_rock):self.transition_pressure=transition_pressureself.rocks=[low_pressure_rock,high_pressure_rock]HelperRockSwitcher.__init__(self)self._name="HelperLowHighPressureRockTransition("+str(self.transition_pressure)+" GPa, "+self.rocks[0].name+", "+self.rocks[1].name+")"defselect_rock(self):ifself._pressure<self.transition_pressure:returnself.rocks[0]else:returnself.rocks[1]defset_method(self,method):forrinself.rocks:r.set_method(method)defdebug_print(self,indent=""):print("%sHelperLowHighPressureRockTransition (%f GPa):"%(indent,self.transition_pressure))indent+=" "forrinself.rocks:r.debug_print(indent)

[docs]classHelperSpinTransition(Composite):""" Helper class that makes a mineral that switches between two materials (for low and high spin) based on some transition pressure [Pa] """def__init__(self,transition_pressure,ls_mat,hs_mat):""" Takes a transition pressure, and two minerals. Use the thermoelastic parameters for ls_mat below the transition pressure, and the thermoelastic parameters for hs_mat above the transition pressure """Material.__init__(self)self.transition_pressure=transition_pressureself.ls_mat=ls_matself.hs_mat=hs_matComposite.__init__(self,[ls_mat,hs_mat])