def setUp(self): warnings.simplefilter('ignore', category=ImportWarning) self.spline = lg.loadGibbsSpline('gsp_puresubstance.mat') self.mlout = load._stripNestingToFields( sio.loadmat('gsp2d_out.mat')['gsp2d_out']) self.P = np.arange(0, 3001, 200).astype(float) self.T = np.arange(0, 401, 50).astype(float)
def test_loadgibbs_3d_ScalarGo(self): gsp = lg.loadGibbsSpline('gsp_1scalarGo.mat') # just do a spot check of a field in the spline since it calls load.getSplineDict which is tested elsewhere self.assertTrue( np.array_equal(gsp['sp']['number'], np.array([29, 20, 14]))) self.assertTrue( np.array_equal(gsp['MW'], np.array([0.01801528, 0.05844]))) self.assertEqual(gsp['nu'], 2)
def setUp(self): warnings.simplefilter('ignore', category=ImportWarning) self.spline = lg.loadGibbsSpline('gsp_singlesolute.mat', 'sp_NaCl') self.mlout = load._stripNestingToFields( sio.loadmat('gsp3d_out.mat')['gsp3d_out']) self.P = np.arange(0.1, 8000, 200).astype(float) self.T = np.arange(239, 501, 50).astype(float) self.M = np.arange(0, 8, 2).astype(float)
import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams from mpl_toolkits.mplot3d import Axes3D from lbftd import statevars, loadGibbs as lg, evalGibbs as eg # load and evaluate the spline # this is a high-pressure spline that starts with IAPWS 95 below 1 GPa # but modifies it above 1 GPa to better match DAC and shockwave data water_spline = lg.loadGibbsSpline('water_demo_spline.mat') P = np.linspace(0, 1500, num=200) T = np.linspace(240, 500, num=200) # evaluate the spline at the requested P(ressure, in MPa) and T(emperature, in K) # requested thermodynamic state variables # (see README for full list of available state vars or don't list any to get the full set): # - rho: density in kg m^-3 # - Cp: isobaric specific heat in J kg^-1 K^-1 # - Kt: isothermal bulk modulus in MPa # - alpha: thermal expansivity in K-1 tdstate = eg.evalSolutionGibbsGrid(water_spline['sp'], np.array([P, T]), 'rho', 'Cp', 'Kt', 'alpha') # for full set of implemented statevars: eg.evalSolutionGibbsGrid(water_spline['sp'], np.array([P, T])) # graph the output rcParams[ 'axes.labelpad'] = 10 # add some padding to prevents axis labels from covering ticks fig = plt.figure() pP, pT = np.meshgrid(P, T) rho_ax = fig.add_subplot(221, projection='3d')
def test_loadgibbs_2d(self): gsp = lg.loadGibbsSpline('gsp_puresubstance.mat') self.assertTrue(np.array_equal(gsp['sp']['number'], np.array([50, 40]))) self.assertTrue(np.array_equal(gsp['MW'], np.array([0.01801528]))) self.assertFalse('nu' in gsp)
import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams from mpl_toolkits.mplot3d import Axes3D # even though this is not used directly, it is required to do 3d plots from lbftd import statevars, loadGibbs as lg, evalGibbs as eg # load and evaluate the spline # this is a high-pressure spline that starts with IAPWS 95 below 1 GPa # but modifies it above 1 GPa to better match DAC and shockwave data water_spline = lg.loadGibbsSpline('water_demo_iapws_modified.mat') P = np.linspace(0, 2000, num=200) # pressure, in MPa T = np.linspace(200, 1000, num=200) # temperature, in K # requested thermodynamic state variables # (see README for full list of available state vars or don't list any to get the full set): # - rho: density in kg m^-3 # - Cp: isobaric specific heat in J kg^-1 K^-1 # - Kt: isothermal bulk modulus in MPa # - alpha: thermal expansivity in K-1 tdstate = eg.evalSolutionGibbsGrid(water_spline['sp'], np.array([P, T]), 'rho', 'Cp', 'Kt', 'alpha', failOnExtrapolate=False) # for full set of implemented statevars: eg.evalSolutionGibbsGrid(water_spline['sp'], np.array([P, T])) # graph the output rcParams[ 'axes.labelpad'] = 10 # add some padding to prevents axis labels from covering ticks
def setUp(self): warnings.simplefilter('ignore', category=ImportWarning) self.puresubstancespline = lg.loadGibbsSpline('gsp_puresubstance.mat')