Skip to content

Commit

Permalink
-Implemented rudimentary support for tables. (Modelica.Blocks.Sources…
Browse files Browse the repository at this point in the history
….CombiTimeTable now works for parameter data or textual data on file, see CombiTimeTableTest.mos.) Implementation in C++ in tables.cpp. Modelica standard library must be changed to use different external function names (e.g. omcTableTimeIni instead of dymTableTimeIni2)

- Redirected stdout and stderr to compilelog.txt when compiling functions in Ceval (System.compileCFile).
-Added support for parameter and variable strings in init file.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2732 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Feb 27, 2007
1 parent a79ff6b commit 36cec87
Show file tree
Hide file tree
Showing 7 changed files with 661 additions and 59 deletions.
38 changes: 38 additions & 0 deletions Compiler/Codegen.mo
Expand Up @@ -3647,6 +3647,23 @@ algorithm
"#-- Codegen.generate_expression: size(X) not implemented");
then
fail();
/* Special case for empty arrays, create null pointer*/
case (e as Exp.ARRAY(ty = t,scalar = a,array = {}),tnr,context)
local Exp.Exp e;
equation
array_type_str = expTypeStr(t, true);
short_type_str = expShortTypeStr(t);
(tdecl,tvar,tnr1) = generateTempDecl(array_type_str, tnr);
scalar = Util.if_(a, "scalar_", "");
scalar_ref = Util.if_(a, "", "&");
scalar_delimit = stringAppend(", ", scalar_ref);
stmt = Util.stringAppendList(
{"array_alloc_",scalar,array_type_str,"(&",tvar,", 0, ",scalar_ref,",0);"});
cfn_1 = cAddVariables(cEmptyFunction, {tdecl});
cfn = cAddStatements(cfn_1, {stmt});
then
(cfn,tvar,tnr1);
/* array */
case (e as Exp.ARRAY(ty = t,scalar = a,array = elist),tnr,context)
local Exp.Exp e;
equation
Expand All @@ -3672,6 +3689,7 @@ algorithm
(cfn,var,tnr_1) = generateMatrix(t, maxn, ell, tnr, context);
then
(cfn,var,tnr_1);

case (Exp.RANGE(ty = t,exp = e1,expOption = NONE,range = e2),tnr,context)
equation
(cfn1,var1,tnr1) = generateExpression(e1, tnr, context);
Expand Down Expand Up @@ -5098,6 +5116,26 @@ algorithm
Exp.Type typ;
list<list<tuple<Exp.Exp, Boolean>>> exps;
Context context;
/* Special case for empty array { {} } */
case (typ,maxn,{{}},tnr,context) equation
array_type_str = expTypeStr(typ, true);
(tdecl,tvar,tnr1) = generateTempDecl(array_type_str, tnr);
/* Create dimensional array Real[0,1]; */
stmt = Util.stringAppendList(
{"alloc_",array_type_str,"(&",tvar,",2,0,1);"});
cfn_1 = cAddVariables(cEmptyFunction, {tdecl});
cfn_2 = cAddStatements(cfn_1, {stmt});
then (cfn_2,tvar,tnr1);
/* Special case from emtpy array: {} */
case (typ,maxn,{},tnr,context) equation
array_type_str = expTypeStr(typ, true);
(tdecl,tvar,tnr1) = generateTempDecl(array_type_str, tnr);
stmt = Util.stringAppendList(
{"alloc_",array_type_str,"(&",tvar,",2,0,1);"});
cfn_1 = cAddVariables(cEmptyFunction, {tdecl});
cfn_2 = cAddStatements(cfn_1, {stmt});
then (cfn_2,tvar,tnr1);

case (typ,maxn,exps,tnr,context)
equation
(cfn1,vars1,tnr1) = generateMatrixExpressions(typ, exps, maxn, tnr, context);
Expand Down
11 changes: 6 additions & 5 deletions Compiler/DAELow.mo
Expand Up @@ -601,18 +601,19 @@ algorithm
NONE,NONE,{},NONE,-1,Exp.CREF_IDENT("$dummy",{}),{},
SOME(
DAE.VAR_ATTR_REAL(NONE,NONE,NONE,(NONE,NONE),NONE,SOME(true),NONE,NONE)),NONE,DAE.NON_CONNECTOR()), vars);
then
/*(vars_1,(EQUATION(
Exp.CALL(Absyn.IDENT("der"),
{Exp.CREF(Exp.CREF_IDENT("$dummy",{}),Exp.REAL())},false,true,Exp.REAL()),Exp.RCONST(0.0)) :: eqns));*/
then
/* Add equation der(dummy) = sin(time*6628.318530717). This so the solver has something to solve
if the model does not contain states. To prevent the solver from taking larger and larger steps
(which would happen if der(dymmy) = 0) when using automatic, we have a osciallating derivative.
*/
(vars_1,(EQUATION(
Exp.CALL(Absyn.IDENT("der"),
{Exp.CREF(Exp.CREF_IDENT("$dummy",{}),Exp.REAL())},false,true,Exp.REAL()),
Exp.CALL(Absyn.IDENT("sin"),{Exp.BINARY(
Exp.CREF(Exp.CREF_IDENT("time",{}),Exp.REAL()),
Exp.MUL(Exp.REAL()),
Exp.RCONST(628.318530717))},false,true,Exp.REAL())) :: eqns));

end matchcontinue;
end addDummyState;

Expand Down

0 comments on commit 36cec87

Please sign in to comment.