Skip to content

Commit

Permalink
Modifications and documentation for additions in Example2
Browse files Browse the repository at this point in the history
  • Loading branch information
lvanfretti committed Mar 13, 2024
1 parent e3f5edb commit 67a553e
Show file tree
Hide file tree
Showing 18 changed files with 401 additions and 390 deletions.

This file was deleted.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ within Example2.Analysis.PFVariants;
package AutomationFunctions "Provides functions for automation of simulation and linearization using the models of the upper layer package"
extends Modelica.Icons.FunctionsPackage;
annotation (Documentation(info="<html>
<p>This package contains functions that automate the simulation, plotting and linearization of the models under <a href=\"modelica://Example2.Analysis\">Example2.Analysis</a>.</p>
<p>This package contains functions that automate the simulation, plotting and linearization of the models under <a href=\"Example2.Analysis.PFVariants\">Example2.Analysis.PFVariants</a>.</p>
</html>"));
end AutomationFunctions;
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
simulate_and_plot_ramping
simulate_and_plot_inputs
linearize_KchangeLinRamping
simulate_and_plot_ramping_pf
simulate_and_plot_inputs_pf
linearize_KchangeLinRamping_pf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within Example2.Analysis.PFVariants.AutomationFunctions;
function simulate_and_plot_inputs
"Simulates and plots the \"RampingRandomLoadAndInput\" model to reproduce the results in Fig. 4 of [2]."
function simulate_and_plot_inputs_pf
"Simulates and plots the \"RampingRandomLoadAndInput_pf\" which includes random load and the designed input signal."
extends Modelica.Icons.Function;
input Integer corenum = 12 "Number of processor cores to use";
algorithm
Expand All @@ -23,37 +23,37 @@ algorithm
<p><i><b>Usage:</b></i></p>
<ol>
<li>In the Package Browser, right click on the function and select &quot;Call function...&quot;. This will open the function&apos;s window. </li>
<p><img src=\"modelica://Example2/Resources/corenum.png\"/></p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_fun_inputs_pf.png\"/></p>
<li>Enter the desired number of cores to use in &quot;corenum&quot;. The number of cores to use depends on your computer&apos;s resources. , if your computer has more than 12 cores, you can enter the desired number of cores to use in the function&apos;s main window. Note that it will take some trial an error to find a trade off on the number of cores to use in your system as per <a href=\"https://en.wikipedia.org/wiki/Amdahl%27s_law\">Amdahl&apos;s law</a>. See the note below the sample output for more details.</li>
<li>In the new function window, click on &quot;Execute&quot;, if successful, messages/results are displayed in the command window and plots will appear in Simulation tab.</li>
<li>Go back to the function&apos;s own window and click on &quot;Close&quot;. </li>
</ol>
<p><br><i><b>Sample output:</b></i></p>
<p>Running the function will result in the following plot.</p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_inputs.png\"/></p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_inputs_pf.png\"/></p>
<p><i><b>Note:</b></i></p>
<p>Please observe that running this function involves simulating the <a href=\"modelica://Example2.Analysis.RampingRandomLoadAndInput\">Example2.Analysis.RampingRandomLoadAndInput</a> model, which takes subtantially more time compared to example&nbsp;<a href=\"modelica://Example2.Analysis.Ramping\">Example2.Analysis.Ramping</a>, the reason is that both random load and probing signals are added to the model which results in an additional computation burden.</p>
<p>Please observe that running this function involves simulating the <a href=\"Example2.Analysis.PFVariants.RampingRandomLoadAndInput_pf\">Example2.Analysis.PFVariants.RampingRandomLoadAndInput_pf</a> model, which takes subtantially more time compared to example&nbsp;<a href=\"Example2.Analysis.PFVariants.Ramping_pf\">Example2.Analysis.PFVariants.Ramping_pf</a>, the reason is that both random load and probing signals are added to the model which results in an additional computation burden.</p>
<p>This function calls the <a href=\"modelica://Example2.Utilities.SetupSolverSettings.On\">Example2.Utilities.SetupSolverSettings.On</a> function that configures several flags to improve simulation speed, however, even by enabling these features, the simulation is time consuming. </p>
<p>For example, running the model using a computer with an 13th Gen Intel(R) Core(TM) i9-13900K, 3.00 GHz, processor and 128 GB DDR4 RAM, setup to use 12 cores, gave the following metrics:</p>
<p style=\"margin-left: 60px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Integration terminated successfully at T = 4050</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for integration : 1.14e+03 seconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for one grid interval : 227 milliseconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for initialization : 0.004 seconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of result points : 961436</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for integration : 1.17e+03 seconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for one grid interval : 234 milliseconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">CPU-time for initialization : 0.005 seconds</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of result points : 959331</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of grid points : 5001</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of accepted steps : 9072834</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of f-evaluations (dynamics) : 18084763</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of crossing function evaluations : 9575493</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of Jacobian-evaluations : 3918760</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of accepted steps : 9172936</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of f-evaluations (dynamics) : 18295816</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of crossing function evaluations : 9668298</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of Jacobian-evaluations : 4006190</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of model time events : 476996</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of input time events : 0</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of state events : 3815</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of state events : 2744</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Number of step events : 0</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Minimum integration stepsize : 2.78e-10</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Maximum integration stepsize : 0.00922</span></p>
<p style=\"margin-left: 90px;\"><span style=\"font-family: Courier New; font-size: 10pt;\">Maximum integration order : 5</span></p>
<p>Looking at the first two lines of the metrics shows that running the model for 67.5 min (4050 sec.) took 19 min (1.14e+03 sec.). </p>
<p>Looking at the first two lines of the metrics shows that running the model for 67.5 min (4050 sec.) took 19.5 min (1.17e+03 sec.). </p>
<p>Naturally, using a computer with a weaker processor and lower memory will lead to longer run times.</p>
<p>Recall that the purpose of this simulation is to use it as input for system identification purposes as explained in [2]. If this is not necessary for your purposes, it is recommended that you run instead the function <a href=\"modelica://Example2.Analysis.AutomationFunctions.simulate_and_plot_ramping\">Example2.Analysis.AutomationFunctions.simulate_and_plot_ramping</a>, which takes substantially less time to execute.</p>
<p>If there is no interest to take into account the random load and probing signal, it is recommended that you run instead the function <a href=\"Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_ramping_pf\">Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_ramping_pf</a>, which takes substantially less time to execute.</p>
</html>"),preferredView="info");
end simulate_and_plot_inputs;
end simulate_and_plot_inputs_pf;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
within Example2.Analysis.PFVariants.AutomationFunctions;
function simulate_and_plot_ramping
"Simulates and plots the \"Ramping\" model"
function simulate_and_plot_ramping_pf
"Simulates and plots the \"Ramping_pf\" model"
extends Modelica.Icons.Function;
algorithm
// turn on flags to speed up the simulation
Expand All @@ -22,12 +22,12 @@ algorithm
<p><i><b>Usage:</b></i></p>
<ol>
<li>In the Package Browser, right click on the function and select &quot;Call function...&quot;. This will open the function&apos;s window.</li>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_fun.png\"/></p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_fun_pf.png\"/></p>
<li>In the new function window, click on &quot;Execute&quot;, if successful, messages/results are displayed in the command window and plots will appear in Simulation tab.</li>
<li>Go back to the function&apos;s own window and click on &quot;Close&quot;. </li>
</ol>
<p><br><i><b>Sample Output:</b></i></p>
<p>Running the function will result in the following plot.</p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_ramping.png\"/></p>
<p><img src=\"modelica://Example2/Resources/simulate_and_plot_ramping_pf.png\"/></p>
</html>"),preferredView="info");
end simulate_and_plot_ramping;
end simulate_and_plot_ramping_pf;
5 changes: 2 additions & 3 deletions Example2/Analysis/PFVariants/RampingRandomLoadAndInput_pf.mo
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ equation
Diagram(coordinateSystem(extent={{-200,-200},{200,200}})),
Icon(coordinateSystem(extent={{-100,-100},{100,100}})),preferredView="diagram",
Documentation(info="<html>
<p>Main model used for simulation in [1] and [2]. </p>
<p>To reproduce the results in Fig. 4 of [2], execute the function <a href=\"modelica://Example2.Analysis.AutomationFunctions.simulate_and_plot_inputs\">Example2.Analysis.AutomationFunctions.simulate_and_plot_inputs</a> , which sets up the adequate solver settings to minimize run time.</p>
<p>Please note that running this model takes substantial time compared to example <a href=\"modelica://Example2.Analysis.Ramping\">Example2.Analysis.Ramping</a>, the reason is that both random load and probing signals are added to the model which results in an additional computation burden. </p>
<p>To simulate this model it is recommended to execute the function <a href=\"Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_inputs_pf\">Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_inputs_pf</a> , which sets up the adequate solver settings to minimize run time.</p>
<p>Please note that running this model takes substantial time compared to example <a href=\"Example2.Analysis.PFVariants.Ramping_pf\">Example2.Analysis.PFVariants.Ramping_pf</a>, the reason is that both random load and probing signals are added to the model which results in an additional computation burden. </p>
</html>"),preferredView="diagram");
end RampingRandomLoadAndInput_pf;
3 changes: 2 additions & 1 deletion Example2/Analysis/PFVariants/Ramping_pf.mo
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ equation
Diagram(coordinateSystem(extent={{-200,-200},{200,200}})),
Icon(coordinateSystem(extent={{-100,-100},{100,100}})),preferredView="diagram",
Documentation(info="<html>
<p>This model illustrates how ramping is applied to move the system to multiple operating points.</p><p>To simulate this model and plot the results, execute the function <a href=\"modelica://Example2.Analysis.AutomationFunctions.simulate_and_plot_ramping\">Example2.Analysis.AutomationFunctions.simulate_and_plot_ramping</a> , which sets up the adequate solver settings to minimize run time.</p>
<p>This model illustrates how ramping is applied to move the system to multiple operating points.</p>
<p>To simulate this model and plot the results, execute the function <a href=\"Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_ramping_pf\">Example2.Analysis.PFVariants.AutomationFunctions.simulate_and_plot_ramping_pf</a> , which sets up the adequate solver settings to minimize run time.</p>
</html>"));
end Ramping_pf;
2 changes: 1 addition & 1 deletion Example2/Analysis/PFVariants/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ within Example2.Analysis;
package PFVariants "Variants with redeclarable power flow structures for top-level re-parametrization"
extends Modelica.Icons.VariantsPackage;
annotation (Documentation(info="<html>
<p>Uses the system model in Example2.Base.Systems.PFVariants that takes advantage of OpenIPSL data types with nominal attributes and top-level re-parametrization of power flow initial guess data. </p>
<p>Uses the system model in <a href=\"Example2.Base.Systems.PFVariants.syspf\">Example2.Base.Systems.PFVariants.syspf</a> that takes advantage of OpenIPSL data types with nominal attributes and top-level re-parametrization of power flow initial guess data. </p>
<p>It is recommended that the models within this package are used for derivative works. See more details in the information layer of <a href=\"modelica://Example2.PFData\">Example2.PFData</a>.</p>
</html>"),preferredView="info");
end PFVariants;
9 changes: 4 additions & 5 deletions Example2/Analysis/Readme/package.mo
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ package Readme "Recommended models for derivative work"
<li>In the examples this layer of the package, <a href=\"
Example2.Analysis\">Example2.Analysis</a>, the power flow intial guess data is provided through the <b>records</b> in <a href=\"
Example2.Base.Systems.Basic.Data\">Example2.Base.Systems.Basic.Data</a>. To change the data, it is necessary to modify the base model in <a href=\"
Example2.Base.Systems.Basic.sys\">Example2.Base.Systems.Basic.sys</a> by changing the name of the record in the text layer. This is obviously inconvenient, but also, the types are generic and do not implement those of OpenIPSL.</li>
Example2.Base.Systems.Basic.sys\">Example2.Base.Systems.Basic.sys</a> by changing the name of the record in the text layer. This is obviously inconvenient, but also as explained above, the types are generic and do not implement those of OpenIPSL.</li>
<li>In the examples within the sub-package, <a href=\"
Example2.Analysis.PFVariants\">Example2.Analysis.PFVariants</a>, the <b>hierarchical replaceable records</b> in <a href=\"
Example2.PFData\">Example2.PFData</a> are used. The data can then be modified at the top-layer of the model by selecting from the available data sets (and/or providing new ones in <a href=\"
Example2.PFData.Data\">Example2.PFData.Data</a>) by clicking on the &quot;Power Flow Scenario&quot; tab of the &quot;Plant&quot; (instantiation of <a href=\"modelica://Example2.Base.Systems.PFVariants.syspf\">syspf</a>), as the records have been propagated and configured for this purposes, as shown in the screenshot below:</li>
Example2.PFData.Data\">Example2.PFData.Data</a>) by clicking on the &quot;Power Flow Scenario&quot; tab of the &quot;Plant&quot; (instantiation of <a href=\"modelica://Example2.Base.Systems.PFVariants.syspf\">syspf</a>), as the records have been propagated and configured for this purposes, as shown in the screenshot below.<br><img src=\"modelica://Example2/Resources/pfsys.png\"/></li>
</ol>
<p style=\"margin-left: 90px;\"><img src=\"modelica://Example2/../../../../Downloads/pf.png\"/></p>
<p>It is important to note that even though the models in 1. and 2. above are identical in terms of their equations, the intialization will be different due to the use of the nominal attributes. Read more on this aspect under the information layer of <a href=\"modelica://Example2.PFData\">Example2.PFData</a>.</p>
</html>"));
<p><br>It is important to note that even though the models in 1. and 2. above are identical in terms of their equations, the intialization will be different due to the use of the nominal attributes. Read more on this aspect under the information layer of <a href=\"modelica://Example2.PFData\">Example2.PFData</a>.</p>
</html>"),preferredView="info");
end Readme;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Example2/Resources/linfun_pf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Example2/Resources/linfun_pf_kchange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Example2/Resources/pfsys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Example2/Resources/simulate_and_plot_fun_pf.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 67a553e

Please sign in to comment.