Please wait...
×

Error

Posted Fri, 28 Oct 2022 12:36:13 GMT by Natalia Gemza
Hello everyone,
I created new SST model in Modelica that is based on the Plosz SST model in MSL library.
Now I identify all the typos and wrong variable declatations by trying to run a simple simualtion with this new model and analyzing error message that popped up.
It went pretty smooth until an error message had actually no defined error in it. Instead there's a long list of all functions and variables in this particular project (in attatchment).
Does anybody had similar experience and know where might be the problem?

 
Posted Tue, 10 Jan 2023 13:10:55 GMT by Enrico Remigi WEST Product Owner
Hello Natalia,
first of: apologies for the huge delay in responding, the Forum has been under renovation for a while, and I was not aware it had been back online for so long.
Yes, this kind of situation does occur, and is of course particularly unfortunate.
You are right: generally, there is one specific error message that points to a particular line in the code. One can double-click on the MOF tab and get automatically directed to the line of code in the MO tab page.
In some situations though, the compiler cannot resolve the issue to be associated to one specific line of code, so it spits out the entire code - which is useless of course.
This often happens in connection with vectors - should this help you in any way.
Have you checked the Logging pane? often, if you scroll up, you might locate the actual error message: in these situation, the error message here may be more informative than the MOF/MO pages.
 
