Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/OpenModelica/OpenModelica…
- Loading branch information
Showing
43 changed files
with
2,246 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// name: RedeclareArrayComponent1 | ||
// keywords: redeclare component array | ||
// status: correct | ||
// | ||
// Checks that a redeclared components gets get correct type when using an array | ||
// type. | ||
// | ||
|
||
model A | ||
replaceable Real x[2]; | ||
end A; | ||
|
||
model RedeclareArrayComponent1 | ||
type Real3 = Real[3]; | ||
A a1(redeclare Real3 x); | ||
A a2(redeclare Real x); | ||
end RedeclareArrayComponent1; | ||
|
||
// Result: | ||
// class RedeclareArrayComponent1 | ||
// Real a1.x[1]; | ||
// Real a1.x[2]; | ||
// Real a1.x[3]; | ||
// Real a2.x[1]; | ||
// Real a2.x[2]; | ||
// end RedeclareArrayComponent1; | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// name: clockedTypesTest | ||
// keywords: synchronous clocked equations types | ||
// status: correct | ||
// teardown_command: rm -f *ClockedTypes* | ||
|
||
setCommandLineOptions("+simCodeTarget=Cpp"); | ||
|
||
loadString(" | ||
model ClockedTypes | ||
Boolean firstTick(start = true); | ||
Boolean pulse(start = false); | ||
Integer counter(start = 0); | ||
String text(start = \"\"); | ||
equation | ||
when Clock(0.5) then | ||
firstTick = false; | ||
pulse = not previous(pulse); | ||
counter = previous(counter) + 1; | ||
text = previous(text) + \", \" + String(counter); | ||
end when; | ||
end ClockedTypes; | ||
"); | ||
getErrorString(); | ||
|
||
simulate(ClockedTypes); | ||
val(firstTick, 0.0); | ||
val(firstTick, 1.0); | ||
val(pulse, 0.0); | ||
val(pulse, 1.0); | ||
val(counter, 0.0); | ||
val(counter, 1.0); | ||
//val(text, 1.0); // not supported in results file? | ||
getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "ClockedTypes_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'ClockedTypes', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// 0.0 | ||
// 0.0 | ||
// 1.0 | ||
// 1.0 | ||
// 1.0 | ||
// 3.0 | ||
// "" | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletions
143
openmodelica/cppruntime/fmu/modelExchange/2.0/testModelDescription.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
// name: testModelDescription | ||
// keywords: FMI 2.0 export clocks | ||
// status: correct | ||
// teardown_command: rm -rf binaries sources modelDescription.xml modelDescription.tmp.xml *SID* output.log | ||
// | ||
|
||
setCommandLineOptions("+simCodeTarget=Cpp"); getErrorString(); | ||
loadString(" | ||
model SID | ||
constant Real dt = 0.1; | ||
parameter Real p = 1; | ||
parameter Real y_start = 0; | ||
Real xd(start = y_start); | ||
input Real u(start = -2); | ||
output Real y; | ||
equation | ||
when Clock(dt) then | ||
xd = previous(xd) + p * u * dt; | ||
y = previous(xd); | ||
end when; | ||
end SID; | ||
"); | ||
getErrorString(); | ||
|
||
translateModelFMU(SID, version="2.0"); | ||
getErrorString(); | ||
|
||
// unzip to console, quiet, extra quiet | ||
system("unzip -cqq SID.fmu modelDescription.xml | grep -v guid | grep -v generationDateAndTime | grep -v generationTool > modelDescription.tmp.xml"); | ||
readFile("modelDescription.tmp.xml"); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// "SimCode: The model SID has been translated to FMU" | ||
// "" | ||
// 0 | ||
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?> | ||
// <fmiModelDescription | ||
// fmiVersion=\"2.0\" | ||
// modelName=\"SID\" | ||
// description=\"\" | ||
// variableNamingConvention=\"structured\" | ||
// numberOfEventIndicators=\"0\"> | ||
// <ModelExchange | ||
// modelIdentifier=\"SID\"> | ||
// </ModelExchange> | ||
// <LogCategories> | ||
// <Category name=\"logEvents\" /> | ||
// <Category name=\"logSingularLinearSystems\" /> | ||
// <Category name=\"logNonlinearSystems\" /> | ||
// <Category name=\"logDynamicStateSelection\" /> | ||
// <Category name=\"logStatusWarning\" /> | ||
// <Category name=\"logStatusDiscard\" /> | ||
// <Category name=\"logStatusError\" /> | ||
// <Category name=\"logStatusFatal\" /> | ||
// <Category name=\"logStatusPending\" /> | ||
// <Category name=\"logAll\" /> | ||
// <Category name=\"logFmi2Call\" /> | ||
// </LogCategories> | ||
// <DefaultExperiment startTime=\"0.0\" stopTime=\"1.0\" tolerance=\"1e-06\"/> | ||
// <ModelVariables> | ||
// <!-- Index of variable = \"1\" --> | ||
// <ScalarVariable | ||
// name=\"previous(xd)\" | ||
// valueReference=\"0\" | ||
// variability=\"discrete\" | ||
// causality=\"local\" | ||
// clockIndex=\"1\" | ||
// initial=\"exact\"> | ||
// <Real start=\"0.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"2\" --> | ||
// <ScalarVariable | ||
// name=\"u\" | ||
// valueReference=\"1\" | ||
// variability=\"continuous\" | ||
// causality=\"input\" | ||
// > | ||
// <Real start=\"-2.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"3\" --> | ||
// <ScalarVariable | ||
// name=\"xd\" | ||
// valueReference=\"2\" | ||
// variability=\"discrete\" | ||
// causality=\"local\" | ||
// clockIndex=\"1\" | ||
// previous=\"1\" | ||
// initial=\"exact\"> | ||
// <Real start=\"0.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"4\" --> | ||
// <ScalarVariable | ||
// name=\"y\" | ||
// valueReference=\"3\" | ||
// variability=\"discrete\" | ||
// causality=\"output\" | ||
// clockIndex=\"1\" | ||
// initial=\"calculated\"> | ||
// <Real/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"5\" --> | ||
// <ScalarVariable | ||
// name=\"p\" | ||
// valueReference=\"4\" | ||
// variability=\"fixed\" | ||
// causality=\"parameter\" | ||
// initial=\"exact\"> | ||
// <Real start=\"1.0\"/> | ||
// </ScalarVariable> | ||
// <!-- Index of variable = \"6\" --> | ||
// <ScalarVariable | ||
// name=\"y_start\" | ||
// valueReference=\"5\" | ||
// variability=\"fixed\" | ||
// causality=\"parameter\" | ||
// initial=\"exact\"> | ||
// <Real start=\"0.0\"/> | ||
// </ScalarVariable> | ||
// </ModelVariables> | ||
// <ModelStructure> | ||
// <Outputs> | ||
// <Unknown index=\"4\" /> | ||
// </Outputs> | ||
// <Derivatives> | ||
// </Derivatives> | ||
// <DiscreteStates> | ||
// <Unknown index=\"3\" /> | ||
// </DiscreteStates> | ||
// <InitialUnknowns> | ||
// </InitialUnknowns> | ||
// <Clocks> | ||
// <Clock><Periodic> | ||
// <Real interval=\"0.1\" /> | ||
// </Periodic></Clock> | ||
// </Clocks> | ||
// </ModelStructure> | ||
// </fmiModelDescription> | ||
// " | ||
// endResult |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
openmodelica/fmi/ModelExchange/2.0/testExperimentalFMU.mos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// name: TestExperimentalFMU | ||
// keywords: fmu export QSS multirate | ||
// status: correct | ||
|
||
loadString(" | ||
model advection | ||
parameter Real alpha = 0.5, mu = 100; | ||
constant Integer N = 100; | ||
Real u[N]; | ||
initial equation | ||
for i in 1:33 loop | ||
u[i] = 1; | ||
end for; | ||
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 advection; "); | ||
setDebugFlags("fmuExperimental"); | ||
translateModelFMU(advection ,"2","me","<default>"); | ||
getErrorString(); | ||
system("unzip -cqq advection.fmu sources/advection.c | grep \"void advection_functionODE_Partial(\""); | ||
|
||
// Result: | ||
// true | ||
// true | ||
// "SimCode: The model advection has been translated to FMU" | ||
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information. | ||
// " | ||
// void advection_functionODE_Partial(DATA *data, threadData_t *threadData, int i) | ||
// 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// name: problem12 | ||
// status: correct | ||
// teardown_command: rm -f nonlinear_system.problem12* output.log | ||
|
||
loadFile("nlsTestPackage.mo"); getErrorString(); | ||
|
||
simulate(nonlinear_system.problem12); getErrorString(); | ||
|
||
val(x,{0.0, 0.5, 1.0}); | ||
val(y,{0.0, 0.5, 1.0}); | ||
val(z,{0.0, 0.5, 1.0}); | ||
|
||
setCommandLineOptions("+d=NLSanalyticJacobian"); | ||
simulate(nonlinear_system.problem12); getErrorString(); | ||
|
||
val(x,{0.0, 0.5, 1.0}); | ||
val(y,{0.0, 0.5, 1.0}); | ||
val(z,{0.0, 0.5, 1.0}); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "nonlinear_system.problem12_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'nonlinear_system.problem12', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information. | ||
// " | ||
// {0.1413741945152485,0.2812491225132911,1.0} | ||
// {1.000399466692872,1.006256979103416,2.0} | ||
// {1.940439478068367,3.537907544719854,243.0} | ||
// true | ||
// record SimulationResult | ||
// resultFile = "nonlinear_system.problem12_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'nonlinear_system.problem12', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "" | ||
// end SimulationResult; | ||
// "Warning: There are iteration variables with default zero start attribute. Use +d=initialization for more information. | ||
// " | ||
// {0.1413741945152598,0.2812491225131152,1.0} | ||
// {1.000399466692872,1.0062569791034,2.0} | ||
// {1.940439478068463,3.537907544717219,243.0} | ||
// endResult |
Oops, something went wrong.