Skip to content

Commit

Permalink
test for algorithm counting
Browse files Browse the repository at this point in the history
  • Loading branch information
vwaurich authored and OpenModelica-Hudson committed Oct 27, 2016
1 parent cfb4594 commit 73de300
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
51 changes: 51 additions & 0 deletions simulation/modelica/algorithms_functions/AlgorithmSize.mo
@@ -0,0 +1,51 @@
within ;
model AlgorithmSize
block conditionSignal
Modelica.Blocks.Interfaces.RealInput u
annotation (Placement(transformation(extent={{-124,-20},{-84,20}})));
Modelica.Blocks.Interfaces.RealOutput y
annotation (Placement(transformation(extent={{94,-20},{130,20}})));
Real norm_u;
parameter Real range = 1023;
parameter Real minSignal = 0.2;
parameter Real a = 1/(1-minSignal);
parameter Real b = minSignal*a;
algorithm
norm_u := (u-range/2)/range*2;
if norm_u < -minSignal then
y := -a*abs(norm_u)+b;
elseif norm_u > minSignal then
y := a*abs(norm_u)-b;
else
y :=0.0;
end if;
end conditionSignal;

Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape shape1(
length=1,
width=1,
height=1,
color={170,255,85},
r={signal1.y,1,0})
annotation (Placement(transformation(extent={{-60,40},{-40,60}})));
conditionSignal signal1
annotation (Placement(transformation(extent={{-100,46},{-80,66}})));
Modelica.Blocks.Sources.Sine sine
annotation (Placement(transformation(extent={{-128,46},{-108,66}})));
equation

connect(signal1.u, sine.y) annotation (Line(
points={{-100.4,56},{-107,56}},
color={0,0,127},
smooth=Smooth.None));
annotation (Diagram(coordinateSystem(preserveAspectRatio=false, extent={{-200,
-100},{100,100}}), graphics),
experiment(
StopTime=15,
Tolerance=0.001,
__Dymola_fixedstepsize=0.001,
__Dymola_Algorithm="Euler"),
__Dymola_experimentSetupOutput,
Icon(coordinateSystem(extent={{-200,-100},{100,100}})),
uses(Modelica(version="3.2.1")));
end AlgorithmSize;
23 changes: 23 additions & 0 deletions simulation/modelica/algorithms_functions/AlgorithmSize.mos
@@ -0,0 +1,23 @@
// name: AlgorithmSize
// keywords: algorithm, removeSimpleEquations
// status: correct
// teardown_command: rm -rf AlgorithmSize_* _AlgorithmSize_* output.log
//
// tests for counting of algorithm section output variables.
// This model replaces a variable with a array-element in RemoveSimpleEquations. Do not count the expanded array-var, only the one element.

loadModel(Modelica,{"3.2.1"}); getErrorString();
loadFile("AlgorithmSize.mo");getErrorString();
simulate(AlgorithmSize);getErrorString();
// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "AlgorithmSize_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 15.0, numberOfIntervals = 500, tolerance = 0.001, method = 'dassl', fileNamePrefix = 'AlgorithmSize', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// ""
// endResult
1 change: 1 addition & 0 deletions simulation/modelica/algorithms_functions/Makefile
Expand Up @@ -6,6 +6,7 @@ AlgorithmCondAssign2.mos \
AlgorithmForInClass.mos \
algorithms.mos \
AlgorithmSection.mos \
AlgorithmSize.mos \
AlgorithmTupleAssign.mos \
ArrayInitSorting.mos \
ASubIfExp.mos \
Expand Down

0 comments on commit 73de300

Please sign in to comment.