Commit ad65d4af authored by Jesse VanderWees's avatar Jesse VanderWees 🐘 Committed by Tjerk Vreeken

Don't set nan constant inputs in modelica mixin

Modelica mixin was masking missing timeseries detection by setting
timeseries full of NaN. This was causing hard-to-debug
InvalidNumberDetected solver errors.
parent b9a30ca4
......@@ -215,11 +215,19 @@ class ModelicaMixin(OptimizationProblem):
constant_input_names = { for sym in self.__mx['constant_inputs']}
for v in self.__pymoca_model.inputs:
if in constant_input_names:
constant_inputs[] = Timeseries(
times, np.full_like(times, v.value))
if logger.getEffectiveLevel() == logging.DEBUG:
logger.debug("Read constant input {} = {} from Modelica model".format(, v.value))
# NOTE: v.value can be a DM. Cast to float to make sure the
# isnan call succeeds.
value = float(v.value)
if not np.isnan(value):
constant_inputs[] = Timeseries(
times, np.full_like(times, value))
if logger.getEffectiveLevel() == logging.DEBUG:
"Read constant input {} = {} from Modelica model".format(, value
return constant_inputs
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment