Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/pathsim_chem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
from .neutronics import *


#blocks that were removed -> what to use instead
_REMOVED = {
"Polynomial": "pathsim.blocks.Polynomial with the coefficients in descending order (numpy.polyval)",
}


def __getattr__(name):
"""Deprecated aliases for the blocks that moved, see 'tritium'"""
"""Deprecated aliases for the blocks that moved, see 'tritium', and an
error that names the replacement for the blocks that were removed.
"""
if name in _REMOVED:
raise ImportError(f"'{name}' was removed from pathsim-chem, use {_REMOVED[name]}")
return getattr(tritium, name)
1 change: 0 additions & 1 deletion src/pathsim_chem/icons/Polynomial.svg

This file was deleted.

26 changes: 0 additions & 26 deletions src/pathsim_chem/thermodynamics/correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,6 @@

# BLOCKS ================================================================================

class Polynomial(Function):
r"""Polynomial correlation (IK-CAPE code: POLY).

.. math::

f(T) = \sum_{i=0}^{n} a_i \, T^i

General-purpose polynomial for temperature-dependent properties.

Parameters
----------
coeffs : list or tuple of float
Polynomial coefficients :math:`[a_0, a_1, \ldots, a_n]` (up to 10).
"""

input_port_labels = {"T": 0}
output_port_labels = {"value": 0}

def __init__(self, coeffs):
self.coeffs = tuple(coeffs)
super().__init__(func=self._eval)

def _eval(self, T):
return sum(a * T**i for i, a in enumerate(self.coeffs))


class ExponentialPolynomial(Function):
r"""Exponential polynomial correlation (IK-CAPE code: EPOL).

Expand Down
25 changes: 5 additions & 20 deletions tests/thermodynamics/test_correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import numpy as np

from pathsim_chem.thermodynamics import (
Polynomial,
ExponentialPolynomial,
Watson,
Antoine,
Expand Down Expand Up @@ -43,25 +42,12 @@ def eval_block(block, T):

# TESTS ================================================================================

class TestPolynomial(unittest.TestCase):
class TestPolynomialRemoved(unittest.TestCase):

def test_init(self):
P = Polynomial(coeffs=[1.0, 2.0, 3.0])
self.assertEqual(P.coeffs, (1.0, 2.0, 3.0))

def test_constant(self):
P = Polynomial(coeffs=[42.0])
self.assertAlmostEqual(eval_block(P, 300), 42.0)

def test_linear(self):
P = Polynomial(coeffs=[10.0, 0.5])
# f(300) = 10 + 0.5*300 = 160
self.assertAlmostEqual(eval_block(P, 300), 160.0)

def test_quadratic(self):
P = Polynomial(coeffs=[1.0, 0.0, 0.01])
# f(10) = 1 + 0 + 0.01*100 = 2
self.assertAlmostEqual(eval_block(P, 10), 2.0)
def test_import_names_replacement(self):
#removed in favour of pathsim.blocks.Polynomial, the coefficient order differs
with self.assertRaisesRegex(ImportError, "pathsim.blocks.Polynomial"):
from pathsim_chem import Polynomial


class TestExponentialPolynomial(unittest.TestCase):
Expand Down Expand Up @@ -339,7 +325,6 @@ class TestSmokeAllBlocks(unittest.TestCase):

def test_all_blocks_at_300K(self):
blocks = [
Polynomial(coeffs=[1.0, 0.01]),
ExponentialPolynomial(coeffs=[2.0, 0.001]),
Watson(a0=5e7, a1=0.38, a2=647.0),
Antoine(a0=23.2256, a1=3835.18, a2=-45.343),
Expand Down
Loading