ModelicaStandardLibrary
ModelicaStandardLibrary copied to clipboard
Invalid access of protected elements in SmoothStep example
This:
https://github.com/modelica/ModelicaStandardLibrary/blob/a877f527e29c47e344d2c05e393b65c6c4eee01b/Modelica/Electrical/Analog/Examples/Lines/SmoothStep.mo#L92-L97
Accesses these protected elements:
https://github.com/modelica/ModelicaStandardLibrary/blob/a877f527e29c47e344d2c05e393b65c6c4eee01b/Modelica/Electrical/Analog/Lines/OLine.mo#L57-L65
and is hence illegal, as reported by System Modeler:
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine50.L.i in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, L is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine50.C.v in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, C is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine5.L.i in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, L is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine5.C.v in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, C is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine1.L.i in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, L is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Error: Modelica.Electrical.Analog.Examples.Lines.SmoothStep Invalid lookup of protected element. When looking up oLine1.C.v in scope Modelica.Electrical.Analog.Examples.Lines.SmoothStep, C is protected. Protected elements can only appear as the first part of a component reference or path, and cannot be imported.
Same thing here:
https://github.com/modelica/ModelicaStandardLibrary/blob/a877f527e29c47e344d2c05e393b65c6c4eee01b/Modelica/Electrical/Analog/Examples/Lines/CompareLineTrunks.mo#L91-L98
Broken by 839ab4de9c84a4a9bcbf070708f982969c84b484 for #4306. Not sure if the protected section was modified on purpose or accident. Given the commit message it does not look a necessary change.
I confirm also OpenModelica complains about that:
- https://libraries.openmodelica.org/branches/master/Modelica_trunk/files/Modelica_trunk_Modelica.Electrical.Analog.Examples.Lines.SmoothStep.err
- https://libraries.openmodelica.org/branches/master/Modelica_trunk/files/Modelica_trunk_Modelica.Electrical.Analog.Examples.Lines.CompareLineTrunks.err
As I understand, 839ab4d made the sub-components of OLine protected to avoid excessive simulation data output and mirrored the current and voltage variables to public alias variables. The commit fixed the initial equations of LightningSegmentedTransmissionLine accordingly, but not the ones of SmoothStep and CompareLineTrunk.
If we had a proper CI in place, this would have been caught immediately 😃
I'll make a PR to fix this.
Will be fixed by #4422 on master, then we need to back-port it to maint/4.1.x
Reopening until it is back-ported to maint/4.1.x
#4446 back-ported #4422, all set.