def test_simple_rkpr_env(self): m = Mixture() m.add_many('methane propane n-pentane n-decane n-hexadecane', '0.822 0.088 0.050 0.020 0.020') s = EosSetup.objects.create(eos='RKPR', kij_mode=EosSetup.T_DEP, lij_mode='constants') m.get_envelope(setup=s)
class TestEnvelope(TestCase): def setUp(self): self.m = Mixture() self.ethane = Compound.objects.get(name='ETHANE') self.methane = Compound.objects.get(name='METHANE') self.co2 = Compound.objects.get(name='CARBON DIOXIDE') @skip('time expire') def test_envelope_requires_a_clean_mixture(self): self.m.add(self.ethane, 0.1) self.m.add(self.co2, 0.3) self.m.add(self.methane, 0.5) assert self.m.total_z == Decimal('0.9') with self.assertRaises(ValidationError): EosEnvelope.objects.create(mixture=self.m) self.m[self.methane] = 0.6 # total_z = 1.0 assert self.m.clean() is None # not raises EosEnvelope.objects.create(mixture=self.m) def test_simple_rkpr_env(self): m = Mixture() m.add_many('methane propane n-pentane n-decane n-hexadecane', '0.822 0.088 0.050 0.020 0.020') s = EosSetup.objects.create(eos='RKPR', kij_mode=EosSetup.T_DEP, lij_mode='constants') m.get_envelope(setup=s) @skip('calc fail') def test_envelope_object_calc_env_on_save(self): self.m.add(self.ethane, 1) env = EosEnvelope.objects.create(mixture=self.m) self.assertIsInstance(env.p, np.ndarray) self.assertIsInstance(env.t, np.ndarray) self.assertIsInstance(env.rho, np.ndarray) self.assertTrue(env.p.shape == env.t.shape == env.rho.shape) self.assertIsInstance(env.p_cri, np.ndarray) self.assertIsInstance(env.t_cri, np.ndarray) self.assertIsInstance(env.rho_cri, np.ndarray) self.assertTrue( env.p_cri.shape == env.t_cri.shape == env.rho_cri.shape) @skip("fail for this mixture case") def test_get_default_envelope_is_the_same(self): self.m.add(self.ethane, 1) env = EosEnvelope.objects.create(mixture=self.m) self.assertEqual(env, self.m.get_envelope())