Skip to content

alpha_data

NoEosError

Bases: Exception

Exception type raised when eos string passed which does not match any given

Source code in terratools/alpha_data.py
13
14
15
16
17
18
19
20
class NoEosError(Exception):
    """
    Exception type raised when eos string passed which does not match any given
    """

    def __init(self, eos):
        self.message = f"alpha for equation of state '{eos}' not implemented."
        super().__init__(self.message)

alpha(eos, model)

Parameters:

Name Type Description Default
eos str

string to denote the equation of state

required
model TerraModel

radii of layers

required
Source code in terratools/alpha_data.py
 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
def alpha(eos, model):
    """
    :param eos: string to denote the equation of state
    :type eos: str
    :param model: radii of layers
    :type model: TerraModel
    """
    alph_eos = {
        "murnaghan": [
            3.7904e-05,
            3.6672e-05,
            3.5511e-05,
            3.4426e-05,
            3.3401e-05,
            3.2438e-05,
            3.1525e-05,
            3.0666e-05,
            2.9848e-05,
            2.9076e-05,
            2.8340e-05,
            2.7643e-05,
            2.6977e-05,
            2.6344e-05,
            2.5738e-05,
            2.5162e-05,
            2.4608e-05,
            2.4080e-05,
            2.3573e-05,
            2.3089e-05,
            2.2622e-05,
            2.2175e-05,
            2.1744e-05,
            2.1331e-05,
            2.0932e-05,
            2.0549e-05,
            2.0178e-05,
            1.9822e-05,
            1.9477e-05,
            1.9145e-05,
            1.8822e-05,
            1.8512e-05,
            1.8210e-05,
            1.7919e-05,
            1.7636e-05,
            1.7363e-05,
            1.7097e-05,
            1.6839e-05,
            1.6589e-05,
            1.6346e-05,
            1.6109e-05,
            1.5880e-05,
            1.5656e-05,
            1.5439e-05,
            1.5226e-05,
            1.5020e-05,
            1.4818e-05,
            1.4623e-05,
            1.4431e-05,
            1.4244e-05,
            1.4061e-05,
            1.3883e-05,
            1.3708e-05,
            1.3538e-05,
            1.3371e-05,
            1.3208e-05,
            1.3048e-05,
            1.2891e-05,
            1.2737e-05,
            1.2587e-05,
            1.2439e-05,
            1.2294e-05,
            1.2152e-05,
            1.2012e-05,
            1.1874e-05,
        ],
    }

    # check if passed in eos is implemented
    if eos.lower() not in alph_eos.keys():
        raise NoEosError(eos)

    a = alph_eos[eos.lower()]

    # The data in alph_eos is pasted from TERRA output files.
    # Layer indexing is reversed relative to the terra grid so need to flip
    a = np.flip(a)

    radii = model.get_radii()
    if len(radii) == len(a):
        return a
    else:
        interp = interp1d(np.linspace(np.max(radii), np.min(radii), len(a)), a)

        return interp(radii)