Closed modelica-trac-importer closed 5 years ago
Comment by fcasella on 2 Apr 2015 09:20 UTC May I suggest the following error message:
Error In ModelicaCompliance.Classes.Predefined.AttributeStateSelect
The equation:
v=5.0;
constrains the continuous time variables:
v
which has stateSelect=StateSelect.always. This is not possible because a state variable cannot have a constant value. Please change the stateSelect attribute or the equation.
Comment by adrpo on 2 Apr 2015 09:41 UTC Jens, you can fix the model and do a pull request at: https://github.com/modelica-compliance/compliance But your point is valid, maybe we should add a new model that tests for this problem.
Comment by hansolsson on 7 Apr 2015 07:38 UTC Replying to [ticket:1692 jfrenkel]:
The Model
ModelicaCompliance.Classes.Predefined.AttributeStateSelect
test that all defined values of StateSelect can be used. But there is a mistake vorReal v(stateSelect = StateSelect.always) = 5.0;
. This variable have to bealways "Do use it as a state."
. But this is not possible because it is bind to be5.0
.
I agree that it is silly, and superfluous, to have v as a state, but why would it be impossible?
In the general case of
model A
X x;
Real v(stateSelect=...)=f(x, time);
end A;
already StateSelect.prefer state that 'v' does not have to be differentiated to be selected as a state (the tools should do that automatically); leading to der(v)=df/dx*der(x)+df/dt*1;
For the degenerate case of 'f' being the constant function this will still be correct; and 'der(v)' will be zero in that case.
Comment by jfrenkel on 15 Apr 2015 09:46 UTC
In your example the equtaion v=f(x, time)
is used to calculate the variable x
.
However, in the degenerate case the equation may look like the following v=f(5, time)
. So after index reduktion there are 2 equations:
der(v)=0;
v=f(5, time)
In the case of v(stateSelect=StateSelect.always)
it is not possible to keep v
as state because there is an equation to many v=f(5,time)
.
In the case of v(stateSelect=StateSelect.prefer)
it is also not possible to keep v
as state. But in that case it is legal to deselect v and use it as normal algebraic variable.
type StateSelect = enumeration(
...
prefer "Prefer it as state over those having the default value
(also variables can be selected, which do not appear
differentiated). ",
always "Do use it as a state.
);
This has already been corrected without a reference to this ticket: https://github.com/modelica/Modelica-Compliance/commit/e0656a5901990e2f5f2555e6d58aec675e24ea1b
Reported by jfrenkel on 2 Apr 2015 07:53 UTC The Model
ModelicaCompliance.Classes.Predefined.AttributeStateSelect
test that all defined values of StateSelect can be used. But there is a mistake vorReal v(stateSelect = StateSelect.always) = 5.0;
. This variable have to bealways "Do use it as a state."
. But this is not possible because it is bind to be5.0
. The tool should reject it with a massage like:Migrated-From: https://trac.modelica.org/Modelica/ticket/1692