Posted Mon, 30 Jan 2023 09:27:27 GMT by Natalia Gemza
Helo Enrico,<br> thanks for the tip. It definitely helped - eror message in logging pane indicated what the issue was.<br> Minimal settling flux condition in MSL Plosz model is defined as follows: <pre class="linenums prettyprint"><span style="font-size:11.0pt;"><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;"><span style="color:green;">//BPlosz - mathematical treatment of the minimum settling flux condition using the Godunov-approach</span></span></span></span> <span style="font-size:11.0pt;"><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:red;">{</span> <span style="color:blue;">FOREACH</span> Layer_Index <span style="color:blue;">IN</span> <span style="color:red;">{</span><span style="color:black;">2</span> <span style="color:red;">..</span> <span style="color:black;">59</span><span style="color:red;">}</span>: <i><span style="color:black;">state.</span></i>J_G<span style="color:red;">[</span>Layer_Index<span style="color:red;">-</span><span style="color:black;">1</span><span style="color:red;">]</span> <span style="color:red;">=</span> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">&lt;=</span> <i><span style="color:black;">state.</span></i>DynamicIndexOfFeedLayer<span style="color:red;">)</span> <span style="color:blue;">THEN</span> <span style="color:blue;">IF</span> <span style="color:red;">(</span><i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">-</span><span style="color:black;">1</span><span style="color:red;">]</span> <span style="color:red;">&lt;=</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">])</span> <span style="color:blue;">THEN</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">-</span><span style="color:black;">1</span><span style="color:red;">]</span> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">-</span><span style="color:black;">1</span><span style="color:red;">]</span> ; <span style="color:red;">}</span>; <span style="color:red;">{</span> <span style="color:blue;">FOREACH</span> Layer_Index <span style="color:blue;">IN</span> <span style="color:red;">{</span><span style="color:black;">1</span> <span style="color:red;">..</span> <span style="color:black;">59</span><span style="color:red;">}</span>: <i><span style="color:black;">state.</span></i>J_G<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">=</span> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>DynamicIndexOfFeedLayer<span style="color:red;">)</span> <span style="color:blue;">THEN</span> <span style="color:blue;">IF</span> <span style="color:red;">(</span><i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+</span><span style="color:black;">1</span><span style="color:red;">])</span> <span style="color:blue;">THEN</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+</span><span style="color:black;">1</span><span style="color:red;">]</span> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> ; <span style="color:red;">}</span>; <span style="color:green;">// end</span></span></span></span></pre> When the above code is straightfowardly converted to Modelica it should look like this: <pre class="linenums prettyprint"><span style="color:#0000ff;font-weight:normal;font-style:normal;">for</span> i <span style="color:#0000ff;font-weight:normal;font-style:normal;">in</span> <span style="color:#000000;font-weight:normal;font-style:normal;">2</span>:<span style="color:#000000;font-weight:normal;font-style:normal;">59</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">loop</span> J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">-</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">=</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">if</span> i <span style="color:#ff0000;font-weight:normal;font-style:normal;">&lt;=</span>DynamicIndexOfFeedLayer <span style="color:#0000ff;font-weight:normal;font-style:normal;">then</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">if</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">(</span>Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">-</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">&lt;=</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">])</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">then</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">-</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">else</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">else</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">-</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span>; <span style="color:#0000ff;font-weight:normal;font-style:normal;">end</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">for</span>; <span style="color:#0000ff;font-weight:normal;font-style:normal;">for</span> i <span style="color:#0000ff;font-weight:normal;font-style:normal;">in</span> <span style="color:#000000;font-weight:normal;font-style:normal;">1</span>:<span style="color:#000000;font-weight:normal;font-style:normal;">59</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">loop</span> J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">=</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">if</span> i <span style="color:#ff0000;font-weight:normal;font-style:normal;">&gt;</span> DynamicIndexOfFeedLayer <span style="color:#0000ff;font-weight:normal;font-style:normal;">then</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">if</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">(</span>Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#ff0000;font-weight:normal;font-style:normal;">&gt;</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">+</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">])</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">then</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">+</span><span style="color:#000000;font-weight:normal;font-style:normal;">1</span><span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">else</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">else</span> Help_J_G<span style="color:#ff0000;font-weight:normal;font-style:normal;">[</span>i<span style="color:#ff0000;font-weight:normal;font-style:normal;">]</span>; <span style="color:#0000ff;font-weight:normal;font-style:normal;">end</span> <span style="color:#0000ff;font-weight:normal;font-style:normal;">for</span>; </pre> <div class="linenums prettyprint">But then for all layers J_G is defined twice, startng with J_G[1] and model build error occurs. How to modify minimal settling flux condition in Modelica? Why, when using MSL model library, the same error doesn't occur? State variable J_G for all layers is also defined twice.</div>
Posted Mon, 30 Jan 2023 13:42:59 GMT by Enrico Remigi WEST Product Owner
Hello Natalia,<br> in fact both implementations look untidy, if not incorrect.<br> It is possible that the MSL compiler had less rigorous checks and would go through this, while the Modelica compiler simply does not allow for multiple assignments to the same variable (it probably complains about &quot;replicate LHS ...&quot;, left hand side of an equation).<br> <br> Further to that, the 2nd loop may result in another error, related to the 'i+1',<br> I can't remember if the indices go up to 59 or to 60, but if it is 59, then 'i+1' will result in &quot;index out of range'.<br> <br> Either way, that code is doomed :)<br> <br> How about the following? <pre class="linenums prettyprint"><code>for i in 2:59 loop J_G[i-1] = if i &lt;=DynamicIndexOfFeedLayer then if (Help_J_G[i-1] &lt;= Help_J_G[i]) then Help_J_G[i-1] else Help_J_G[i] elseif (i &gt; DynamicIndexOfFeedLayer and i &lt; 59) then if (Help_J_G[i] &gt; Help_J_G[i+1]) then Help_J_G[i+1] else Help_J_G[i] else Help_J_G[i]; end for;</code></pre> Hope this helps<br> &#160;
Posted Fri, 10 Feb 2023 11:15:44 GMT by Natalia Gemza
<p>Hi Enrico,</p> <p>indeed after this modification error disappeared but this new, proposed loop does not reflect original structure - it refers only to J_G[i-1] and therefore when conditions in the second part of the loop are met J_G[i-1] = J_G[i+1] and and not J_G[i] = J_G[i+1].</p> <p>Furthermore, after checking the exact form of Godunov scheme in Plosz paper (2007)</p> <p><img></p> <p>I believe in original MSL code there's an error in condition for finding maximum (second loop). Now, it states:</p> <pre class="linenums prettyprint"><span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"><span style="color:red;">{</span> <span style="color:blue;">FOREACH</span> Layer_Index <span style="color:blue;">IN</span> <span style="color:red;">{</span><span style="color:black;">1</span> <span style="color:red;">..</span> <span style="color:black;">59</span><span style="color:red;">}</span>: <i><span style="color:black;">state.</span></i>J_G<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">=</span></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>DynamicIndexOfFeedLayer<span style="color:red;">)</span> <span style="color:blue;">THEN</span> </span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span><i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+</span><span style="color:black;">1</span><span style="color:red;">])</span> <span style="color:blue;">THEN</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+</span><span style="color:black;">1</span><span style="color:red;">]</span></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> ; <span style="color:red;">}</span>;</span></span></span></span></pre> <p>and it looks as though this loop actually finds minimum. Shouldn't it be:</p> <pre class="linenums prettyprint"><span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"><span style="color:red;">{</span> <span style="color:blue;">FOREACH</span> Layer_Index <span style="color:blue;">IN</span> <span style="color:red;">{</span><span style="color:black;">1</span> <span style="color:red;">..</span> <span style="color:black;">59</span><span style="color:red;">}</span>: <i><span style="color:black;">state.</span></i>J_G<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">=</span></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>DynamicIndexOfFeedLayer<span style="color:red;">)</span> <span style="color:blue;">THEN</span> </span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span><i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> <span style="color:red;">&gt;</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+</span><span style="color:black;">1</span><span style="color:red;">])</span> <span style="color:blue;">THEN</span> <strong><i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span></strong></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <strong> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">+1]</span></strong></span></span></span></span> <span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;"> <span style="color:blue;">ELSE</span> <i><span style="color:black;">state.</span></i>J_G_Help<span style="color:red;">[</span>Layer_Index<span style="color:red;">]</span> ; <span style="color:red;">}</span>;</span></span></span></span></pre> <p><span style="font-size:11pt;"><span style="line-height:normal;"><span style=""><span style="font-family:&quot;Calibri&quot;,sans-serif;">And the last question relates to state variables. When I tried to convert MSL code to Modelica I found two state variables in Plosz MSL model that are declared and neither defined nor used in the model. From their description it looks like they were supposed to be used exactly in the Godunov condition: </span></span></span></span></p> <pre class="linenums prettyprint"><span style="font-size:11pt;"><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;"><span style="color:blue;">OBJ</span></span></span></span><span style="font-size:11pt;"><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;"> J_GUp_Help <span style="color:red;">(*</span> <span style="color:gray;">hidden</span> <span style="color:red;">=</span> <i><span style="color:purple;">&quot;1&quot;</span></i> <span style="color:red;">*)</span> <i><span style="color:purple;">&quot;Treatment of the minimum settling flux conditions by Godunov - gravity and upwards convective help fluxes&quot;</span></i>: PloszArealFluxVector; <span style="color:blue;">OBJ</span> J_GUp <span style="color:red;">(*</span> <span style="color:gray;">hidden</span> <span style="color:red;">=</span> <i><span style="color:purple;">&quot;1&quot;</span></i> <span style="color:red;">*)</span> <i><span style="color:purple;">&quot; Treatment of the minimum settling flux conditions by Godunov - gravity and upwards convective fluxes&quot;</span></i>: PloszArealFluxVector; </span></span></span></pre> <p><span style="font-size:11pt;"><span style="line-height:107%;"><span style="font-family:&quot;Calibri&quot;,sans-serif;">So now I'm wondering if someone changed original concept for describing this condition and forgot to remove this variable or if there's someting missing in the code?</span></span></span></p>
Posted Mon, 13 Feb 2023 08:24:16 GMT by Enrico Remigi WEST Product Owner
Hello Natalia,<br> intuitively, I would say you are right regarding the piece of code that is to find the maximum: have you tested it? do you get sensible results when you &quot;swap&quot; Layer_Index and Layer_Index+1 ?<br> Regarding your second question: I checked an early implementation of the Plosz model (2017), both variables are declared and never assigned.<br> So I believe they are not present in Modelica, as the result of a code clean-up.<br> <br> /Enrico<br> &#160;
Posted Mon, 13 Feb 2023 09:42:17 GMT by Natalia Gemza
Hello Enrico,<br> yes I tested change in simulation results (both steady-state and dynamic) after this &quot;swap&quot;.<br> Results are more then sensible. To my surprise they were not so different from the original run. It seems as though this model is not so sensitive to 'min' and 'max' condition.<br> <br> Regarding second issue - there's no implementation of Plosz model in Modelica library. Generally Modelica library, in terms of available SST models, is very limited (when compared to MSL library).That's why, since using this exact SST model is part of my research, I have to either create this model in Modelica by myself (which is not so straight forward since, as we can see, the same piece of code can be interpreted differently) or go back to MSL. Are there plans to complete Modelica library with models available in MSL?
Posted Thu, 16 Feb 2023 12:15:59 GMT by Enrico Remigi WEST Product Owner
<p>Hello Natalia,</p> <p>I understand your dilemma.</p> <p>There's no real plan to include more SST models in Modelica, I thought the set of models is already quite sufficient - only &quot;minor&quot; ones were left out.</p> <p>Is there any in particular that you would need, beside Plosz? If it is only Plosz, I can probably give it a try and make it available for you.</p>
Posted Thu, 16 Feb 2023 12:38:28 GMT by Natalia Gemza
<p>Hi Enrico,</p> <p>I work with 3 SST models. Takacs, BurgerDiehl and Plosz.</p>

You must be signed in to post in this forum.