Skip to content

Commit

Permalink
Merge pull request #27 from fvanderlinden/master
Browse files Browse the repository at this point in the history
Added globalSeed to Examples
  • Loading branch information
Franciscus van der Linden committed Jun 25, 2014
2 parents 3a84684 + dc59ca8 commit 0f5a9d0
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Noise/Examples/Actuator/ActuatorPRNGNoise.mo
Expand Up @@ -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={{70,70},{90,90}})));
annotation (
experiment(
StopTime=8,
Expand Down
2 changes: 1 addition & 1 deletion Noise/Examples/Actuator/Parts/package.mo
@@ -1,5 +1,5 @@
within Noise.Examples.Actuator;
package Parts
package Parts
annotation (Documentation(revisions="<html>
<p><img src=\"modelica://Noise/Resources/Images/dlr_logo.png\"/> <b>Developed 2014 at the DLR Institute of System Dynamics and Control</b> </p>
</html>", info="<html>
Expand Down
2 changes: 1 addition & 1 deletion Noise/Examples/Actuator/package.mo
@@ -1,5 +1,5 @@
within Noise.Examples;
package Actuator
package Actuator
extends Modelica.Icons.ExamplesPackage;


Expand Down
2 changes: 2 additions & 0 deletions Noise/Examples/Analysis.mo
Expand Up @@ -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={{70,70},{90,90}})));
equation
connect(prng.y, mu.u) annotation (Line(
points={{-59,50},{18,50}},
Expand Down
2 changes: 2 additions & 0 deletions Noise/Examples/ComparePDF.mo
Expand Up @@ -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="<html>
Expand Down
2 changes: 2 additions & 0 deletions Noise/Examples/ComparePSD.mo
Expand Up @@ -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={{70,70},{90,90}})));
annotation (
experiment(StopTime=100, Interval=0.001),
Documentation(revisions="<html>
Expand Down
2 changes: 2 additions & 0 deletions Noise/Examples/CompareRNG.mo
Expand Up @@ -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={{70,70},{90,90}})));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-100,
-100},{100,100}}),
graphics={Rectangle(
Expand Down
2 changes: 1 addition & 1 deletion Noise/Examples/PRNG.mo
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Noise/Examples/SystemNoiseInteraction/PRNGNoise.mo
Expand Up @@ -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}},
Expand Down
2 changes: 1 addition & 1 deletion Noise/Examples/TestSeeding.mo
Expand Up @@ -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="<html>
<p><img src=\"modelica://Noise/Resources/Images/dlr_logo.png\"/> <b>Developed 2014 at the DLR Institute of System Dynamics and Control</b> </p>
</html>", info="<html>
Expand Down
6 changes: 6 additions & 0 deletions Noise/Utilities/Analysis/Corr.mo
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion Noise/Utilities/Analysis/Mu.mo
Expand Up @@ -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;
Expand Down

0 comments on commit 0f5a9d0

Please sign in to comment.