Skip to content

Commit

Permalink
Added testcase for splitting generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Dec 14, 2016
1 parent ffd20b2 commit 04ae07a
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Makefile
Expand Up @@ -35,7 +35,8 @@ resolveLoops.log \
evalConstFuncs.log \
flatteningBuildings.log \
buildings.log \
requirements.log
requirements.log \
scalable.log

SIMULATIONLOGS = \
linearization.log \
Expand Down Expand Up @@ -557,6 +558,9 @@ hummod.log: omc-diff
openmodelicadiff.log: omc-diff
$(MAKE) -C openmodelica/diff -f Makefile test > $@
@echo $@ done
scalable.log: omc-diff
$(MAKE) -C simulation/libraries/3rdParty/ScalableTestSuite -f Makefile test > $@
@echo $@ done
requirements.log: omc-diff
$(MAKE) -C openmodelica/requirements -f Makefile test > $@
@echo $@ done
Expand Down
50 changes: 50 additions & 0 deletions simulation/libraries/3rdParty/ScalableTestSuite/Advection_N3200.mo
@@ -0,0 +1,50 @@
package Modelica "Modelica Standard Library - Version 3.2.1 (Build 4)"
extends Modelica.Icons.Package;

package Icons "Library of icons"
extends Icons.Package;

partial package ExamplesPackage "Icon for packages containing runnable examples"
extends Modelica.Icons.Package;
end ExamplesPackage;

partial package Package "Icon for standard packages" end Package;
end Icons;
annotation(version = "3.2.1", versionBuild = 4, versionDate = "2013-08-14", dateModified = "2015-09-30 09:15:00Z");
end Modelica;

package ScalableTestSuite "A library of scalable Modelica test models"
package Thermal "Models from the thermal domain"
package Advection "1D advection models"
package Models
model AdvectionReaction "Model of an advection process with chemical reaction"
parameter Integer N = 10 "Number of volumes";
parameter Real mu = 1000 "Kinetic coefficient of the reaction";
constant Real alpha = 0.5 "Parameter of the reaction model";
Real u_in = 1 "Inlet concentration";
Real[N] u(each start = 0, each fixed = true) "Concentration at each volume outlet";
equation
der(u[1]) = ((-u[1]) + 1) * N - mu * u[1] * (u[1] - alpha) * (u[1] - 1);
for j in 2:N loop
der(u[j]) = ((-u[j]) + u[j - 1]) * N - mu * u[j] * (u[j] - alpha) * (u[j] - 1);
end for;
end AdvectionReaction;
end Models;

package ScaledExperiments
extends Modelica.Icons.ExamplesPackage;

model AdvectionReaction_N_3200
extends Models.AdvectionReaction(N = 3200, mu = 16000);
annotation(experiment(StopTime = 1, NumberOfIntervals = 5000, Tolerance = 1e-6));
end AdvectionReaction_N_3200;
end ScaledExperiments;
end Advection;
end Thermal;
annotation(version = "1.7.1");
end ScalableTestSuite;

model AdvectionReaction_N_3200_total
extends ScalableTestSuite.Thermal.Advection.ScaledExperiments.AdvectionReaction_N_3200;
annotation(experiment(StopTime = 1, NumberOfIntervals = 5000, Tolerance = 1e-6));
end AdvectionReaction_N_3200_total;
@@ -0,0 +1,32 @@
// status: correct
// This is a test for equationsPerFile compiling as it should

loadFile("Advection_N3200.mo");getErrorString();

setCommandLineOptions("--daeMode=dynamic -d=nogen");
extraSimFlags := "-mei=4000 -daeMode -s=ida -idaLS=klu --equationsPerFile=200";
setCFlags(getCFlags() + " -Os");

file := "AdvectionReaction_N_3200_total_06inz_part2.c";
if regularFileExists(file) then
print("Files not cleaned up properly: " + file);
end if;
translateModel(AdvectionReaction_N_3200_total);getErrorString();
if not regularFileExists(file) then
print("Files not created properly: " + file);
else
print("OK");
end if;

// Result:
// true
// ""
// true
// "-mei=4000 -daeMode -s=ida -idaLS=klu --equationsPerFile=200"
// true
// "AdvectionReaction_N_3200_total_06inz_part2.c"
//
// true
// ""
// OK
// endResult
50 changes: 50 additions & 0 deletions simulation/libraries/3rdParty/ScalableTestSuite/Makefile
@@ -0,0 +1,50 @@
TEST = ../../../../rtest -v

TESTFILES = \
Advection_N3200.mos \

# test that currently fail. Move up when fixed.
# Run make failingtest
FAILINGTESTFILES = \

# Dependency files that are not .mo .mos or Makefile
# Add them here or they will be cleaned.
DEPENDENCIES = \
ReferenceFiles \
*.mo \
*.mos \
Makefile \

CLEAN = `ls | grep -w -v -f deps.tmp`

.PHONY : test clean getdeps failingtest

test:
@echo
@echo Running tests...
@echo
@echo OPENMODELICAHOME=" $(OPENMODELICAHOME) "
@$(TEST) $(TESTFILES)

# Cleans all files that are not listed as dependencies
clean:
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
@rm -f $(CLEAN)

# Run this if you want to list out the files (dependencies).
# do it after cleaning and updating the folder
# then you can get a list of file names (which must be dependencies
# since you got them from repository + your own new files)
# then add them to the DEPENDENCIES. You can find the
# list in deps.txt
getdeps:
@echo $(DEPENDENCIES) | sed 's/ /\\|/g' > deps.tmp
@echo $(CLEAN) | sed -r 's/deps.txt|deps.tmp//g' | sed 's/ / \\\n/g' > deps.txt
@echo Dependency list saved in deps.txt.
@echo Copy the list from deps.txt and add it to the Makefile @DEPENDENCIES

failingtest:
@echo
@echo Running failing tests...
@echo
@$(TEST) $(FAILINGTESTFILES)
6 changes: 3 additions & 3 deletions simulation/modelica/declarations/MyPointsInst1.mos
Expand Up @@ -2,10 +2,10 @@
// keywords: <insert keywords here>
// status: correct
// teardown_command: rm -rf MyPointsInst1_* MyPointsInst1 MyPointsInst1.exe MyPointsInst1.cpp MyPointsInst1.makefile MyPointsInst1.libs MyPointsInst1.log output.log
//
//
// <insert description here>
// Drmodelica: 2.2 Declaring Instances of Classes (p. 26)
//
// Drmodelica: 2.2 Declaring Instances of Classes (p. 26)
//
loadFile("MyPointsInst1.mo");
simulate(MyPointsInst1,numberOfIntervals=2, tolerance=1e-5); // 2 intervals == 3 values
val(x,0.0);
Expand Down

0 comments on commit 04ae07a

Please sign in to comment.