-
Notifications
You must be signed in to change notification settings - Fork 41
/
test_perplex.py
50 lines (38 loc) · 1.57 KB
/
test_perplex.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
from __future__ import absolute_import
import unittest
import os
import sys
import numpy as np
sys.path.insert(1, os.path.abspath('..'))
import warnings
import burnman
from burnman import minerals
from util import BurnManTest
# Predefine our rock
rock = burnman.PerplexMaterial('../burnman/data/input_perplex/in23_1.tab')
class PerpleX(BurnManTest):
def test_energies(self):
P = [10.e9, 11.e9]
A, G, V = rock.evaluate(['molar_helmholtz', 'molar_gibbs', 'V'],
P, [2000., 2000.])
self.assertArraysAlmostEqual(A, G - V*P)
def test_grueneisen(self):
gr, alpha, V, K_S, cp = rock.evaluate(['grueneisen_parameter', 'alpha', 'V', 'adiabatic_bulk_modulus', 'molar_heat_capacity_p'],
[10.e9, 11.e9], [2000., 2000.])
self.assertArraysAlmostEqual(gr, alpha*V*K_S/cp)
def test_bounds(self):
def fnLP():
return rock.set_state(rock.bounds[0][0] - 1., np.mean(rock.bounds[1]))
def fnHP():
return rock.set_state(rock.bounds[0][1] + 1., np.mean(rock.bounds[1]))
def fnLT():
return rock.set_state(np.mean(rock.bounds[0]), rock.bounds[1][0] - 1.)
def fnHT():
return rock.set_state(np.mean(rock.bounds[0]), rock.bounds[1][1] + 1.)
with np.errstate(all='ignore'):
self.assertRaises(Exception, fnLP)
self.assertRaises(Exception, fnHP)
self.assertRaises(Exception, fnLT)
self.assertRaises(Exception, fnHT)
if __name__ == '__main__':
unittest.main()