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
  • Index
  • » Users
  • » sh12
  • » Profile

Posts

Posts

Jun-17-16 10:04:13
Category: Programming

Hello,
I have the following error

Index number 1 of the array expression Vout_gt[count4] is not an integer expression.

Index number 1 of the array expression Pout_gt[count4] is not an integer expression.

even thought count4 has been declared as Integer. Can someone help?



The code is below!

model pv_version1_17june

input Real T_Real_in_dyncur;
  input Real V_capacitor_in_dyncur, Reference_V_in_dyncur;
  input Real time_step_in_dyncur, Time_Instance_in_dyncur;
  output Real I_out_dyncur, V_capacitor_out_dyncur;
  output Integer Status_out_dyncur;
  input Integer P_coef_in_dyncur, G_Real_in_dyncur, Status_in_dyncur,
    V_control_in_dyncur, V_net_in_dyncur;

Real Gstc=1000;
  Real Rsh_gt, Isc_gt, Ir, Il_gt, Voc_gt, maxlim_gt=1000, iVoc_gt, I0_gt, Vr,
    modified_Vr, iIr, Vmpp_gt, Impp_gt, Pout_max;
  Real Vout_gt[:]=zeros(100);
  Real Iout_gt[:]=zeros(100);
  Real Pout_gt[:]=zeros(100);
  Real matrixsize=100;
  Real maxlim2=1000, step_size, count3;
  Integer count4;

algorithm
if G_Real_in_dyncur <0.0001 then //issues with small values of irradiance
            Vmpp_gt:=0;
            Impp_gt:=0;
        else  for count4 in 1:Vr loop
                  Pout_gt[count4]:=Vout_gt[count4]*Iout_gt[count4];
                    if Pout_gt[count4]>Pout_max then
                    Vmpp_gt:=Vout_gt[count4];
                    Impp_gt:=Iout_gt[count4];
                    end if;
             end for;
         end if;

end pv_version1_17june;

Jun-15-16 13:57:30
Topic: help!
Category: Programming

My code is below.
i am getting the following error. can someone help!

Trying to assign a parameter a value with higher variability:
iVt = Wcor*Vt+(1-Wcor)*(Impp*Rs+Vmpp-Voc)/(ns*log(((Isc-Impp)*(Rs+Rsh)-Vmpp)/( Isc*(Rs+Rsh)-Voc)));

Trying to assign a parameter a value with higher variability:
iRs = Wcor*Rs+(1-Wcor)*(Voc-Vmpp+ns*Vt*log(ns*Vt*(Impp*Rs+Impp*Rsh-Vmpp)/(Isc*Rs *Vmpp+Isc*Rsh*Vmpp+Impp*Voc*Rs-Impp*Isc*Rs*Rs-Isc*Impp*Rsh*Rs-Vmpp*Voc)))/Impp;

Trying to assign a parameter a value with higher variability:
iRsh = Wcor*Rsh+(1-Wcor)*(ns*Vt*Rs+ns*Vt*Rsh+Rs*exp((Isc*Rs-Voc)/(ns*Vt))*(Isc* Rs+Isc*Rsh-Voc))/(ns*Vt+Rs*exp((Isc*Rs-Voc)/(ns*Vt))*(Isc*Rs+Isc*Rsh-Voc));

Error detected in
algorithm
for count1 in (1:maxlim1) loop
iVt := Wcor*Vt+(1-Wcor)*(Impp*Rs+Vmpp-Voc)/(ns*log(((Isc-Impp)*(Rs+Rsh)- Vmpp)/(Isc*(Rs+Rsh)-Voc)));
iRs := Wcor*Rs+(1-Wcor)*(Voc-Vmpp+ns*Vt*log(ns*Vt*(Impp*Rs+Impp*Rsh-Vmpp)/ (Isc*Rs*Vmpp+Isc*Rsh*Vmpp+Impp*Voc*Rs-Impp*Isc*Rs*Rs-Isc*Impp*Rsh*Rs- Vmpp*Voc)))/Impp;
iRsh := Wcor*Rsh+(1-Wcor)*(ns*Vt*Rs+ns*Vt*Rsh+Rs*exp((Isc*Rs-Voc)/(ns*Vt)) *(Isc*Rs+Isc*Rsh-Voc))/(ns*Vt+Rs*exp((Isc*Rs-Voc)/(ns*Vt))*(Isc*Rs+Isc* Rsh-Voc));
if (abs((iVt-Vt)/iVt) < accuracy) then
if (abs(iRs-Rs) < accuracy) then
if (abs((iRsh-Rsh)/iRsh) < accuracy/10) then
Vt := iVt;
Rs := iRs;
Rsh := iRsh;
else
Vt := 0;
Rs := 0;
Rsh := 0;
end if;
else
Vt := 0;
Rs := 0;
Rsh := 0;
end if;
else
Vt := 0;
Rs := 0;
Rsh := 0;
end if;
end for;
I0 := (Isc-(Voc-Isc*Rs)/Rsh)*exp( -Voc/(ns*Vt));




