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

The error message is wrong when the final time is almost equal to the largest value in the mesh #115

Closed
mbaudin47 opened this issue Oct 16, 2024 · 1 comment · Fixed by #116

Comments

@mbaudin47
Copy link
Contributor

In the script below, we create an epidemiological model using a stop time equal to 13 and 100 vertices.

# %%
import otfmi
import os
import openturns as ot
import platform
import openturns.viewer as otv

# %%
infection_rate = 0.007
healing_rate = 0.3
input_value = [infection_rate, healing_rate]

# %%
start_time = 0.0
final_time = 13.0
number_of_vertices = 100
step = (final_time - start_time) / (number_of_vertices - 1)
mesh = ot.RegularGrid(start_time, step, number_of_vertices)
vertices = mesh.getVertices()

# %%
# Select the FMU
cwd = os.getcwd()
if platform.system() == "Linux":
    path_fmu= os.path.join(cwd, "epid-linux-x86_64.fmu")
else:
    path_fmu= os.path.join(cwd, "epid-win64.fmu")

# %%
monModele = otfmi.FMUPointToFieldFunction(
    mesh,
    path_fmu,
    inputs_fmu=["infection_rate", "healing_rate"],
    outputs_fmu=["infected"],
    start_time=start_time,
    final_time=final_time)

The previous script produces:

AssertionError: The mesh final time must be >= to FMU final time.
To set the FMU final time, use the argument final_time in
FMUPointToFieldFunction constructor.

This is wrong because the message is inverted. It should read "<=" instead of ">=".

The bug is here:

assert (

@mbaudin47
Copy link
Contributor Author

Furthermore, there are rounding errors which might be taken into account.
Here:

>>> vertices[-1][0]
13.000000000000002

instead of exactly 13. The rounding error is close to machine precision. In this case, no exception should be generated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant