2
votes

I have a parameter under section protected that is needed for further calculations:

parameter Integer Ns = integer(ceil(L / dx))

It shouldn't be modified that's why I placed it there. However, I want to access this parameter while building my general model. Particularly to access it in the other component that I could do something like:

Ns = componentName.Ns

But as it is under protected section it is not possible. I did a work around by simply adding another parameter in general section:

parameter Integer N=Ns

However, this parameter appears in the GUI and can be modified, which I would like to avoid by all means.

Is there any solution for this? I hope it is clear what I mean.

1
If you want it to be visible and accessible, but no longer changeable, then you should mark it final. mbe.modelica.university/components/subsystems/propagationmatth
@matth I am aware of final, though how do I make it for the Integer? Particularly in this line parameter Integer Ns = integer(ceil(L / dx))Tomillo
What about final parameter Integer Ns = integer(ceil(L / dx)) ?matth
That's exactly what I was looking for. Thank you!Tomillo

1 Answers

3
votes

Converting my comments into an answer:
If you want a parameter to be visible and accessible from outside of the model class, but no longer changeable, then you should mark it final, like this:

final parameter Integer Ns = integer(ceil(L / dx))

As you can see in the example, the parameter can be calculated and becomes final afterwards.