modelicadymola

How to modify an outer parameter in two instances declaration?


I have developed a submodel that I am using throughout my project and it has an outer parameter:

model Submodel

    outer parameter Real toto;

    [...]

end Submodel;

Then, for each component of my project, I just start with the definition of the inner parameter:

model Model

    inner parameter Real toto = 1;

    Submodel submodel1;
    Submodel submodel2;

    [...]

end Model;

That's really convenient for my project and I don't want to modify this, unless there's a clean workaround. Just to be clear, I actually have more than two instances, hence the use of an outer parameter.

Now, the issue is that I have a specific model that requires the use of two different values for the parameter toto, for two instances of the submodel. I thought of something like:

model SpecificModel

    Submodel submodel1(toto=1);
    Submodel submodel2(toto=2);

    [...]

end SpecificModel;

But Dymola throw me out with an Outer component with non-empty modifier. Any idea how to go around the outer or redeclare the parameter itself in the instance declaration?


Solution

  • You cannot directly do that, but have to introduce an extra layer:

    model SpecificModel
    
        SpecificAdapater1 submodel1(toto=1);
        SpecificAdapater2 submodel2(toto=2);
    
        [...]
    
    end SpecificModel;
    
    model SpecificAdapater1
        inner parameter Real toto;
    
        Submodel submodel1;
    end SpecificAdapater1;
    
    model SpecificAdapater2
        inner parameter Real toto;
    
        Submodel submodel2;
    end SpecificAdapater2;
    

    It might be that there should be more differences between SpecificAdapater1 and SpecificAdapater2 - or on the other hand that they could be the same class.