Skip to content

Commit

Permalink
Added numeric tests for all test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
crupp2 authored and lochel committed Mar 30, 2016
1 parent 202229e commit be78147
Show file tree
Hide file tree
Showing 19 changed files with 1,138 additions and 92 deletions.
1 change: 0 additions & 1 deletion openmodelica/linearization/Makefile
Expand Up @@ -14,7 +14,6 @@ smallValues.mos \
simLotkaVolterra.mos \
simTwoTank.mos \
simNonlinear.mos \
simNonlinear_numeric.mos \
simextfunction.mos \
test_01.mos \
test_02.mos \
Expand Down
64 changes: 62 additions & 2 deletions openmodelica/linearization/linmodel.mos
Expand Up @@ -13,8 +13,19 @@ loadFile("linear_linearmodel.mo");
list(linear_linearmodel);
simulate(linear_linearmodel);
getErrorString();
readFile("linear_linearmodel.log"); // Check that output log is emtpy
echo(false); // turns of output
readFile("linear_linearmodel.log"); // Check that output log is empty

//
// Case for numeric linearization of VanDerPol model
//
//linearize with numeric linearization and data recovery
simulate(linearmodel, simflags="-l=0 -l_datarec");
getErrorString();
loadFile("linear_linearmodel.mo");
list(linear_linearmodel);
simulate(linear_linearmodel);
getErrorString();
readFile("linear_linearmodel.log"); // Check that output log is empty

// Result:
// true
Expand Down Expand Up @@ -60,4 +71,53 @@ echo(false); // turns of output
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// record SimulationResult
// resultFile = "linearmodel_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linearmodel', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=0 -l_datarec'",
// messages = "stdout | info | Linearization will performed at point of time: 0.000000
// stdout | info | Linear model is created!
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// true
// "model linear_linearmodel
// parameter Integer n = 4;
// // states
// parameter Integer k = 0;
// // top-level inputs
// parameter Integer l = 0;
// // top-level outputs
// parameter Integer nz = 0;
// // data recovery variables
// parameter Real x0[4] = {1, -2, 3, -5};
// parameter Real u0[0] = {i for i in 1:0};
// parameter Real z0[0] = {i for i in 1:0};
// parameter Real A[4, 4] = [-2.999999997398604, 1.999999993823069, 0, 0; -6.999999996151411, 0, -5.000000006771011, 0.9999999880261984; -0.9999999880261984, 0, -1.000000001354202, 3.999999996531473; 0, 1.000000014682206, -1.000000001354202, 4.999999984557672];
// parameter Real B[4, 0] = zeros(4, 0);
// parameter Real C[0, 4] = zeros(0, 4);
// parameter Real D[0, 0] = zeros(0, 0);
// parameter Real Cz[0, 4] = zeros(0, 4);
// parameter Real Dz[0, 0] = zeros(0, 0);
// Real x[4](start = x0);
// input Real u[0];
// output Real y[0];
// output Real z[0];
// Real x_Px1 = x[1];
// Real x_Px2 = x[2];
// Real x_Px3 = x[3];
// Real x_Px4 = x[4];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linear_linearmodel;"
// record SimulationResult
// resultFile = "linear_linearmodel_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linear_linearmodel', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// endResult
61 changes: 60 additions & 1 deletion openmodelica/linearization/simLotkaVolterra.mos
Expand Up @@ -13,7 +13,19 @@ loadFile("linear_LotkaVolterra.mo");
list(linear_LotkaVolterra);
simulate(linear_LotkaVolterra);
getErrorString();
readFile("linear_LotkaVolterra.log"); // Check that output log is emtpy
readFile("linear_LotkaVolterra.log"); // Check that output log is empty

//
// Case for numeric linearization of LotkaVolterra model
//
//linearize with numeric linearization and data recovery
simulate(LotkaVolterra, simflags="-l=0 -l_datarec");
getErrorString();
loadFile("linear_LotkaVolterra.mo");
list(linear_LotkaVolterra);
simulate(linear_LotkaVolterra);
getErrorString();
readFile("linear_LotkaVolterra.log"); // Check that output log is empty