model Photovoltaic1
extends SinglePhase.Interfaces.OnePortGrounded;

  import Modelica.ComplexMath.'abs';
  import Modelica.ComplexMath.real;
  import Modelica.ComplexMath.imag;
  import Modelica.ComplexMath.conj;
  import Modelica.Constants.k;

    parameter Modelica.SIunits.ActivePower Pnom = 500e3 "nominal power";
  parameter String profileFileName = "NoName" "File where matrix is stored"
    annotation (Dialog(
      loadSelector(filter="Text files (*.txt);;MATLAB MAT-files (*.mat)",
          caption="Open file in which table is present")));
  parameter String profileName = "NoName" "Table name on file";

//    Modelica.Blocks.Sources.CombiTimeTable pvProfile(
//     tableOnFile = true,
//     tableName = profileName,
//     fileName = profileFileName,
//     table = fill(0.0, 0, 4),
//     extrapolation = Modelica.Blocks.Types.Extrapolation.Periodic);
//
//     Real irrad = pvProfile.y[1] + pvProfile.y[2];
//     Real temp = pvProfile.y[3];

  //pv origins
   input Real Voc, Isc, Vmpp, Impp, Nss, Npp, Wcor;
   output Real I0, Vt, Rs, Rsh, ns;
    parameter Real maxlim1 = 3000;
    parameter Real accuracy = 0.001;
    parameter Real count1;
    parameter Real Voc_out, Vmpp_out, Impp_out, Isc_out, iVt, iRs, iRsh;

equation
  //-----------------------------------------------------------------------PV_ORIGINS-------------------------------------------------------------------------------------------------------------------------------------------------------------//
// Calculation of parameter for ITERATION
  Voc_out =  Voc * Nss;
  Isc_out =  Isc * Npp;
  Vmpp_out =  Vmpp* Nss;
  Impp_out =  Impp * Npp;
  ns =  Nss;

  //applying SUR - successive-under relaxation
  //finding intial data for iterations
  Vt =  (Impp * Rs + Vmpp - Voc) / (ns * log(((Isc - Impp) * (Rs + Rsh) - Vmpp) / (Isc * (Rs + Rsh) - Voc))); // eqn 2.17 jUNCTION vOLTAGE
  //all the variables with additional "i" in cycles are used for cycling purpose

algorithm
  for  count1 in 1:maxlim1 loop //when used only previous data in calculations-less steps required
    iVt:=Wcor*Vt + (1 - Wcor)*((Impp*Rs + Vmpp - Voc)/(ns*log(((Isc - Impp)*(Rs +
      Rsh) - Vmpp)/(Isc*(Rs + Rsh) - Voc))));                                                           //Eq.2.27
    iRs:=Wcor*Rs + (1 - Wcor)*((Voc - Vmpp + ns*Vt*log(ns*Vt*(Impp*Rs + Impp*
      Rsh - Vmpp)/(Isc*Rs*Vmpp + Isc*Rsh*Vmpp + Impp*Voc*Rs - Impp*Isc*Rs*Rs -
      Isc*Impp*Rsh*Rs - Vmpp*Voc)))/Impp);                                                                                                    //Eq.2.28
    iRsh:=Wcor*Rsh + (1 - Wcor)*((ns*Vt*Rs + ns*Vt*Rsh + Rs*exp((Isc*Rs - Voc)/(
      ns*Vt))*(Isc*Rs + Isc*Rsh - Voc))/(ns*Vt + Rs*exp((Isc*Rs - Voc)/(ns*Vt))*
      (Isc*Rs + Isc*Rsh - Voc)));                                                                                                    //Eq.2.21
    if abs((iVt-Vt)/iVt)<accuracy then
        if abs(iRs-Rs)<accuracy then //Rs can be close to 0, so absolute is used
            if abs((iRsh-Rsh)/iRsh)<(accuracy/10) then//Rsh differs in order, comapred to Vt and Rs
                Vt:=iVt;
                Rs:=iRs;
                Rsh:=iRsh;
            else
               Vt:=0;
                Rs:=0;
                Rsh:=0;
            end if;
        else
           Vt:=0;
           Rs:=0;
           Rsh:=0;
        end if;
    else
       Vt:=0;
       Rs:=0;
       Rsh:=0;
    end if;

  end for;
  I0 :=(Isc - (Voc - Isc*Rs)/Rsh)*exp(-Voc/(ns*Vt));            //eqn 2.23 diode or dark saturation current

