]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
simple interpolate function that adds automatically one parameter needed for interpolate2
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 07:54:52 +0000 (07:54 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 24 Aug 2010 07:54:52 +0000 (07:54 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@17494 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java

index 7949b38d6a2a22899f2d1daf0a86ad04cb40178f..d2e6243442a26cda32912e846fa2046f84b41d78 100644 (file)
@@ -38,9 +38,17 @@ public class ModelicaWriter {
 \r
         if(!functionsWritten) {\r
 \r
-            // THIS INTERPOLATE DOESN'T WORK PROPERLY\r
             b.append(\r
-                    "\nfunction Interpolate\n" +\r
+                    "\nfunction interpolate\n" +\r
+                    "  input Real u \"in1;put value (first column of table)\";\n" +\r
+                    "  input Real table[:, :] \"table to be interpolated\";\n" +\r
+                    "  output Real y \"interpolated input value (icol column of table)\";\n" +\r
+                    "algorithm \n" +\r
+                    "  y := interpolate2(u, table, 2);" +\r
+            "end interpolate;\n\n");\r
+                    \r
+            b.append(\r
+                    "\nfunction interpolate2\n" +\r
                     "  input Real u \"in1;put value (first column of table)\";\n" +\r
                     "  input Real table[:, :] \"table to be interpolated\";\n" +\r
                     "  input Integer icol \"column of table to be interpolated\";\n" +\r
@@ -81,7 +89,7 @@ public class ModelicaWriter {
                     "                  y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);\n" +\r
                     "          end if;\n" +\r
                     "  end if;\n" +\r
-            "end Interpolate;\n");\r
+            "end interpolate2;\n");\r
 \r
             b.append(\r
                     "function xidz\n" +\r
index b9137bd062a5855700296de3f63a51c98f4ca306..79620c288c67471f74603236a3181c33ec6a1d99 100644 (file)
@@ -32,7 +32,7 @@ public class WithLookupExpression extends Expression {
     @Override\r
     public String getEquation(IndependentVariable variable) {\r
         return \r
-        "    " + variable.getName() + " = Interpolate(" + equation + ", " + lookupTable + ", 2);\n";\r
+        "    " + variable.getName() + " = interpolate(" + equation + ", " + lookupTable + ");\n";\r
     }\r
 \r
 }\r