// Result:
// true
Expand Down Expand Up @@ -57,4 +69,51 @@ readFile("linear_LotkaVolterra.log"); // Check that output log is emtpy
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// record SimulationResult
// resultFile = "LotkaVolterra_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'LotkaVolterra', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=0 -l_datarec'",
// messages = "stdout | info | Linearization will performed at point of time: 0.000000
// stdout | info | Linear model is created!
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// true
// "model linear_LotkaVolterra
// parameter Integer n = 2;
// // states
// parameter Integer k = 0;
// // top-level inputs
// parameter Integer l = 0;
// // top-level outputs
// parameter Integer nz = 0;
// // data recovery variables
// parameter Real x0[2] = {5, 3};
// parameter Real u0[0] = {i for i in 1:0};
// parameter Real z0[0] = {i for i in 1:0};
// parameter Real A[2, 2] = [-3.999999996531473, -15.00000002031303; 3.000000008505274, 3.000000004062607];
// parameter Real B[2, 0] = zeros(2, 0);
// parameter Real C[0, 2] = zeros(0, 2);
// parameter Real D[0, 0] = zeros(0, 0);
// parameter Real Cz[0, 2] = zeros(0, 2);
// parameter Real Dz[0, 0] = zeros(0, 0);
// Real x[2](start = x0);
// input Real u[0];
// output Real y[0];
// output Real z[0];
// Real x_Px = x[1];
// Real x_Py = x[2];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linear_LotkaVolterra;"
// record SimulationResult
// resultFile = "linear_LotkaVolterra_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linear_LotkaVolterra', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// endResult
71 changes: 70 additions & 1 deletion openmodelica/linearization/simNonlinear.mos
Expand Up @@ -13,7 +13,19 @@ loadFile("linear_p.nonlinsys.mo");
list(linear_p_nonlinsys);
simulate(linear_p_nonlinsys);
getErrorString();
readFile("linear_p_nonlinsys.log"); // Check that output log is emtpy
readFile("linear_p_nonlinsys.log"); // Check that output log is empty

//
// Case for numeric linearization of nonlinsys model
//
//linearize with numeric linearization and data recovery
simulate(p.nonlinsys, simflags="-l=0 -l_datarec");
getErrorString();
loadFile("linear_p.nonlinsys.mo");
list(linear_p_nonlinsys);
simulate(linear_p_nonlinsys);
getErrorString();
readFile("linear_p_nonlinsys.log"); // Check that output log is empty

// Result:
// true
Expand Down Expand Up @@ -61,4 +73,61 @@ readFile("linear_p_nonlinsys.log"); // Check that output log is emtpy
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// record SimulationResult
// resultFile = "p.nonlinsys_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'p.nonlinsys', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=0 -l_datarec'",
// messages = "stdout | info | Linearization will performed at point of time: 0.000000
// stdout | info | Linear model is created!
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// true
// "model linear_p_nonlinsys
// parameter Integer n = 3;
// // states
// parameter Integer k = 1;
// // top-level inputs
// parameter Integer l = 2;
// // top-level outputs
// parameter Integer nz = 6;
// // data recovery variables
// parameter Real x0[3] = {1, 1, 2};
// parameter Real u0[1] = {0};
// parameter Real z0[6] = {0, -6, -6, 0, 0, 0};
// parameter Real A[3, 3] = [0, 0, 0; 0, 5.999999994797209, -2.000000002708405; 0, 3.999999998752807, -6.000000017010549];
// parameter Real B[3, 1] = [0; 0; 0];
// parameter Real C[2, 3] = [0, 0, 0; 0, 0, 0];
// parameter Real D[2, 1] = [0; 0];
// parameter Real Cz[6, 3] = [0, 0, 0; 0, 9.999999993550016, -8.000000019718954; 0, 9.999999993550016, -8.000000019718954; 0, 0, 0; 0, 0, 0; 0, 0, 0];
// parameter Real Dz[6, 1] = [0; 0; 0; 1; 0; 0];
// Real x[3](start = x0);
// input Real u[1](start = u0);
// output Real y[2];
// output Real z[6];
// Real x_Pb1Px = x[1];
// Real x_Pc1Px1 = x[2];
// Real x_Pc1Px2 = x[3];
// Real u_Pu1 = u[1];
// Real y_Py1 = y[1];
// Real y_Py2 = y[2];
// Real z_Pa1Py = z[1];
// Real z_Pc1Py = z[2];
// Real z_Pc1Py1 = z[3];
// Real z_Pu1 = z[4];
// Real z_Py1 = z[5];
// Real z_Py2 = z[6];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linear_p_nonlinsys;"
// record SimulationResult
// resultFile = "linear_p_nonlinsys_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linear_p_nonlinsys', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// endResult
78 changes: 0 additions & 78 deletions openmodelica/linearization/simNonlinear_numeric.mos

