Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
355 additions
and
5 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
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,43 @@ | ||
// name: qss_example3 | ||
// status: correct | ||
|
||
// Quantization-Based New Integration Methods for Stiff ODEs | ||
// Migoni, Kofman, Cellier | ||
// May 2010, p. 16 | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example3 | ||
Real x1(nominal=1), x2(nominal=1); | ||
parameter Real a=0; | ||
parameter Real w=1; | ||
initial equation | ||
x1 = 4; | ||
x2 = 0; | ||
equation | ||
der(x1) = a * x1 + w * x2; | ||
der(x2) = -w * x1 + a * x2; | ||
end example3; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
simulate(qssTests.example3, stopTime=60, method="qss"); getErrorString(); | ||
val(x1, {0.0, 60.0}); getErrorString(); | ||
val(x2, {0.0, 60.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example3_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 60.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example3', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {4.0,-3.813295511112654} | ||
// "" | ||
// {0.0,1.220381953186809} | ||
// "" | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// name: qss_example4 | ||
// status: correct | ||
|
||
// Quantization-Based New Integration Methods for Stiff ODEs | ||
// Migoni, Kofman, Cellier | ||
// May 2010, p. 21 | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example4 | ||
Real x1(nominal=100), x2(nominal=100), x3(nominal=5e-4); | ||
initial equation | ||
x1 = 1; | ||
x2 = 1; | ||
x3 = 0; | ||
equation | ||
der(x1) = -0.013 * x1 - 1000 * x1 * x3; | ||
der(x2) = -2500 * x2 * x3; | ||
der(x3) = -0.013 * x1 - 1000 * x1 * x3 - 2500 * x2 * x3; | ||
end example4; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
simulate(qssTests.example4, stopTime=500, method="qss"); getErrorString(); | ||
val(x1, {0.0, 500.0}); getErrorString(); | ||
val(x2, {0.0, 500.0}); getErrorString(); | ||
val(x3, {0.0, 500.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example4_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 500.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example4', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// stdout | warning | All derivatives are zero at time 420.433938!. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {1.0,0.0} | ||
// "" | ||
// {1.0,1.999999999988223} | ||
// "" | ||
// {0.0,0.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// name: qss_example5 | ||
// status: correct | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example5 | ||
Real x1(nominal=1), x2(nominal=1e2), x3(nominal=1); | ||
initial equation | ||
x1=1; | ||
x2=1; | ||
x3=1; | ||
equation | ||
der(x1) = x3; | ||
der(x2) = x2 * sin(x3); | ||
der(x3) = x1 * sin(x2) * cos(x3); | ||
end example5; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--indexReductionMethod=uode");getErrorString(); | ||
simulate(qssTests.example5, stopTime=5, method="qss"); getErrorString(); | ||
val(x1, {0.0, 5.0}); getErrorString(); | ||
val(x2, {0.0, 5.0}); getErrorString(); | ||
val(x3, {0.0, 5.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example5_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 5.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example5', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {1.0,7.438837369532695} | ||
// "" | ||
// {1.0,118.3274783548923} | ||
// "" | ||
// {1.0,1.288486633956759} | ||
// "" | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// name: qss_example6 | ||
// status: correct | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example6 \"RLC Circuit\" | ||
Real x1(nominal=0.01), x2(nominal=1); | ||
parameter Real L=0.01; | ||
parameter Real U=100; | ||
parameter Real C=0.01; | ||
parameter Real R=100.01; | ||
initial equation | ||
x1 = 0; | ||
x2 = 0; | ||
equation | ||
der(x1) = x2 / L; | ||
der(x2) = U - x1 / C - R / L * x2; | ||
end example6; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--indexReductionMethod=uode");getErrorString(); | ||
simulate(qssTests.example6, stopTime=6, method="qss"); getErrorString(); | ||
val(x1, {0.0, 6.0}); getErrorString(); | ||
val(x2, {0.0, 6.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example6_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 6.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example6', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {0.0,0.9975217565500376} | ||
// "" | ||
// {0.0,4.146597733702257e-06} | ||
// "" | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// name: qss_example7 | ||
// status: correct | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example7 | ||
Real x1(nominal=3), x2(nominal=3); | ||
Real dx1(start=0, fixed=true, nominal=3), dx2(start=0, fixed=true, nominal=3); | ||
parameter Real m=1; | ||
parameter Real g=9.81; | ||
parameter Real L=0.5; | ||
parameter Real epsi=1e-6; | ||
Real F(nominal=30); | ||
initial equation | ||
// x1 = sqrt(epsi*(2-epsi)); | ||
// x2 = 0.5-epsi; | ||
x1 = 0.5; | ||
x2 = 0; | ||
equation | ||
der(x1) = dx1; | ||
der(x2) = dx2; | ||
m * der(dx1) = -(x1/L)*F; | ||
m * der(dx2) = -(x2/L)*F-m*g; | ||
(x1)^2+(x2)^2=L^2; | ||
end example7; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
setCommandLineOptions("--indexReductionMethod=uode");getErrorString(); | ||
simulate(qssTests.example7, stopTime=4.41636511, method="qss"); getErrorString(); | ||
val(x1, {0.0, 4.0}); getErrorString(); | ||
val(x2, {0.0, 4.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example7_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 4.41636511, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example7', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {0.5,-0.4707135376128905} | ||
// "" | ||
// {0.0,-0.1776113445770274} | ||
// "" | ||
// 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// name: qss_example8 | ||
// status: correct | ||
|
||
loadString(" | ||
within ; | ||
package qssTests | ||
model example8 | ||
Real x1(nominal=1), x2(nominal=1), x3(nominal=1); // deflexion | ||
Real x4(nominal=1), x5(nominal=1), x6(nominal=1); // velocity | ||
parameter Real m1=1; | ||
parameter Real m2=2; | ||
parameter Real m3=3; | ||
parameter Real c1=1; | ||
parameter Real c2=10; | ||
parameter Real c3=5; | ||
parameter Real c4=15; | ||
parameter Real d1=0.5; | ||
parameter Real d2=0.4; | ||
parameter Real d3=0.45; | ||
initial equation | ||
x1 = 0.1; | ||
x2 = 0; | ||
x3 = 0; | ||
x4 = 0; | ||
x5 = 0; | ||
x6 = 0; | ||
equation | ||
der(x1) = x4; | ||
der(x2) = x5; | ||
der(x3) = x6; | ||
der(x4) = -(c1+c2)/m1*x1 + c2/m1*x2 - d1/m1*x4; | ||
der(x5) = c2/m2*x1 - (c2+c3)/m2*x2 + c3/m2*x3 - d2/m2*x5; | ||
der(x6) = c3/m3*x2 - (c3+c4)/m3*x3 - d3/m3*x6; | ||
end example8; | ||
end qssTests; | ||
"); getErrorString(); | ||
|
||
simulate(qssTests.example8, stopTime=20, method="qss"); getErrorString(); | ||
val(x1, {0.0, 20.0}); getErrorString(); | ||
val(x2, {0.0, 20.0}); getErrorString(); | ||
val(x3, {0.0, 20.0}); getErrorString(); | ||
val(x4, {0.0, 20.0}); getErrorString(); | ||
val(x5, {0.0, 20.0}); getErrorString(); | ||
val(x6, {0.0, 20.0}); getErrorString(); | ||
|
||
// Result: | ||
// true | ||
// "" | ||
// record SimulationResult | ||
// resultFile = "qssTests.example8_res.mat", | ||
// simulationOptions = "startTime = 0.0, stopTime = 20.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'qss', fileNamePrefix = 'qssTests.example8', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''", | ||
// messages = "stdout | warning | This QSS method is under development and should not be used yet. | ||
// " | ||
// end SimulationResult; | ||
// "" | ||
// {0.1,0.001077030775611781} | ||
// "" | ||
// {0.0,-0.001775288784157483} | ||
// "" | ||
// {0.0,0.003171398458016391} | ||
// "" | ||
// {0.0,0.0007} | ||
// "" | ||
// {0.0,4.61667547513319e-05} | ||
// "" | ||
// {0.0,0.0065} | ||
// "" | ||
// endResult |
Oops, something went wrong.