From 78054bfba97d758b8e0b205b6f902bdb41e462cb Mon Sep 17 00:00:00 2001 From: miettinen Date: Thu, 16 Jan 2014 05:49:26 +0000 Subject: [PATCH] Solving problems in custom integral equation in stocks (refs #4657). git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@28641 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../src/org/simantics/sysdyn/manager/SysdynModel.java | 3 ++- .../sysdyn/representation/expressions/StockExpression.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java index 561a99d8..feb07341 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java @@ -60,6 +60,7 @@ import org.simantics.sysdyn.representation.Variability; import org.simantics.sysdyn.representation.expressions.Expression; import org.simantics.sysdyn.representation.expressions.IExpression; import org.simantics.sysdyn.representation.expressions.ParameterExpression; +import org.simantics.sysdyn.representation.expressions.StockExpression; import org.simantics.sysdyn.solver.SolverSettings; import org.simantics.sysdyn.solver.SolverSettings.SolverType; @@ -273,7 +274,7 @@ public class SysdynModel implements IModel, IMappingListener, VariableSubscripti for(Object o : updated) { if(o instanceof Model) { continue; - } else if(o instanceof Expression) { + } else if(o instanceof Expression && !(o instanceof StockExpression)) { IndependentVariable variable = ((Expression)o).getParent(); Variability variability = Variability.getVariability(variable, false, configuration); if(variability == Variability.PARAMETER) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java index c96d01e4..18cd0632 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java @@ -50,12 +50,12 @@ public class StockExpression extends Expression { @Override public String getExpression() { - return "This + is + not + a + parameter + at + any + time"; + return initialEquation; } @Override public String getModelicaExpression() { - return FormatUtils.replaceWhitespace(getExpression()); + return FormatUtils.replaceWhitespace(initialEquation); } @Override @@ -68,7 +68,7 @@ public class StockExpression extends Expression { StringBuilder b = new StringBuilder(); b.append(" der(") .append(parent.getModelicaName() + range) - .append(") ="); + .append(") = "); if (integralEquation != null) { String equation = FormatUtils.replaceWhitespace(this.integralEquation); -- 2.47.1