This file was deleted.

66 changes: 65 additions & 1 deletion openmodelica/linearization/simTwoTank.mos
Expand Up @@ -13,7 +13,19 @@ loadFile("linear_twoflattankmodel.mo");
list(linear_twoflattankmodel);
simulate(linear_twoflattankmodel,method="dassl");
getErrorString();
readFile("linear_twoflattankmodel.log"); // Check that output log is emtpy
readFile("linear_twoflattankmodel.log"); // Check that output log is empty

//
// Case for numeric linearization of twoflattankmodel model
//
//linearize with numeric linearization and data recovery
simulate(twoflattankmodel, simflags="-l=0 -l_datarec");
getErrorString();
loadFile("linear_twoflattankmodel.mo");
list(linear_twoflattankmodel);
simulate(linear_twoflattankmodel);
getErrorString();
readFile("linear_twoflattankmodel.log"); // Check that output log is empty

// Result:
// true
Expand Down Expand Up @@ -59,4 +71,56 @@ readFile("linear_twoflattankmodel.log"); // Check that output log is emtpy
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// record SimulationResult
// resultFile = "twoflattankmodel_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'twoflattankmodel', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-l=0 -l_datarec'",
// messages = "stdout | info | Linearization will performed at point of time: 0.000000
// stdout | info | Linear model is created!
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// true
// "model linear_twoflattankmodel
// parameter Integer n = 2;
// // states
// parameter Integer k = 1;
// // top-level inputs
// parameter Integer l = 1;
// // top-level outputs
// parameter Integer nz = 3;
// // data recovery variables
// parameter Real x0[2] = {2, 1};
// parameter Real u0[1] = {0};
// parameter Real z0[3] = {0, 2, 1};
// parameter Real A[2, 2] = [-0.4999999873490973, 0.5000000165041055; 1.999999949396389, -3.000000034050615];
// parameter Real B[2, 1] = [0.500000000677101; 0];
// parameter Real C[1, 2] = [0, 0.4999999840170964];
// parameter Real D[1, 1] = [0];
// parameter Real Cz[3, 2] = [0, 0; 0.9999999746981947, -1.000000033008211; 0, 0.4999999840170964];
// parameter Real Dz[3, 1] = [1; 0; 0];
// Real x[2](start = x0);
// input Real u[1](start = u0);
// output Real y[1];
// output Real z[3];
// Real x_Ph1 = x[1];
// Real x_Ph2 = x[2];
// Real u_PF = u[1];
// Real y_PF2 = y[1];
// Real z_PF = z[1];
// Real z_PF1 = z[2];
// Real z_PF2 = z[3];
// equation
// der(x) = A * x + B * u;
// y = C * x + D * u;
// z = Cz * x + Dz * u;
// end linear_twoflattankmodel;"
// record SimulationResult
// resultFile = "linear_twoflattankmodel_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 1e-06, method = 'dassl', fileNamePrefix = 'linear_twoflattankmodel', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = ''",
// messages = ""
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
// "
// ""
// endResult

0 comments on commit be78147

Please sign in to comment.