@@ -191,7 +191,7 @@ algorithm
191191 DAE . ComponentRef cr,cr1;
192192 DAE . Type tp;
193193 DAE . Exp e1,e2,res;
194- Real r;
194+ Real r, r2 ;
195195 list< DAE . Statement > asserts;
196196
197197 // special case for inital system when already solved, cr1 = $_start(...)
@@ -254,9 +254,21 @@ algorithm
254254 e2 = DAE . BINARY (inExp2,DAE . POW (tp),res);
255255 (res, asserts) = solve(e1,e2,inExp3);
256256 then (res, asserts);
257- // f(a)^n = 0 => f(a) = 0
258- // where n is odd
259- case (DAE . BINARY (e1,DAE . POW (tp),e2), DAE . RCONST (real = 0 . 0 ), DAE . CREF (componentRef = cr))
257+ // (r1)^f(a) = r2 => f(a) = ln(r2)/ln(r1)
258+ case (DAE . BINARY (e1 as DAE . RCONST (r),DAE . POW (_),e2), DAE . RCONST (r2), DAE . CREF (componentRef = cr))
259+ equation
260+ true = r2 >. 0 . 0 ;
261+ true = r >. 0 . 0 ;
262+ false = Expression . isConstOne(e1);
263+ true = Expression . expHasCref(e2, cr);
264+ e1 = Expression . makePureBuiltinCall("log" ,{e1},DAE . T_REAL_DEFAULT );
265+ res = Expression . makePureBuiltinCall("log" ,{inExp2},DAE . T_REAL_DEFAULT );
266+ res = Expression . makeDiv(res,e1);
267+ (res, asserts) = solve(e2,res,inExp3);
268+ then
269+ (res,asserts);
270+ // f(a)^b = 0 => f(a) = 0
271+ case (DAE . BINARY (e1,DAE . POW (_),e2), DAE . RCONST (real = 0 . 0 ), DAE . CREF (componentRef = cr))
260272 equation
261273 false = Expression . expHasCref(e2, cr);
262274 true = Expression . expHasCref(e1, cr);
@@ -265,7 +277,7 @@ algorithm
265277 (res,asserts);
266278 // f(a)^n = c => f(a) = c^(1/n)
267279 // where n is odd
268- case (DAE . BINARY (e1,DAE . POW (tp ),e2 as DAE . RCONST (r)), _, DAE . CREF (componentRef = cr))
280+ case (DAE . BINARY (e1,DAE . POW (_ ),e2 as DAE . RCONST (r)), _, DAE . CREF (componentRef = cr))
269281 equation
270282 1 . 0 = realMod(r,2 . 0 );
271283 false = Expression . expHasCref(inExp2, cr);
0 commit comments