Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

array inside function

array inside function

hi,

  I have the function below and among her inputs, there is Ta and as you can see it is declared as array,

Code:


function Nusselt_free_convection_fg_test

   
      output Real Nu[5];
      input Real  Ta[5];
      input Real  v, ni, Pr, Tfilm, Tfg_3, Lpan, teta;
    protected
      //--------------
      //import Modelica.Constants;
      parameter Real Pi = Modelica.Constants.pi;
      parameter Real g = 9.81;
      Real beta;
      Real cteta;
      Real Gr[5];
      Real Grcr;
    algorithm
      beta := 1 / Tfilm;
      cteta := 90 - teta;
      for i in 1:5 loop
        Gr[i] := g * cos(cteta * Pi / 180) * beta * (Tfg_3 - Ta[i]) * Lpan ^ 3 / ni ^ 2;
        if v < 2 then
          Grcr := 15.0 * 10 ^ 9;
        else
          Grcr := 6.0 * 10 ^ 9;
        end if;
        Nu[i] := 0.14 * ((Gr[i] * Pr) ^ (1 / 3) - (Grcr * Pr) ^ (1 / 3)) + 0.56 * (Grcr * Pr * cos(teta * Pi / 180)) ^ (1 / 4);
      end for;
   
end Nusselt_free_convection_fg_test;

when I simulate this function by the test fuction below I got this error message
]: Type mismatch for positional argument 1 in Nusselt_free_convection_fg_test(Ta=Ta[i]). The argument has type:
  Real
expected type:
  Real[5]
can anyone help me?

Code:



class test_propria_fun
Real a[5];
parameter Real Ta[5]={24.6,23.5,23.3,24.1,24.5};
equation
for i in 1:5 loop
a[i]=Nusselt_free_convection_fg_test(Ta[i],1.5,1.6699e-5,0.7110,310,35,3.354,45);
end for;
end test_propria_fun;


Edited by: Abderezakabidi - May-04-20 20:13:52
There are 0 guests and 0 other users also viewing this topic