Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features/0.2.4 #22

Merged
merged 5 commits into from
Oct 10, 2023
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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.3
current_version = 0.2.4
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
2 changes: 1 addition & 1 deletion src/qfmu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/qfmu/codegen/templates/fmi2model.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 10 additions & 10 deletions src/qfmu/codegen/templates/fmi2modelDescription.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@
<Real derivative="{{ i+1 }}"/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.nu) %}
<ScalarVariable name="u{{i+1}}" valueReference="{{model.vr.u[i]}}" description="Model input {{i+1}}" causality="input">
<Real start="{{model.u0[i]}}"/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.ny) %}
<ScalarVariable name="y{{i+1}}" valueReference="{{model.vr.y[i]}}" description="Model output {{i+1}}" causality="output">
<Real/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.nx) %}
<ScalarVariable name="x{{i+1}}_start" valueReference="{{model.vr.x0[i]}}" description="Start value for x{{i+1}}" causality="parameter" variability="fixed">
<Real start="{{model.x0[i]}}"/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.nu) %}
<ScalarVariable name="u{{i+1}}" valueReference="{{model.vr.u[i]}}" description="Model input {{i+1}}" causality="input">
<Real start="{{model.u0[i]}}"/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.nu) %}
<ScalarVariable name="u{{i+1}}_start" valueReference="{{model.vr.u0[i]}}" description="Start value for u{{i+1}}" causality="parameter" variability="fixed">
<Real start="{{model.u0[i]}}"/>
</ScalarVariable>
{% endfor %}
{% for i in range(model.ny) %}
<ScalarVariable name="y{{i+1}}" valueReference="{{model.vr.y[i]}}" description="Model output {{i+1}}" causality="output">
<Real/>
</ScalarVariable>
{% endfor %}
</ModelVariables>

Expand Down
4 changes: 2 additions & 2 deletions src/qfmu/model/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
8 changes: 7 additions & 1 deletion src/qfmu/model/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)}")

Expand Down
2 changes: 1 addition & 1 deletion src/qfmu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down