0

I want to export my model to python as an FMU and work with its parameters. Since it is easy for me working with inputs and outputs when I'm importing the FMU in a new environment, I'm trying to change parameters to inputs. As a first approach I was trying to change the model parameters as inputs but it is unable to simulate or export it as an FMU.

The next code is a extremely simple example of what I want to do:

model test
input Real value1;
  Modelica.Blocks.Math.Gain gamma(k = value1) annotation(
    Placement(visible = true, transformation(origin = {200, 84}, extent = {{-10, -10}, {10, 10}}, rotation = 180)));
equation

annotation(
    Diagram(coordinateSystem(extent = {{180, 100}, {220, 60}})),
    version = "",
    uses(Modelica(version = "4.0.0")));
end test;

Thank you very much!

Elena
  • 85
  • 5
  • 1
    Make it a "input parameter Real value1;" as you cannot bind the parameter from Gain to a variable. – Adrian Pop Aug 24 '23 at 10:47
  • @AdrianPop thank you so much for your comment, you're very kind:) I've tried your suggestion and it still dosen't work. I get this error: [4] 12:49:30 Syntax Error [test: 2:7-2:16]: No viable alternative near token: parameter – Elena Aug 24 '23 at 10:51
  • 1
    Then i guess is parameter input instead of input parameter, I did not check the grammar :) – Adrian Pop Aug 24 '23 at 12:56
  • 1
    Yes is "parameter input Real value1;" according to the grammar: https://specification.modelica.org/master/modelica-concrete-syntax.html#component-clause – Adrian Pop Aug 24 '23 at 12:58
  • Hi @AdrianPop! Thank you again :) I have solved it in a different way based on your help. I used parameter Real value1; but when I created the FMU I used this function in Python: simulate_fmu( filename = fmu_model, start_time = 0, stop_time = start_values = "here I established the parameter in a dictionary" output = } It is better explained in the following answer of another question: https://stackoverflow.com/q/76967687/21772092 = Thank you again, Adrian! – Elena Aug 25 '23 at 07:43
  • 1
    Yes, is actually better to use the parameters if possible and NOT make a new model where you force them to be inputs. – Adrian Pop Aug 25 '23 at 13:16
  • That's true. Thank you! – Elena Aug 28 '23 at 07:12

0 Answers0