<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:"Calibri",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:"Calibri",sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">></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:"Calibri",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;">></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:"Calibri",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:"Calibri",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:"Calibri",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:"Calibri",sans-serif;"> <span style="color:blue;">IF</span> <span style="color:red;">(</span>Layer_Index <span style="color:red;">></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:"Calibri",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;">></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:"Calibri",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:"Calibri",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:"Calibri",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:"Calibri",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:"Calibri",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;">"1"</span></i> <span style="color:red;">*)</span> <i><span style="color:purple;">"Treatment of the minimum settling flux conditions by Godunov - gravity and upwards convective help fluxes"</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;">"1"</span></i> <span style="color:red;">*)</span> <i><span style="color:purple;">" Treatment of the minimum settling flux conditions by Godunov - gravity and upwards convective fluxes"</span></i>: PloszArealFluxVector; </span></span></span></pre>
<p><span style="font-size:11pt;"><span style="line-height:107%;"><span style="font-family:"Calibri",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>