annotation (
  Icon(
     coordinateSystem(
        preserveAspectRatio=false,
        extent={{-100,-100},{100,100}},
        grid={2,2}),
      graphics={
        Line(
          points={{0,100},{0,50}},
          color={0,0,0}),
        Ellipse(
          extent={{-50,50},{50,-50}}),
        Text(
          extent={{-100,-100},{100,-60}},
          textString = "//Pnom"),
        Text(
          extent={{-30,30},{30,-30}},
          textString="PV")}),
  Documentation(info="<html>   
  <p>
  The model is according to the paper \"A novel model for photovoltaic array performance prediction\" by Wei Zhou et al.
  </p> 
 
</html>"));
end Photovoltaic1;

Jun-15-16 10:36:17
Category: Programming

I have the following code. when simulating it shows the following problem.


For algorithm
for count3 in (1:maxlim2) loop
iIr := Wcor*Ir+(1-Wcor)*(IL-I0_GranTurismo*(exp((Vr+Ir*Rs)/(ns*Vt))-1)-(Vr+ Ir*Rs)/Rsh_real);
if (abs(iIr-Ir) < accuracy) then
Iout_GranTurismo[count2] := iIr;
else
// No equations
end if;
Ir := iIr;
Iout_GranTurismo[count2] := iIr;
count3 := count3+1;
end for;
Vout_GranTurismo[count2] := Vr;
Pout_max := 0;

Assignment of Real to Integer.


is there any way i change the type to include both?



model Photovoltaic
  import Photovoltaic;
extends SinglePhase.Interfaces.OnePortGrounded;

  import Modelica.ComplexMath.'abs';
parameter Real Gstc = 1000;
    parameter Integer maxlim2= 1000;
    parameter Integer matrixsize = 10000;
    parameter Real Impp_real, Pout_max, iVoc_real, Tstc=298, Vr;
    parameter Integer   count2, count3;
    parameter Integer  Vout_GranTurismo[:] = zeros( matrixsize);
    parameter Integer   Iout_GranTurismo[:] = zeros( matrixsize);
    parameter Integer Pout_GranTurismo[:] = zeros(matrixsize);
    parameter Integer iIr, Ir;
    input Real  Ki, Kv,  T_real;
    input Integer G_real;
    output Real IL; //Iphotocurrent calculated with new values pg12
    output Real Rsh_real,Vmpp_GranTurismo, Voc_real=28, Isc_real;
    output Real I0_GranTurismo; // Diode Current,


equation
   I0_GranTurismo =  (Isc_real - (Voc_real - Isc_real * Rs) / Rsh_real) * exp(-Voc_real / (ns * Vt)); //eqn 2.23
   Ir =  Isc_real;
algorithm
      count2 =0;

        for Vr in 0:Voc_real loop
               count3 = 1;
               count2 = count2 + 1;


          for count3 in 1:maxlim2 loop
       iIr :=Wcor*Ir + (1 - Wcor)*(IL - I0_GranTurismo*(exp((Vr + Ir*Rs)/(ns*Vt))
       - 1) - (Vr + Ir*Rs)/Rsh_real);

       if  abs(iIr - Ir) < accuracy then
        Iout_GranTurismo[count2] :=iIr;
        else

       end if;

       Ir :=iIr;
       Iout_GranTurismo[count2] :=iIr;
      count3 :=count3 + 1;//counter to limit number of iterations
     end for;


     Vout_GranTurismo[count2] :=Vr;
    end for;
    Pout_max :=0;

       if  G_real < 0.0001 then
        Vmpp_GranTurismo :=0;
        Impp_real :=0;
      else
        for count4 in 1:count2 loop
          Pout_GranTurismo[count4] :=Vout_GranTurismo[count4]*Iout_GranTurismo[
        count4];
          if  Pout_GranTurismo[count4] > Pout_max then
            Vmpp_GranTurismo :=Vout_GranTurismo[count4];
            Impp_real :=Iout_GranTurismo[count4];
            else
          end if;
        end for;
       end if;

end Photovoltaic

Jun-15-16 09:39:47
Category: Programming

ok. thanx. but this is a Model that I am making. How do i include an algorithm in this? can you show an example?

model Photovoltaic
extends SinglePhase.Interfaces.OnePortGrounded;

  import Modelica.ComplexMath.'abs';
parameter Real Gstc = 1000;
    parameter Integer maxlim2= 1000;
    parameter Integer matrixsize = 10000;
    parameter Real Impp_real, Pout_max, iVoc_real, Tstc=298,iIr, Vr, Ir;
    parameter Integer   count2, count3;
    parameter Integer  Vout_GranTurismo[:] = zeros( matrixsize);
    parameter Integer   Iout_GranTurismo[:] = zeros( matrixsize);
    parameter Integer Pout_GranTurismo[:] = zeros(matrixsize);
    input Real  Ki, Kv,  T_real;
    input Integer G_real;

equation

     if  G_real == 0 then   //to avoid division by 0
     Rsh_real =  100000000000000;   //close to infinite
   else
     Rsh_real =  Rsh * (Gstc / G_real); //eqn 2.28
     end if;

   Isc_real =  Isc * (G_real / Gstc) * (1 + (Ki * (T_real - Tstc))); // eqn 2.27
   IL =  Isc_real + ((Isc_real * Rs) / Rsh_real); //eqn 2.29
   Voc_real= Voc * (1 + Kv * (T_real - Tstc)) + ns * Vt * log(G_real / Gstc); //eqn 2.30

     for count1 in 1:maxlim2 loop
          iVoc_real=     Wcor * Voc_real + (1 - Wcor) * (ns * Vt * log((IL * Rsh_real - Voc_real) / (I0 * Rsh_real)) * (1 + Kv * (T_real - Tstc)));
         if G_real < 0.001 then
           Voc_real =   0;
         else

             if  abs((iVoc_real - Voc_real) / Voc_real) < accuracy then
              Voc_real =     iVoc_real;
             else
         end if;

         end if;

    end for;
   I0_GranTurismo =  (Isc_real - (Voc_real - Isc_real * Rs) / Rsh_real) * exp(-Voc_real / (ns * Vt)); //eqn 2.23
   Ir =  Isc_real;

     count2 =  0;
       for Vr in 0:Voc_real / (matrixsize - 1):Voc_real loop
              count3 =  1;
              count2 =  count2 + 1;
          for count3 in 1:maxlim2 loop
       iIr =  Wcor * Ir + (1 - Wcor) * (IL -  I0_GranTurismo * (exp((Vr + Ir * Rs) / (ns * Vt)) - 1) - (Vr + Ir * Rs) / Rsh_real);

       if  abs(iIr - Ir) < accuracy then
        Iout_GranTurismo[count2] =  iIr;
        else

       end if;

       Ir =  iIr;
       Iout_GranTurismo[count2] =  iIr;
      count3 =  count3+1; //counter to limit number of iterations
     end for;

     Vout_GranTurismo[count2] =  Vr;
   end for;
   Pout_max =  0;

       if  G_real < 0.0001 then
        Vmpp_GranTurismo =  0;
        Impp_real =  0;
      else
        for count4 in 1:count2 loop
          Pout_GranTurismo[count4] =  Vout_GranTurismo[count4] * Iout_GranTurismo[count4];
          if  Pout_GranTurismo[count4] > Pout_max then
            Vmpp_GranTurismo =  Vout_GranTurismo[count4];
            Impp_real =  Iout_GranTurismo[count4];
            else
          end if;
        end for;
       end if;

end Photovoltaic;

Jun-15-16 09:20:28
Category: Programming

I am using dymola and i still dont understand what you mean. Do i need to include a function in this model?

Jun-15-16 09:08:51
Category: Programming

This is my full code.
How do i change it?


Isc_real =  Isc * (G_real / Gstc) * (1 + (Ki * (T_real - Tstc)));  // eqn 2.27
   
IL =  Isc_real + ((Isc_real * Rs) / Rsh_real);  //eqn 2.29
   Voc_real =  Voc * (1 + Kv * (T_real - Tstc)) + ns * Vt * log(G_real / Gstc); //eqn 2.30

     for count1 in 1:maxlim2 loop
          iVoc_real =  Wcor * Voc_real + (1 - Wcor) * (ns * Vt * log((IL * Rsh_real - Voc_real) / (I0 * Rsh_real)) * (1 + Kv * (T_real - Tstc)));

         if  G_real < 0.001 then
           Voc_real =  0;
         else

             if  abs((iVoc_real - Voc_real) / Voc_real) < accuracy then
              Voc_real =  iVoc_real;
             else
         end if;
       end if;
    end for;

Jun-15-16 08:57:14
Category: Programming

Hello,

i am getting the following error, can some one help?


Unable to expand if-statement:
if (abs((iVoc_real-Voc_real)/Voc_real) < 0.001) then
Voc_real = iVoc_real;
else
// No equations
end if;

since the different branches have different number of equations.

If-statements where the conditions are non-parameters
must have the same number of scalar equations in all branches.

  • Index
  • » Users
  • » sh12
  • » Profile
You are here: