diff --git a/setup.cfg b/setup.cfg index 529d445..869345d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.2.3 +current_version = 0.2.4 commit = False tag = False diff --git a/setup.py b/setup.py index c8900a2..e185d36 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,6 @@ install_requires=install_requires, extras_require={"dev": dev_requires}, url="https://github.com/hyumo/qfmu", - version="0.2.3", + version="0.2.4", zip_safe=False, ) diff --git a/src/qfmu/__init__.py b/src/qfmu/__init__.py index 3ef9d39..82c7f6f 100644 --- a/src/qfmu/__init__.py +++ b/src/qfmu/__init__.py @@ -4,7 +4,7 @@ __author__ = """Hang Yu""" __email__ = "yuhang.neu@gmail.com" -__version__ = "0.2.3" +__version__ = "0.2.4" __module_path__ = pathlib.Path(__file__).parent __template_path__ = __module_path__ / "codegen" / "templates" diff --git a/src/qfmu/codegen/templates/fmi2model.jinja b/src/qfmu/codegen/templates/fmi2model.jinja index 5617846..ed7ba2f 100644 --- a/src/qfmu/codegen/templates/fmi2model.jinja +++ b/src/qfmu/codegen/templates/fmi2model.jinja @@ -180,7 +180,7 @@ static void updateDerivatives(ModelInstance* comp){ * \todo TODO: Implement other integration methods */ static void updateStates(ModelInstance* comp, fmi2Real h){ - const fmi2Real dt = {{ dt }}; + const fmi2Real dt = min({{ dt }}, h); size_t i = 0; for (i = 0; i < NX; i++) { fmi2Real hc = h; diff --git a/src/qfmu/codegen/templates/fmi2modelDescription.jinja b/src/qfmu/codegen/templates/fmi2modelDescription.jinja index 191fe8d..fcdbc48 100644 --- a/src/qfmu/codegen/templates/fmi2modelDescription.jinja +++ b/src/qfmu/codegen/templates/fmi2modelDescription.jinja @@ -51,25 +51,25 @@ {% endfor %} -{% for i in range(model.nu) %} - - - -{% endfor %} -{% for i in range(model.ny) %} - - - -{% endfor %} {% for i in range(model.nx) %} {% endfor %} +{% for i in range(model.nu) %} + + + +{% endfor %} {% for i in range(model.nu) %} +{% endfor %} +{% for i in range(model.ny) %} + + + {% endfor %} diff --git a/src/qfmu/model/pid.py b/src/qfmu/model/pid.py index 5b82fd3..1d8d54f 100644 --- a/src/qfmu/model/pid.py +++ b/src/qfmu/model/pid.py @@ -55,8 +55,8 @@ def __init__( self.m.A.shape[0], 1, 1, - [x0] if x0 is not None else None, - [u0] if u0 is not None else None, + np.array([x0]) if x0 is not None else None, + np.array([u0]) if u0 is not None else None, ) logging.info(f"P = {P}") diff --git a/src/qfmu/model/tf.py b/src/qfmu/model/tf.py index d132cba..a2dfccc 100644 --- a/src/qfmu/model/tf.py +++ b/src/qfmu/model/tf.py @@ -17,7 +17,13 @@ def __init__( u0: Optional[float] = None, ): self._A, self._B, self._C, self._D = signal.tf2ss(num, den) - super().__init__(nx=self._A.shape[0], nu=1, ny=1, x0=x0, u0=u0) + super().__init__( + nx=self._A.shape[0], + nu=1, + ny=1, + x0=np.array([x0]) if x0 is not None else np.zeros(self._A.shape[0]), + u0=np.array([u0]) if u0 is not None else np.zeros(1), + ) logging.info(f"{signal.TransferFunction(num, den)}") diff --git a/src/qfmu/utils.py b/src/qfmu/utils.py index 749a9a5..00bd87c 100644 --- a/src/qfmu/utils.py +++ b/src/qfmu/utils.py @@ -12,7 +12,7 @@ import numpy as np from jinja2 import Environment, FileSystemLoader, select_autoescape -from qfmu import __include_path__, __platform__, __version__, __template_path__ +from qfmu import __include_path__, __platform__, __template_path__, __version__ from qfmu.codegen.utils import array2cstr from qfmu.model.lti import LTI