Source code for g3d.calc.tests.test_shock_tube

"""unit tests for shock-tube relations calculator"""
import unittest
import os

if os.environ.get('__USE_CUDA', '0') == '1':
    import cupy as np
else:
    import numpy as np

from g3d.calc.tests import CFlowTestCase
from g3d.calc.calculators.shock_tube import G3DShockTubeCalculator


[docs] class TestShockTube(CFlowTestCase): """CFlow unit tests: shock-tube relations""" def _setup(self) -> None: super()._setup() self.__shock_tube = G3DShockTubeCalculator() self.__PR21 = 2.1278730 self.__T1 = 300. self.__T4 = 300. self.__PR41 = 5.
[docs] def test_shock_tube_relations_kwargs(self) -> None: """CFlow unit tests: shock-tube relations (kwargs)""" self._setup() self.assertEqual(self.__shock_tube.get_PR41( PR21=self.__PR21, T1=self.__T1, T4=self.__T4, precision=self._prec), np.round(self.__PR41, self._prec)) self.assertEqual(self.__shock_tube.find_PR21_from_PR41( PR41=self.__PR41, T4=self.__T4, T1=self.__T1, precision=self._prec), np.round(self.__PR21, self._prec))
[docs] def test_shock_tube_relations_args(self) -> None: """CFlow unit tests: shock-tube relations (args)""" self._setup() self.assertEqual(self.__shock_tube.get_PR41( self.__PR21, self.__T1, self.__T4, precision=self._prec), np.round(self.__PR41, self._prec)) self.assertEqual(self.__shock_tube.find_PR21_from_PR41( self.__PR41, self.__T4, self.__T1, precision=self._prec), np.round(self.__PR21, self._prec))
if __name__ == '__main__': unittest.main()