Opened 12 years ago

Closed 12 years ago

#1926 closed defect (fixed)

hybrid initialization

Reported by: Willi Braun Owned by: Lennart Ochel
Priority: high Milestone: 1.9.0
Component: Backend Version:
Keywords: Cc: Jens Frenkel

Description (last modified by Willi Braun)

try to initialize following two models:

loadString("
model A1
  parameter Real x(fixed=false) = if y>3 then sin(y) else 0;
  parameter Real y(start=5);
initial equation
  x = 0;
end A1;

model A2
  Real x(fixed=false) = if y>3 then sin(y) else 0;
  Real y(start=5);
initial equation
  x = 0;
equation
  when time > 0.5 then
    y = 0;
  end when;
end A2;
");

simulate(A1);
val(x,0);
val(y,0);
val(x,1);
val(y,1);

simulate(A2);
val(x,0);
val(y,0);
val(x,1);
val(y,1);

run it results in :

true
record SimulationResult
    resultFile = "A1_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'A1', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",    messages = "stdout        | warning | Error in initialization. Storing results and exiting.
|             | |       | Use -lv LOG_INIT for more information.
",
    timeFrontend = 0.012162227000000001,
    timeBackend = 0.004835605000000001,
    timeSimCode = 0.0027522370000000003,
    timeTemplates = 0.0018435300000000001,
    timeCompile = 0.196330831,
    timeSimulation = 0.009741879,
    timeTotal = 0.22773643100000002
end SimulationResult;
-0.9589242746631385
5.0
-0.9589242746631385
5.0
record SimulationResult
    resultFile = "A2_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'A2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "",
    timeFrontend = 0.009759409,
    timeBackend = 0.004888894,
    timeSimCode = 0.002635039,
    timeTemplates = 0.001217053,
    timeCompile = 0.205227073,
    timeSimulation = 0.00712046,
    timeTotal = 0.230887109
end SimulationResult;
-0.9589242746631385
5.0
0.0
0.0

I would expect at least one of this solutions:
x = 0;
y = {sin(i*Pi) for i in 1:n};

Change History (2)

comment:1 by Willi Braun, 12 years ago

Description: modified (diff)

in reply to:  description comment:2 by Lennart Ochel, 12 years ago

Resolution: fixed
Status: newclosed

I am not sure what could be the goal of A1. The initial system is over-determined:

Variables (1)
=========
1: x

Equations (2, 2)
=========
1 : x = 0.0
2 : x = if y>3 then sin(y) else 0

A2 is running using +d=solveinitialsystem. Same results as Dymola.

Replying to wbraun:

try to initialize following two models:

loadString("
model A1
  parameter Real x(fixed=false) = if y>3 then sin(y) else 0;
  parameter Real y(start=5);
initial equation
  x = 0;
end A1;

model A2
  Real x(fixed=false) = if y>3 then sin(y) else 0;
  Real y(start=5);
initial equation
  x = 0;
equation
  when time > 0.5 then
    y = 0;
  end when;
end A2;
");

simulate(A1);
val(x,0);
val(y,0);
val(x,1);
val(y,1);

simulate(A2);
val(x,0);
val(y,0);
val(x,1);
val(y,1);

run it results in :

true
record SimulationResult
    resultFile = "A1_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'A1', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",    messages = "stdout        | warning | Error in initialization. Storing results and exiting.
|             | |       | Use -lv LOG_INIT for more information.
",
    timeFrontend = 0.012162227000000001,
    timeBackend = 0.004835605000000001,
    timeSimCode = 0.0027522370000000003,
    timeTemplates = 0.0018435300000000001,
    timeCompile = 0.196330831,
    timeSimulation = 0.009741879,
    timeTotal = 0.22773643100000002
end SimulationResult;
-0.9589242746631385
5.0
-0.9589242746631385
5.0
record SimulationResult
    resultFile = "A2_res.mat",
    simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 500, tolerance = 0.000001, method = 'dassl', fileNamePrefix = 'A2', storeInTemp = false, noClean = false, options = '', outputFormat = 'mat', variableFilter = '.*', measureTime = false, cflags = '', simflags = ''",
    messages = "",
    timeFrontend = 0.009759409,
    timeBackend = 0.004888894,
    timeSimCode = 0.002635039,
    timeTemplates = 0.001217053,
    timeCompile = 0.205227073,
    timeSimulation = 0.00712046,
    timeTotal = 0.230887109
end SimulationResult;
-0.9589242746631385
5.0
0.0
0.0

I would expect at least one of this solutions:
x = 0;
y = {sin(i*Pi) for i in 1:n};

Note: See TracTickets for help on using tickets.