Skip to content

Commit

Permalink
- Fix MeasureTime.mos
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13994 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Nov 20, 2012
1 parent fa441d1 commit 9b48df5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
51 changes: 14 additions & 37 deletions Compiler/Template/CodegenC.tpl
Expand Up @@ -301,34 +301,11 @@ template functionSimProfDef(SimEqSystem eq, Integer value)
"Generates function in simulation file."
::=
match eq
case SES_ALGORITHM(__) then
<<
>>
case SES_WHEN(__) then
<<
>>
case SES_RESIDUAL(__) then
<<
>>
case SES_ARRAY_CALL_ASSIGN(__) then
<<
>>
case SES_SIMPLE_ASSIGN(__) then
<<
>>
case SES_MIXED(__) then
<<
#define SIM_PROF_EQ_<%index%> <%value%><%\n%>
>>
case SES_LINEAR(__) then
<<
>>
case SES_MIXED(__)
case SES_LINEAR(__)
case SES_NONLINEAR(__) then
<<
#define SIM_PROF_EQ_<%index%> <%value%><%\n%>
>>
else
<<
>>
end match
end functionSimProfDef;
Expand Down Expand Up @@ -360,16 +337,16 @@ template functionInitializeDataStruc2(ModelInfo modelInfo, list<SimEqSystem> all
<%eqnInfo%>
memcpy(data->modelData.equationInfo, &equationInfo, data->modelData.nEquations*sizeof(EQUATION_INFO));
data->modelData.nProfileBlocks = 0 <% allEquations |> eq => match eq
case SES_MIXED(__)
case SES_LINEAR(__)
case SES_NONLINEAR(__) then '+1'
data->modelData.nProfileBlocks = 0 <% listAppend(listAppend(initialEquations,parameterEquations),allEquations) |> eq => match eq
case SES_MIXED(__) then "+1"
case SES_LINEAR(__) then "+1"
case SES_NONLINEAR(__) then "+1"
%>;
data->modelData.equationInfo_reverse_prof_index = (int*) malloc(data->modelData.nProfileBlocks*sizeof(int));
<%System.tmpTickReset(0)%>
<% allEquations |> eq hasindex i0 => match eq
case SES_MIXED(__)
case SES_LINEAR(__)
<% listAppend(listAppend(initialEquations,parameterEquations),allEquations) |> eq hasindex i0 => match eq
case SES_MIXED(__) then 'data->modelData.equationInfo_reverse_prof_index[<%System.tmpTick()%>] = <%i0%>;<%\n%>'
case SES_LINEAR(__) then 'data->modelData.equationInfo_reverse_prof_index[<%System.tmpTick()%>] = <%i0%>;<%\n%>'
case SES_NONLINEAR(__) then 'data->modelData.equationInfo_reverse_prof_index[<%System.tmpTick()%>] = <%i0%>;<%\n%>'
; empty
%>
Expand Down Expand Up @@ -8393,24 +8370,24 @@ template equationInfo1(SimEqSystem eq, Text &preBuf, Text &eqnsDefines)
::=
match eq
case SES_RESIDUAL(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_RESIDUAL <%index%>",0,NULL}'
case SES_SIMPLE_ASSIGN(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
let var = '<%cref(cref)%>__varInfo'
let &preBuf += 'const VAR_INFO** equationInfo_cref<%index%> = (const VAR_INFO**)calloc(1,sizeof(VAR_INFO*));<%\n%>'
let &preBuf += 'equationInfo_cref<%index%>[0] = &<%var%>;<%\n%>'
'{<%index%>,"SES_SIMPLE_ASSIGN <%index%>",1,equationInfo_cref<%index%>}'
case SES_ARRAY_CALL_ASSIGN(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
//let var = '<%cref(componentRef)%>__varInfo'
//let &preBuf += 'const struct VAR_INFO *equationInfo_cref<%index%> = &<%var%>;'
'{<%index%>,"SES_ARRAY_CALL_ASSIGN <%index%>",0,NULL}'
case SES_ALGORITHM(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_ALGORITHM <%index%>", 0, NULL}'
case SES_WHEN(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
// let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
'{<%index%>,"SES_WHEN <%index%>", 0, NULL}'
case SES_LINEAR(__) then
let &eqnsDefines += '<%functionSimProfDef(eq,System.tmpTick())%>'
Expand Down
8 changes: 5 additions & 3 deletions SimulationRuntime/c/simulation/solver/nonlinearSolverHybrd.c
Expand Up @@ -221,6 +221,8 @@ int solveHybrd(DATA *data, int sysNumber) {

NONLINEAR_SYSTEM_DATA* systemData = &(data->simulationInfo.nonlinearSystemData[sysNumber]);
DATA_HYBRD* solverData = (DATA_HYBRD*)(((SOLVER_DATA*)systemData->solverData)->hybrdData);
/* We are given the number of the non-linear system. We want to look it up among all equations. */
int eqSystemNumber = data->modelData.equationInfo_reverse_prof_index[systemData->simProfEqNr];

int i, iflag=0;
double xerror, xerror_scaled;
Expand All @@ -239,7 +241,7 @@ int solveHybrd(DATA *data, int sysNumber) {
if(DEBUG_STREAM(LOG_NONLIN_SYS))
{
INFO2(LOG_NONLIN_SYS, "Start solving Non-Linear System %s at time %e",
data->modelData.equationInfo[systemData->simProfEqNr].name,
data->modelData.equationInfo[eqSystemNumber].name,
data->localData[0]->timeValue);
INDENT(LOG_NONLIN_SYS);

Expand Down Expand Up @@ -332,7 +334,7 @@ int solveHybrd(DATA *data, int sysNumber) {
}
/* check for proper inputs */
if (solverData->info == 0) {
printErrorEqSyst(IMPROPER_INPUT, data->modelData.equationInfo[systemData->simProfEqNr],
printErrorEqSyst(IMPROPER_INPUT, data->modelData.equationInfo[eqSystemNumber],
data->localData[0]->timeValue);
data->simulationInfo.found_solution = -1;
}
Expand Down Expand Up @@ -607,7 +609,7 @@ int solveHybrd(DATA *data, int sysNumber) {

/* while the initialization it's ok to every time a solution */
if (!data->simulationInfo.initial){
printErrorEqSyst(ERROR_AT_TIME, data->modelData.equationInfo[systemData->simProfEqNr], data->localData[0]->timeValue);
printErrorEqSyst(ERROR_AT_TIME, data->modelData.equationInfo[eqSystemNumber], data->localData[0]->timeValue);
}
if (DEBUG_STREAM(LOG_NONLIN_SYS)) {
RELEASE(LOG_NONLIN_SYS);
Expand Down

0 comments on commit 9b48df5

Please sign in to comment.