Skip to content

Commit

Permalink
Optimized Equations in DAELOW. Fixed some stuff in Tornado. Added dym…
Browse files Browse the repository at this point in the history
…TableInit as builtinFunction.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1432 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Jan 28, 2005
1 parent a027036 commit bdac17d
Show file tree
Hide file tree
Showing 10 changed files with 681 additions and 480 deletions.
22 changes: 20 additions & 2 deletions modeq/builtin.rml
Expand Up @@ -633,6 +633,18 @@ val array2real= (Types.T_FUNCTION([("x",(Types.T_ARRAY(Types.DIM(SOME(1)),(Types
val array8dimbool2array1dimint = (Types.T_FUNCTION([("x",(Types.T_ARRAY(Types.DIM(SOME(8)),(Types.T_BOOL([]),NONE)),NONE))], (Types.T_ARRAY(Types.DIM(SOME(1)),(Types.T_INTEGER([]),NONE)),NONE)),NONE)
val array9dimbool2array1dimint = (Types.T_FUNCTION([("x",(Types.T_ARRAY(Types.DIM(SOME(9)),(Types.T_BOOL([]),NONE)),NONE))], (Types.T_ARRAY(Types.DIM(SOME(1)),(Types.T_INTEGER([]),NONE)),NONE)),NONE)

val dymTableTimeIni_type = (Types.T_FUNCTION([("time",(Types.T_REAL([]),NONE)),
("ipoType",(Types.T_INTEGER([]),NONE)),
("tableName",(Types.T_STRING([]),NONE)),
("fileName",(Types.T_STRING([]),NONE)),
("tableIn",(Types.T_ARRAY(Types.DIM(SOME(2)),(Types.T_REAL([]),NONE)),NONE)),
("colWiseIn",(Types.T_INTEGER([]),NONE))
],
(Types.T_REAL([]),NONE) (* return type *)
),NONE)



(*
val array2array= (Types.T_FUNCTION([("x",(Types.T_ARRAY)],
(Types.T_ARRAY),NONE)
Expand Down Expand Up @@ -719,7 +731,7 @@ relation initial_env =
Env.extend_frame_t(env, "sin", real2real) => env &
Env.extend_frame_t(env, "cos", real2real) => env &
Env.extend_frame_t(env, "tan", real2real) => env &

Env.extend_frame_t(env, "exp", real2real) => env &
(* PR. Add the built in array functions here.*)
(* Also do it for real, string and bool*)
Env.extend_frame_t(env, "ndims", array1dimint2int) => env &
Expand Down Expand Up @@ -1221,7 +1233,13 @@ relation initial_env =
Env.extend_frame_t(env, "skew", array1dimreal2array3dimreal) => env &

Env.extend_frame_t(env, "sqrt", int2real) => env &
Env.extend_frame_t(env, "sqrt", real2real) => env
Env.extend_frame_t(env, "sqrt", real2real) => env &


(* Dymola specific external functions. Needed to generaete tornado code *)
Env.extend_frame_t(env, "dymTableTimeIni",dymTableTimeIni_type) => env


(*Debug. Print.print_buf "\n Just AFTER the built in array functions part." *)
----------------------------------------------
initial_env () => env
Expand Down
2 changes: 1 addition & 1 deletion modeq/codegen.rml
Expand Up @@ -3370,7 +3370,7 @@ relation generate_extcall_copydecls_f77 : (DAE.Element list, int) => (CFunction,
is_array var => true &
var_name_external_cref cref => cref' &
list_reverse dims => dims' &
let extvar = DAE.VAR(cref', vk, vd, ty, value, dims',NONE,DAE.NON_FLOW,Absyn.IDENT("$extvar$")) &
let extvar = DAE.VAR(cref', vk, vd, ty, value, dims',NONE,DAE.NON_FLOW,[]) &
generate_var_decl (extvar, tnr) => (fn, tnr') &
generate_extcall_copydecls_f77 (rest, tnr') => (restfn, tnr''') &
c_merge_fn (fn, restfn) => resfn
Expand Down
29 changes: 16 additions & 13 deletions modeq/dae.rml
Expand Up @@ -68,7 +68,7 @@ module DAE:
StartValue * (* value of start attribute *)
Flow * (* Flow of connector variable. Needed for
unconnected flow variables *)
Absyn.Path (* The class the variable is instantiated from *)
Absyn.Path list (* The class the variable is instantiated from *)

| DEFINE of Exp.ComponentRef * Exp.Exp
| INITIALDEFINE of Exp.ComponentRef * Exp.Exp
Expand Down Expand Up @@ -722,13 +722,14 @@ relation dump_var : Element => () =
rule dump_kind kind & dump_direction dir & dump_type typ &
Exp.print_component_ref id &
dump_start_value start &
Absyn.path_string(class) => classstr &
Print.print_buf " \"" &
Util.list_map(classlst,Absyn.path_string) => classstrlst &
Util.string_delimit_list(classstrlst, ", ") => classstr &
Print.print_buf " \"{" &
Print.print_buf classstr &
Print.print_buf "\" " &
Print.print_buf "}\" " &
Print.print_buf ";\n"
--------------------------------------
dump_var VAR(id, kind, dir, typ, NONE,_,start,flow,class)
dump_var VAR(id, kind, dir, typ, NONE,_,start,flow,classlst)

rule dump_kind kind & dump_direction dir & dump_type typ &
Exp.print_component_ref id &
Expand All @@ -749,22 +750,24 @@ relation dump_var_str : Element => string =
dump_type_str typ => s3 &
Exp.print_component_ref_str id => s4 &
dump_start_value_str start => s5 &
Absyn.path_string(class) => classstr &
Util.string_append_list([s1,s2,s3,s4,s5," \"",classstr,"\";\n"]) => str
Util.list_map(classlst,Absyn.path_string) => classstrlst &
Util.string_delimit_list(classstrlst, ", ") => classstr &
Util.string_append_list([s1,s2,s3,s4,s5," \"{",classstr,"}\";\n"]) => str
--------------------------------------
dump_var_str VAR(id, kind, dir, typ, NONE,_,start,flow,class) => str
dump_var_str VAR(id, kind, dir, typ, NONE,_,start,flow,classlst) => str

rule dump_kind_str kind => s1 &
dump_direction_str dir => s2 &
dump_type_str typ => s3 &
Exp.print_component_ref_str id => s4 &
Exp.print_exp_str e => s5 &
dump_start_value_str start => s6 &
Absyn.path_string(class) => classstr &
Util.string_append_list([s1, s2, s3, s4, " = ", s5, s6," \"",classstr,"\" ;\n"] )
Util.list_map(classlst,Absyn.path_string) => classstrlst &
Util.string_delimit_list(classstrlst, ", ") => classstr &
Util.string_append_list([s1, s2, s3, s4, " = ", s5, s6," \"{",classstr,"}\" ;\n"] )
=> str
--------------------------------------
dump_var_str VAR(id, kind, dir, typ, SOME(e),_,start,flow,class) => str
dump_var_str VAR(id, kind, dir, typ, SOME(e),_,start,flow,classlst) => str

axiom dump_var_str (_) => ""

Expand Down Expand Up @@ -1263,8 +1266,8 @@ relation set_component_type: (Element list,Absyn.Path) => Element list =

rule set_component_type(xs,newtype) => xs'
-------------------------------------
set_component_type(VAR(cr,kind,dir,tp,bind,dim,start,flow,_)::xs,newtype)
=> VAR(cr,kind,dir,tp,bind,dim,start,flow,newtype)::xs'
set_component_type(VAR(cr,kind,dir,tp,bind,dim,start,flow,lst)::xs,newtype)
=> VAR(cr,kind,dir,tp,bind,dim,start,flow,newtype::lst)::xs'

rule set_component_type(xs,newtype) => xs'
-------------------------------------
Expand Down

0 comments on commit bdac17d

Please sign in to comment.