From 328ac208494f0345b66b86408eb555022d94f62a Mon Sep 17 00:00:00 2001 From: akloeckner Date: Wed, 25 Jun 2014 10:33:34 +0200 Subject: [PATCH 1/3] Added globalSeed to examples --- Noise/Examples/Actuator/ActuatorPRNGNoise.mo | 2 ++ Noise/Examples/Analysis.mo | 2 ++ Noise/Examples/ComparePDF.mo | 2 ++ Noise/Examples/ComparePSD.mo | 2 ++ Noise/Examples/CompareRNG.mo | 2 ++ Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo | 2 ++ 6 files changed, 12 insertions(+) diff --git a/Noise/Examples/Actuator/ActuatorPRNGNoise.mo b/Noise/Examples/Actuator/ActuatorPRNGNoise.mo index 2aa8138..849b6e9 100644 --- a/Noise/Examples/Actuator/ActuatorPRNGNoise.mo +++ b/Noise/Examples/Actuator/ActuatorPRNGNoise.mo @@ -2,6 +2,8 @@ within Noise.Examples.Actuator; model ActuatorPRNGNoise extends Actuator(controller(redeclare Noise.Examples.Actuator.Parts.PRNG noiseModel)); + inner GlobalSeed globalSeed + annotation (Placement(transformation(extent={{60,60},{80,80}}))); annotation ( experiment( StopTime=8, diff --git a/Noise/Examples/Analysis.mo b/Noise/Examples/Analysis.mo index cfb7125..50f54d8 100644 --- a/Noise/Examples/Analysis.mo +++ b/Noise/Examples/Analysis.mo @@ -17,6 +17,8 @@ model Analysis "Shows how to analyze a noise signal" annotation (Placement(transformation(extent={{20,-40},{40,-20}}))); Noise.Utilities.Analysis.Corr corr annotation (Placement(transformation(extent={{20,-80},{40,-60}}))); + inner Noise.GlobalSeed globalSeed + annotation (Placement(transformation(extent={{60,60},{80,80}}))); equation connect(prng.y, mu.u) annotation (Line( points={{-59,50},{18,50}}, diff --git a/Noise/Examples/ComparePDF.mo b/Noise/Examples/ComparePDF.mo index 5034cb9..c347e3d 100644 --- a/Noise/Examples/ComparePDF.mo +++ b/Noise/Examples/ComparePDF.mo @@ -24,6 +24,8 @@ model ComparePDF "Compares different PSDs" Noise.PRNG DiscreteDistribution(useSampleBasedMethods=false, redeclare function PDF = Noise.PDF.PDF_Discrete) annotation (Placement(transformation(extent={{20,30},{40,50}}))); + inner Noise.GlobalSeed globalSeed + annotation (Placement(transformation(extent={{70,70},{90,90}}))); annotation ( experiment(StopTime=100, Interval=0.001), Documentation(revisions=" diff --git a/Noise/Examples/ComparePSD.mo b/Noise/Examples/ComparePSD.mo index 343bd9d..0f57798 100644 --- a/Noise/Examples/ComparePSD.mo +++ b/Noise/Examples/ComparePSD.mo @@ -18,6 +18,8 @@ model ComparePSD "Compares different PSDs" useSampleBasedMethods=false, redeclare function PDF = Noise.PDF.PDF_Uniform (interval={-1,1})) annotation (Placement(transformation(extent={{-40,-50},{-20,-30}}))); + inner Noise.GlobalSeed globalSeed + annotation (Placement(transformation(extent={{60,60},{80,80}}))); annotation ( experiment(StopTime=100, Interval=0.001), Documentation(revisions=" diff --git a/Noise/Examples/CompareRNG.mo b/Noise/Examples/CompareRNG.mo index ad588de..b67db53 100644 --- a/Noise/Examples/CompareRNG.mo +++ b/Noise/Examples/CompareRNG.mo @@ -21,6 +21,8 @@ model CompareRNG blockType=Parts.Modelica_LinearSystems2.Controller.Types.BlockType.Discrete, sampleTime=0.01) annotation (Placement(transformation(extent={{-80,70},{-60,90}}))); + inner GlobalSeed globalSeed + annotation (Placement(transformation(extent={{60,68},{80,88}}))); annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100, -100},{100,100}}), graphics={Rectangle( diff --git a/Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo b/Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo index 7f991ff..f4da8fd 100644 --- a/Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo +++ b/Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo @@ -18,6 +18,8 @@ model PRNGNoise "Shows the modelling of a noisy sensor" n=50, initType=Modelica.Blocks.Types.Init.InitialState) annotation (Placement(transformation(extent={{60,-10},{80,10}}))); + inner GlobalSeed globalSeed + annotation (Placement(transformation(extent={{-70,-10},{-50,10}}))); equation connect(prng.y, criticalDamping.u) annotation (Line( points={{-17,0},{58,0}}, From db117637a69024a574916c9f9ddd9cbc36294d62 Mon Sep 17 00:00:00 2001 From: akloeckner Date: Wed, 25 Jun 2014 10:34:07 +0200 Subject: [PATCH 2/3] Fixed incomplete initialization of integrators --- Noise/Utilities/Analysis/Corr.mo | 6 ++++++ Noise/Utilities/Analysis/Mu.mo | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Noise/Utilities/Analysis/Corr.mo b/Noise/Utilities/Analysis/Corr.mo index 45d4b95..b8a9501 100644 --- a/Noise/Utilities/Analysis/Corr.mo +++ b/Noise/Utilities/Analysis/Corr.mo @@ -38,6 +38,12 @@ public Real int_x2 "The integral of x^2"; Real int_y2 "The integral of y^2"; Real int_xy "The integral of x*y"; +initial equation + int_x = 0; + int_y = 0; + int_x2 = 0; + int_y2 = 0; + int_xy = 0; equation der(int_x) = if t <= 0 then 0 else x; der(int_y) = if t <= 0 then 0 else y; diff --git a/Noise/Utilities/Analysis/Mu.mo b/Noise/Utilities/Analysis/Mu.mo index ae82b86..84e85c6 100644 --- a/Noise/Utilities/Analysis/Mu.mo +++ b/Noise/Utilities/Analysis/Mu.mo @@ -9,7 +9,8 @@ protected Real mu_0 "Internal integrator variable"; parameter Real t_0(fixed=false) "Start time"; initial equation - t_0 = time; + t_0 = time; + mu_0 = 0; equation der(mu_0) = u; mu = if time > t_0 then mu_0/(time-t_0) else u; From dc59ca80c597cb5c1d2f3b6efea0f7940c383ec1 Mon Sep 17 00:00:00 2001 From: fvanderlinden Date: Wed, 25 Jun 2014 11:08:28 +0200 Subject: [PATCH 3/3] Aligned all global seeds at the same positions --- Noise/Examples/Actuator/ActuatorPRNGNoise.mo | 2 +- Noise/Examples/Actuator/Parts/package.mo | 2 +- Noise/Examples/Actuator/package.mo | 2 +- Noise/Examples/Analysis.mo | 2 +- Noise/Examples/ComparePSD.mo | 2 +- Noise/Examples/CompareRNG.mo | 2 +- Noise/Examples/PRNG.mo | 2 +- Noise/Examples/TestSeeding.mo | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Noise/Examples/Actuator/ActuatorPRNGNoise.mo b/Noise/Examples/Actuator/ActuatorPRNGNoise.mo index 849b6e9..dff6f97 100644 --- a/Noise/Examples/Actuator/ActuatorPRNGNoise.mo +++ b/Noise/Examples/Actuator/ActuatorPRNGNoise.mo @@ -3,7 +3,7 @@ model ActuatorPRNGNoise extends Actuator(controller(redeclare Noise.Examples.Actuator.Parts.PRNG noiseModel)); inner GlobalSeed globalSeed - annotation (Placement(transformation(extent={{60,60},{80,80}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); annotation ( experiment( StopTime=8, diff --git a/Noise/Examples/Actuator/Parts/package.mo b/Noise/Examples/Actuator/Parts/package.mo index fc3a5b8..98498f8 100644 --- a/Noise/Examples/Actuator/Parts/package.mo +++ b/Noise/Examples/Actuator/Parts/package.mo @@ -1,5 +1,5 @@ within Noise.Examples.Actuator; -package Parts +package Parts annotation (Documentation(revisions="

Developed 2014 at the DLR Institute of System Dynamics and Control

", info=" diff --git a/Noise/Examples/Actuator/package.mo b/Noise/Examples/Actuator/package.mo index b597690..0370055 100644 --- a/Noise/Examples/Actuator/package.mo +++ b/Noise/Examples/Actuator/package.mo @@ -1,5 +1,5 @@ within Noise.Examples; -package Actuator +package Actuator extends Modelica.Icons.ExamplesPackage; diff --git a/Noise/Examples/Analysis.mo b/Noise/Examples/Analysis.mo index 50f54d8..d3ef17d 100644 --- a/Noise/Examples/Analysis.mo +++ b/Noise/Examples/Analysis.mo @@ -18,7 +18,7 @@ model Analysis "Shows how to analyze a noise signal" Noise.Utilities.Analysis.Corr corr annotation (Placement(transformation(extent={{20,-80},{40,-60}}))); inner Noise.GlobalSeed globalSeed - annotation (Placement(transformation(extent={{60,60},{80,80}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); equation connect(prng.y, mu.u) annotation (Line( points={{-59,50},{18,50}}, diff --git a/Noise/Examples/ComparePSD.mo b/Noise/Examples/ComparePSD.mo index 0f57798..9928ef1 100644 --- a/Noise/Examples/ComparePSD.mo +++ b/Noise/Examples/ComparePSD.mo @@ -19,7 +19,7 @@ model ComparePSD "Compares different PSDs" redeclare function PDF = Noise.PDF.PDF_Uniform (interval={-1,1})) annotation (Placement(transformation(extent={{-40,-50},{-20,-30}}))); inner Noise.GlobalSeed globalSeed - annotation (Placement(transformation(extent={{60,60},{80,80}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); annotation ( experiment(StopTime=100, Interval=0.001), Documentation(revisions=" diff --git a/Noise/Examples/CompareRNG.mo b/Noise/Examples/CompareRNG.mo index b67db53..d3bc5a5 100644 --- a/Noise/Examples/CompareRNG.mo +++ b/Noise/Examples/CompareRNG.mo @@ -22,7 +22,7 @@ model CompareRNG sampleTime=0.01) annotation (Placement(transformation(extent={{-80,70},{-60,90}}))); inner GlobalSeed globalSeed - annotation (Placement(transformation(extent={{60,68},{80,88}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100, -100},{100,100}}), graphics={Rectangle( diff --git a/Noise/Examples/PRNG.mo b/Noise/Examples/PRNG.mo index 61da6d6..d949dca 100644 --- a/Noise/Examples/PRNG.mo +++ b/Noise/Examples/PRNG.mo @@ -4,7 +4,7 @@ model PRNG "Shows the use of the basic PRNG block" extends Modelica.Icons.Example; inner GlobalSeed globalSeed - annotation (Placement(transformation(extent={{40,40},{60,60}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); Noise.PRNG prng annotation (Placement(transformation(extent={{-10,-12},{10,8}}))); equation diff --git a/Noise/Examples/TestSeeding.mo b/Noise/Examples/TestSeeding.mo index 396bfb8..312ac70 100644 --- a/Noise/Examples/TestSeeding.mo +++ b/Noise/Examples/TestSeeding.mo @@ -19,7 +19,7 @@ model TestSeeding localSeed=25634) annotation (Placement(transformation(extent={{-40,0},{-20,20}}))); inner Noise.GlobalSeed globalSeed(userSeed=1446) - annotation (Placement(transformation(extent={{-80,60},{-60,80}}))); + annotation (Placement(transformation(extent={{70,70},{90,90}}))); annotation (Documentation(revisions="

Developed 2014 at the DLR Institute of System Dynamics and Control

", info="