Ejemplo n.º 1
0
    def query(self, quantities, deLog10Result=False):
        """
        Queries the EOS table looking for 'quantity' at set physical state
        Note: query clears physical state after quantity is determined!
        """
        assert all([var is not None for var in self.physicalState]), \
            "One or more independent variables " \
            "not set for this EOS's physical state!"

        tableIndexes = []
        for i, indVar in enumerate(self.indVars):
            value = self.physicalState[i]
            tableIndexes.append(lookupIndexBisect(value, self.h5file[indVar][:]))

        answers = self.interpolateTable(tableIndexes, quantities)
        self.clearState()
        if deLog10Result:
            answers = numpy.power(10.0, answers)
        return answers
theEos = ls220

theEos.setState({'rho': 1.0e15, 'ye': 0.15, 'temp': 30.0})
canonicalEntropy = theEos.query('entropy')
print canonicalEntropy
print theEos.setBetaEqState({'rho': 1.0e15,  'temp': 30.0})
canonicalEntropy = theEos.query('entropy')
print canonicalEntropy
canonicalEntropy = 0.9
fixedYe = 0.15


print
print "---------------"
print
getLogRhoIndex = lambda lr: lookupIndexBisect(lr, theEos.h5file['logrho'][:])
def entropyOfT(logtemp, logrho, target):

    lrindex = getLogRhoIndex(logrho)
    return multidimInterp((logtemp, logrho), [theEos.h5file['logtemp'][:],
                                              theEos.h5file['logrho'][:]],
                          theEos.h5file['entropy'][11, :, :],
                          linInterp, 2) - target


logtemp = numpy.log10(30.)

ye = 0.15
tcold = 0.5

logrhos = numpy.arange(13.0,15.5,0.1)