Changeset ef124e4 in OpenModelica
- Timestamp:
- 2024-02-06T17:11:03+01:00 (3 months ago)
- Branches:
- maintenance/v1.23, master
- Children:
- f5281322
- Parents:
- 2ab36e87
- git-author:
- kabdelhak <38032125+kabdelhak@…> (02/06/24 17:11:03)
- git-committer:
- GitHub <noreply@…> (02/06/24 17:11:03)
- Location:
- OMCompiler/Compiler/NBackEnd
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/NBackEnd/Classes/NBEquation.mo
rcfdfeb87 ref124e4 1229 1229 end setRHS; 1230 1230 1231 function fromLHSandRHS1232 input Expression lhs;1233 input Expression rhs;1234 input Pointer<Integer> idx;1235 input String context;1236 input EquationAttributes attr = EquationAttributes.default(EquationKind.UNKNOWN, false);1237 input DAE.ElementSource src = DAE.emptyElementSource;1238 output Pointer<Equation> eqn_ptr;1239 protected1240 Type ty;1241 Equation eqn;1242 Option<Integer> opt_rec_size;1243 Integer rec_size;1244 algorithm1245 ty := Expression.typeOf(lhs);1246 opt_rec_size := Type.complexSize(ty);1247 eqn := match (ty, opt_rec_size)1248 case (Type.ARRAY(), _) then ARRAY_EQUATION(ty, lhs, rhs, src, attr, opt_rec_size);1249 case (Type.COMPLEX(), SOME(rec_size)) then RECORD_EQUATION(ty, lhs, rhs, src, attr, rec_size);1250 else SCALAR_EQUATION(ty, lhs, rhs, src, attr);1251 end match;1252 eqn_ptr := Pointer.create(eqn);1253 Equation.createName(eqn_ptr, idx, context);1254 end fromLHSandRHS;1255 1256 1231 function updateLHSandRHS 1257 1232 input output Equation eqn; … … 1768 1743 if Iterator.isEmpty(iter) then 1769 1744 lhs := Expression.fromCref(var.name); 1770 eqn := Equation. fromLHSandRHS(lhs, rhs, idx, context, eqnAttr);1745 eqn := Equation.makeAssignment(lhs, rhs, idx, context, Iterator.EMPTY(), eqnAttr); 1771 1746 else 1772 1747 rhs := Expression.map(rhs, Expression.repairOperator); … … 1774 1749 subs := list(Subscript.fromTypedExp(Expression.fromCref(cref)) for cref in sub_crefs); 1775 1750 lhs := Expression.fromCref(ComponentRef.mergeSubscripts(subs, var.name, true, true)); 1776 eqn := Equation.fromLHSandRHS(lhs, rhs, idx, context, eqnAttr); 1777 eqn := Pointer.create(Equation.FOR_EQUATION( 1778 size = ComponentRef.size(var.name), 1779 iter = iter, 1780 body = {Pointer.access(eqn)}, 1781 source = DAE.emptyElementSource, 1782 attr = eqnAttr)); 1783 Equation.createName(eqn, idx, context); 1751 eqn := Equation.makeAssignment(lhs, rhs, idx, context, iter, eqnAttr); 1784 1752 // this could lead to non existing variables, should not be a problem though 1785 1753 Equation.renameIterators(eqn, "$i"); -
OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBDetectStates.mo
refc4e90 ref124e4 59 59 import BVariable = NBVariable; 60 60 import Differentiate = NBDifferentiate; 61 import NBEquation.{Equation, EquationPointers, EqData, WhenEquationBody, WhenStatement, IfEquationBody};61 import NBEquation.{Equation, EquationPointers, EqData, EquationAttributes, EquationKind, Iterator, WhenEquationBody, WhenStatement, IfEquationBody}; 62 62 import NBVariable.{VariablePointers, VarData}; 63 63 … … 266 266 // more than one algebraic variable > create auxiliary state 267 267 (state_var, state_cref, der_var, der_cref) := BVariable.makeAuxStateVar(Pointer.access(uniqueIndex), SOME(arg)); 268 aux_equation := Equation. fromLHSandRHS(Expression.fromCref(state_cref), arg, uniqueIndex, NBVariable.AUXILIARY_STR);268 aux_equation := Equation.makeAssignment(Expression.fromCref(state_cref), arg, uniqueIndex, NBVariable.AUXILIARY_STR, Iterator.EMPTY(), EquationAttributes.default(EquationKind.CONTINUOUS, false)); 269 269 returnExp := Expression.fromCref(der_cref); 270 270 -
OMCompiler/Compiler/NBackEnd/Modules/2_Pre/NBEvents.mo
r638e4828 ref124e4 212 212 (cond, cev) := tpl; 213 213 if not BVariable.isDummyVariable(cev.auxiliary) then 214 aux_eqn := Equation. fromLHSandRHS(Expression.fromCref(BVariable.getVarName(cev.auxiliary)), cond.exp, idx, context, EquationAttributes.default(EquationKind.DISCRETE, false));214 aux_eqn := Equation.makeAssignment(Expression.fromCref(BVariable.getVarName(cev.auxiliary)), cond.exp, idx, context, Iterator.EMPTY(), EquationAttributes.default(EquationKind.DISCRETE, false)); 215 215 auxiliary_vars := cev.auxiliary :: auxiliary_vars; 216 216 auxiliary_eqns := aux_eqn :: auxiliary_eqns; … … 414 414 algorithm 415 415 // create auxiliary equation and solve for TIME 416 tmpEqn := Pointer.access(Equation. fromLHSandRHS(exp.exp1, exp.exp2, Pointer.create(0), "TMP"));416 tmpEqn := Pointer.access(Equation.makeAssignment(exp.exp1, exp.exp2, Pointer.create(0), "TMP", Iterator.EMPTY(), EquationAttributes.default(EquationKind.UNKNOWN, false))); 417 417 _ := Equation.map(tmpEqn, function containsTimeTraverseExp(b = containsTime), SOME(function containsTimeTraverseCref(b = containsTime))); 418 418 if Pointer.access(containsTime) then
Note: See TracChangeset
for help on using the changeset viewer.