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
  • » Abderezakabidi
  • » Profile

Posts

Posts

Hi everybody,
   
   I have two questions about complex number in opnemodelica?


     I have a variable in certain time in the simulation turn from real to complex

    how I define this variable complex or real ?

    how I can make a derivative of a complex number or funvtion in openmodelica?


please, any idea

thank you for your help

Hi,


I have an ODE to solve

Code:


Der(Vc)=hg*(Vc-Vf)+hcp*(Vc-Vh)-m*Vc

at the beginning the initial condition is Vc (0) = 17.3

And after each iteration in the for loop I would like the initial condition to be the value of Vc itself.
how am i going to do that on openmodelica?

Please Can anyone help me?

adrpo,

  thannnnk you,
  very well explained, I understood your answer.

  in truth, I'm trying to translate a model from Matlab to OpenModelica.

   I managed to translate all parameters, constants, equations ... etc. but my problem is that I cannot translate this instruction which is used to solve ODE.in

Code:



t_7,T_7]=ode45('Modello3',tspan,T0_7);
//
Modello3 is the function that contain ODE
.....

I know that there is DASSL solver for ode in openmodelica but I don't know how does it works

Code:



T0_7=[16.2+273.15 16.2+273.15 16.2+273.15 16.2+273.15  16.2+273.15 16.2+273.15  32+273.15 ];
t0=0;                %Istante di tempo iniziale
tf=60;              %Istante di tempo finale
tspan=t0:1:t0+tf-1;

for i=1:1:N_misure

[t_7,T_7]=ode45('Modello3',tspan,T0_7);
//
Modello3 is the function that contain ODE
.....

T0_7=T_7(length(T_7), : ) ;

t0=t0+length(T_7);
end

sjoelund.se,
 
   thank you for your answer,

   In fact, I would like to assign a value for the initial temperature for each iteration, knowing that these values are saved in an array.

  So I want the Tint takes a new value from the array for each iteration, in order to solve an ODE.



HOOOOPING that I have described the problem correctly and you have understood my question.

thanks



Code:

model temperartureModel


parameter Real Tint=17.5;
Real T(start=Tint);

parameter Real [6,9] data={{22.3,    26.6,    27.7,    30.7,    29.8,    31.3,    19.5,    539,    0.3},
{26.5,    27.7,    29.3,    27.9,    29.8,    31.3,    19.6,    535,    0.8},
{26.9,    27.7,    28.1,    29.3,    29.9,    31.3,    19.7,    478,    1.6},
{27.3,    28.5,    28.3,    29.6,    29.9,    31.4,    19.7,    482,    2.3},
{27.3,    28.0,    28.0,    29.5,    29.8,    31.4,    19.7,    500,    2.5},
{27.4,    28.1,    28.6,    29.6,    29.8,    31.3,    19.8,    548,    2.5}};
//

/*
other parameters


*/
equation
for i in 1: N_mesure loop

der(T) = (q_punto_r_g_sky + q_r_g_gr * (Ta - T) + q_conv_g * (Ta - T) - q_cd_g_pv * (T - Tint) + alfa_fg * G * Ag) * (1 / Cg);

// others equations
end for

end temperartureModel;

Dear everyone,

I am using OpenModelica, and meet a problem.

In my model, I initialize each variable with certain value, such as
Real T(start = T0)

However, I need T0 to change at each iteration in for loop in ordre to solve an ODE. For example, I use "for loop".  At the beginning of each loop, I want to update the value of T.

How can I do this ?

Many thanks!

Apr-21-21 21:15:58
Question about how der() operator calculates the derivative
Category: Programming

Hi,

   I saw your answer and I think you can help me about the integation methods in modelica.
Actually, I try to translate a Mtlab code to modelica,

so my question how I can translate this instruction from matlab to openmodelica.

Code:


[t_7,T_7]=ode45('Modello3',tspan,T0_7)

can you help me please?










Apr-21-21 21:15:22
Question about how der() operator calculates the derivative
Category: Programming

Hi,

   I saw your answer and I think you can help me about the integation methods in modelica.
Actually, I try to translate a Mtlab code to modelica,

so my question how I can translate this instruction from matlab to openmodelica.

Code:


[t_7,T_7]=ode45('Modello3',tspan,T0_7)

can you help me please?










Apr-21-21 21:14:57
Question about how der() operator calculates the derivative
Category: Programming

Hi,

   I saw your answer and I think you can help me about the integation methods in modelica.
Actually, I try to translate a Mtlab code to modelica,

so my question how I can translate this instruction from matlab to openmodelica.

Code:


[t_7,T_7]=ode45('Modello3',tspan,T0_7)

can you help me please?










as you can see in the title, I have an ordinary diffrential equation and the unknow function can takes complex values and
I don't figure out how I can derivate this function.

I propose the code below

can anyone help me?

Code:



der(T7[i].re) = (0.4 * mr[i] * 0.016 * Kf * (Tout[i].re- T7[i].re) - Ks * (T7[i].re - Ta[i])) * (1 / Ct);
der(T7[i].im) = (0.4 * mr[i] * 0.016 * Kf * (Tout[i].im - T7[i].im) - Ks * (T7[i].im - Ta[i])) * (1 / Ct);



GTC

thank you it works very well;

I try to translate a program of temperature variation from Matlab to OpenModelica, so in matlab, the initial conditions are updated for each iteration, like shown in the code below,

How I can do that in OpenModelica?

Code:




T0_7=[16.2+273.15 16.2+273.15 16.2+273.15 16.2+273.15  16.2+273.15 16.2+273.15  32+273.15 ];


t0=0;                %Istante di tempo iniziale
tf=60;              %Istante di tempo finale
tspan=t0:1:t0+tf-1;  %Intervallo di tempo


Tint=16.2; %celsus
Tint=Tint+273.15;% kelvin

N_misure=1440;% nobre de mesure
TT_7=zeros((tf*N_misure),7);

for i=1:1:N_misure
   
   
    options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 ]);
   
    %Risoluzione del modello (8) modificato tramite il metodo Runge Kutta del 4 ordine

    [t_7,T_7]=ode45('Modello3',tspan,T0_7,options);         
    T_7=real(T_7);
   

    T0_7=T_7(length(T_7),:)



CTG,
 
   thank you,   I take what you told me with your example and I will apply it in my model.

CTG,

thank you CTG for your answer.

I do what you told me to do, but, now I have another problem in derivative of complex function.

is there a function which allow us to derivate a complex function? else you can give me an idea how to do this

can you help me, please?

thank you in advance for your answer

Code:




der(T2[i]) =(q_cd_g_pv * (T1[i] - T2[i]) - q_cd_pv_ted * (T2[i] - T3[i]) + (tau_fg * alfa_pv - eta) * G[i] * Apv + tau_fg * alfa_eva * G[i] * (Ag - Apv)) * (1 / Cpv);

message error: [OM_Modello3_11: 340:5-340:207]: Type mismatch for positional argument 1 in der(=T1[i]). The argument has type:
  Complex
expected type:
  Real

hi,


   thank you for your answer;


  in fact, I have a variable in my function and during simulation can takes real and complex numbers, so my question is how can I define this variable in the top of the function


thanks in advance

hi,


   can anyone help me

How to define complex numbers in arrays in openmodelcia, does the complex number take two boxes in the array or one



 

hi,


    If we have a variable and may be it takes real and complex values, so how I will define this value in OpenModelica.

    can anyone help me.








CTG,

  thank you a loooooot it was helpful for me and for who has the same problem

USER wrote:

sjoelund.se

hi

I want to solve this equation ax2+bx+c=0 in OpenModelica and when the discriminant (delta<0) is less then 0 the program does not give me the complex numbers results

Can you help me please?

Code:


function equation_2nd

input Real a;
input Real b;
input Real c;
output Real x1;
output Real x2;
output Real x0;
output Real c1;
output Real c2;

protected
Real d;
constant Complex j;
algorithm
d:=b^2-4*a*c;
if d>0 then
  x1:=(-b-sqrt(d))/(2*a);
  x2:=(-b+sqrt(d))/(2*a);
elseif d==0 then
  x0:=-b/(2*a);
  else
  c1:=(-b/(2*a))-j*(sqrt(d)/(2*a));
  c2:=(-b/(2*a))+j*(sqrt(d)/(2*a));
  end if;


end equation_2nd;

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;


hi
what does the error below means
and
can us use ode inside for loop in OpenModelica.
thanks in advance.
can anyone help me

Code:


der(cr) := exp is not legal Modelica code. OpenModelica accepts it for interoperability with non-standards-compliant Modelica tools. There is no way to suppress this warning.


I want to recover the values of x for each time instant (t) in a vector, in the example below.
for example t=0:0.1:5;

can any one help me please?



Code:



model test_ode
Real x;
Real y;
initial equation
x=0;
equation
y=time ;
der(x)=3*exp(-y);

end test_ode;

Can anyone help me, please?


[b]  I have a matrix with 100 lines and 9 columns and it is hard to write all this lines, can anyone help me to give me an idea how i can do this easily

  thank you in advance

May-02-20 16:49:04
To Obtain ODE formulation for a given DAE in OMC

adrpo,

   Hi adrpo,

          I have 2  differential equations and I want to initialize them, can you help me, please

Code:



  der(T1) = (q_punto_r_g_sky + q_r_g_gr * (Ta - T1) + q_conv_g * (Ta - T1) - q_cd_g_pv * (T1 - T2) + alfa_fg * G * Ag) * (1 / Cg);
  der(T2) = (q_cd_g_pv * (T1 - T2) - q_cd_pv_ted * (T2 - T3) + (tau_fg * alfa_pv - eta) * G * Apv + tau_fg * alfa_eva * G * (Ag - Apv)) * (1 / Cpv);


Hi,

   I want to solve ODE in openmodelica and when i simulate my model I get this warning message

can anyone help me, please?



03:31:17 Traduction Avertissement
Assuming fixed start value for the following 7 variables:
         T7:VARIABLE(fixed = true )  type: Real
         T6:VARIABLE(fixed = true )  type: Real
         T5:VARIABLE(fixed = true )  type: Real
         T4:VARIABLE(fixed = true )  type: Real
         T3:VARIABLE(fixed = true )  type: Real
         T2:VARIABLE(fixed = true )  type: Real
         T1:VARIABLE(fixed = true )  type: Real

hi,


I want to create a matrix with (n lines and j columns) and I will extract in a specific column of the matrix as described in the code below written in MatLab
can anyone help me please?

Code:



Matrix=[1,2,3;4 5 6;7 8 9]

a=Matrix(:,2)

Apr-30-20 01:07:57
how to declare array in modelica language
Category: Programming

hi,

    can you please show me how to declare a matrix with (n lines and j columns) and how extract a specific column

Code:


Matrix=[1 2 5;4 5 3;1 9 8]

a=Matrix(2,:)



I used CombiTimeTable in openmodelica to uplod the  txt file.

my question is how to extract each column separately and save them in variables

temp.txt



   Hi,

   can you please help me to show me how to uplaod txt file in CombiTimeTable ?

thanks in advance

Hi,
Can anyone help me to learn how to import a txt file into timetable as an input data? I am attaching the file. Can you please show me how to import the txt data into timetable?


Thanks in Advance.
temp.txt

adrpo,
hi,

   I saw you replay, so i want to help to uplaod data (ambiante temperature and external temperature)  to timetable
can you help me please



hi Arinomo23

Hello, thank you for your answer
can you explain to me how to write a txt file that Openmodelica accepts.
The excel file contains three columns, the first column corresponds to the time, the second column to the indoor temperature and the last column contains the external temperature

thank you

I'm looking for the integration methods of differential equations that OpenModelica uses

adrpo,

Hello,

   Actually, I want to translate a Matlab code to openmodelica

Can you help me to translate the instructions below

Code:



options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 ]);
[t, s]=ode45('Modello3',tspan,T0,options);

thank you in advance for your aswer

Hello,
Actually, I try to translate a Matlab code to openmodelica.
can any one help me to translate this instructions

Code:


options = odeset('RelTol',1e-4,'AbsTol',[1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 1e-4 ])
[t,X]=ode45(@Modello3, tspan, t0 ,options)

Hello,

   I have an Excel file and which it contains temperature values of one day, now I want to read all this data in modelica from an excel file

can any one help me, please?

thank you in advance fo your answer

Hi,

     I want to uplaod a picture inside a block 

thank you in advance for your answer

Hello,

    I  got this error when i run my model

Variable pvte500cr1.y[1] does not have any remaining equation to be solved in.  The original equations were:


Code:


model PVTE500CR
extends Modelica.Blocks.Interfaces.MIMO(nin=3);
extends Modelica.Blocks.Interfaces.MIMO(nout=3);

input Real Va;
input Real TaC;
input Real G;
//outputs
output Real Ia[:];
output Real p;
output Real pj;

//outputs
//% Define variables
Real TaK ;
Real Isc ;
Real Iph ;
Real Ir;
Real Vt_Ta ;
constant Real k=Modelica.Constants.k;
constant Real e_ch=Modelica.Constants.q;
//***************
parameter Real n = 1.62 ;
parameter Real Eg = 1.12;
parameter Real Ns = 36;
parameter Real TrK = 298;
parameter Real Voc_TrK = 22.30/Ns;
parameter Real Isc_TrK = 3.90;
parameter Real a = 0.95e-3;
parameter Real b= Eg * e_ch /(n * k);
parameter Real Vt_TrK = n * k * TrK / e_ch;
parameter Real Ir_TrK = Isc_TrK / (exp(Voc_TrK / Vt_TrK) -1);
parameter Real dVdI_Voc = -1.0/Ns;
parameter Real Xv = Ir_TrK / Vt_TrK * exp(Voc_TrK / Vt_TrK);
parameter Real Rs = - dVdI_Voc - 1/Xv;


equation
TaK = 273 + TaC;

Iph = G * Isc;
Isc = Isc_TrK * (1 + (a * (TaK - TrK)));
Ir = Ir_TrK * (TaK / TrK)^(3/n) * exp(-b * (1 / TaK -1 / TrK));
Vt_Ta = n * k * TaK / e_ch;
Ia[1]=0;

for i in 2:4 loop
  Ia[i]=Ia[i-1]-(Iph - Ia[i-1]-Ir.*(exp(((Ia[i-1]*Rs)+(Va/Ns))./Vt_Ta)-1))./(-1-Ir*(Rs./Vt_Ta).*exp(((Va/Ns) + Ia[i-1]* Rs) ./ Vt_Ta));
end for;

p=Ia[size(Ia,1)]*Va;
pj= Rs*(Ia[size(Ia,1)]^2)*Ns;//% + (( (Va+Rs*Ia)^2)/Rsh);


end PVTE500CR;

I would like to test my model if it works very well, I tried to inject constant inputs but it returns me errors when I simulate it

Code:


model test_pvt2
  Modelica.Blocks.Sources.Constant const(k = 1200)  annotation(
      Placement(visible = true, transformation(origin = {-150, 30}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
    Modelica.Blocks.Sources.Constant const1(k = 25)  annotation(
      Placement(visible = true, transformation(origin = {-150, -28}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
    Modelica.Blocks.Sources.Constant const2(k = 38)  annotation(
      Placement(visible = true, transformation(origin = {-150, -70}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  PVTE500CR pvte500cr1 annotation(
    Placement(visible = true, transformation(origin = {34, -22}, extent = {{-28, -28}, {28, 28}}, rotation = 0)));
equation
connect(const2.y, pvte500cr1.u[3]) annotation(
    Line(points = {{-138, -70}, {-56, -70}, {-56, -22}, {0, -22}}, color = {0, 0, 127}));
connect(const1.y, pvte500cr1.u[2]) annotation(
    Line(points = {{-138, -28}, {-58, -28}, {-58, -22}, {0, -22}}, color = {0, 0, 127}));
connect(const.y, pvte500cr1.u[1]) annotation(
    Line(points = {{-138, 30}, {-58, 30}, {-58, -22}, {0, -22}}, color = {0, 0, 127}));

    end test_pvt2;

can any one help me please?

Jan-01-20 16:26:05
Category: Programming

Hi,

     I took your exemple but I rewrote it in anathor way, finally it works well

Code:


block A
extends Modelica.Blocks.Interfaces.MO(nout=2);
  parameter Real a[2] = {5.0, 2.0};
  equation
  for i in 1:2 loop
  y[i] = a[i];
  end for;
end A;

//
block B
extends Modelica.Blocks.Interfaces.MIMO(nin=2);

extends Modelica.Blocks.Interfaces.MIMO(nout=2);
  equation
  // for loop to run out our model
  for i in 1:2 loop
    y[i] = u[i];
  end for;
 
end B;

//
model AB
  A a1 annotation(
    Placement(visible = true, transformation(origin = {-128, 12}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
  B b1 annotation(
    Placement(visible = true, transformation(origin = {14, 10}, extent = {{-10, -10}, {10, 10}}, rotation = 0)));
equation
for i in 1:2 loop
  connect(a1.y[i], b1.u[i]) annotation(
    Line(points = {{-116, 12}, {2, 12}, {2, 10}, {2, 10}}, color = {0, 0, 127}, thickness = 0.5));
    end for;

end AB;


hi,

   I want to translate this for loop from matab to openmodelica

Code:


Ia=zeros(size(Vc))
for j=1:5
Ia = Ia - (Iph - Ia - Ir .* ( exp((Vc + Ia .* Rs) ./ Vt_Ta) -1))./ (-1 - Ir * (Rs ./ Vt_Ta) .* exp((Vc + Ia .* Rs) ./ Vt_Ta))
end

can any one help me please?

thank you in advance



Hello,

I got this error when I run my model,
Please, can any one help me to fix this error?     


 
 
    Equation 13 (size: 1) Ia[3] = Ia[2] + (Ir * (-1.0 + exp((Vc + 0.01711085220626408 * Ia[2]) / Vt_Ta)) + Ia[2] - Iph) / (-1.0 + (-0.01711085220626408) * Ir * exp((Vc + 0.01711085220626408 * Ia[2]) / Vt_Ta) / Vt_Ta) is not big enough to solve for enough variables.

thanks in advance for your answer

Hello

    I got this error when I run my model

   Component Vc of variability PARAM has binding 0.02777777777777778 * Va of higher variability VAR

   openmodelica indicate that the error comes from this line
  parameter Real Vc=Va/Ns;

  can you help me please

Hello,


I want to use a function inside a block, so how I can associate function's inputs with block inputs and same thing for outputs

thank you in advance

Hello,

     Actually, I work to translate a program from matlab to modelica, but i have an issue about xlsread instruction in matlab 
so, can any one help me to find how to use xlsread in modelica


thanks in advance for your help

hello, thank you for your answer it was helpful

hello,

    I want to extract just the real part of a complex number, so can any one help me please?
thank in advance for your answer

hello

 
  I want to share parameters beetwen functions in modelica, like in matlabe with GLOBAL instruction
 
  can anyone help me, please?

thank you for your answer
your answer it was helpful for me, so I have another question which i want to share parameters with other function in modelica
can you please help me?

hello,

    Can anyone help me to solve this problem? so when I run my program I get this error

Component Tm of variability PARAM has binding 0.5 * (T4 + T6) of higher variability VAR.

thank you in advance for your answer

hello

     can anyone help me, please to return a column in matrix

Thank you, it was helpful so I have another question which I want to return a column of matrix
how I can do that?

Hello,
 
   can anyone please shaw me to extract the real part of a complex number

Jun-20-19 13:49:13
Topic: URGENT
Mppt references

Hello,

    can anyone give me refrences about Mppt controler used in openmodelica,


I get this error when I simulate the system, can you give me the suggestions answer for solving this problem, please? 
Incompatible components in connect statement: connect(voltageSensor1.y, pv_t31.u[6])
- voltageSensor1.y has components record ComplexOutput
  Real im;
  Real re;
end ComplexOutput;
- pv_t31.u[6] has components Real

Hello,
Can anyone explain to me how to use CombiTimeTable in OpenModelica, please with example thank you

can anyone help me, to give the solution for this problem each time a simulate the system it returns to me this error


Iteration variables with default zero start attribute in torn nonlinear equation system:
         pv_t31.u[6]:VARIABLE()  "Connector of Real input signals" type: Real  [6]

hello,

    can anyone help me to translate this function from matlab to modelica, at the least the for loop because i don't figure out how i can translate it
thank you for your help


 
function [Ia] = TE500CR(Va,G,TaC)
/*------comments---------------------*/
% function TE500CR.m models the Totale Energie TE500CR+ PV module
% calculates module current under given voltage, irradiance and temperature
% Ia = TE500CR(Va,G,T)
%
% Out: Ia = Module operating current (A), vector or scalar
% In: Va = Module operating voltage (V), vector or scalar
% G = Irradiance (1G = 1000 W/m^2), scalar
% TaC = Module temperature in deg C, scalar
%++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
/*--------------------------------------------*/
/*-------------parameters----------------*/
/*--------------------------------------------*/
% Define constants
k = 1.381e-23; % Boltzmann’s constant
q = 1.602e-19; % Electron charge
                % Following constants are taken from the datasheet of PV module and
                   % curve fitting of I-V character (Use data for 1000W/m^2)
n = 1.62; % Diode ideality factor (n),
                   % 1 (ideal diode) < n < 2
Eg = 1.12; % Band gap energy; 1.12eV (Si), 1.42 (GaAs),
                   % 1.5 (CdTe), 1.75 (amorphous Si)
Ns = 36; % # of series connected cells (TENESOL TE500CR+, 36 cells)
TrK = 298; % Reference temperature (25C) in Kelvin
Voc_TrK = 22.30/Ns; % Voc (open circuit voltage per cell) @ temp TrK
Isc_TrK = 3.90; % Isc (short circuit current per cell) @ temp TrK
a = 0.95e-3; % Temperature coefficient of Isc (0.065%/C)
                 % Define variables
TaK = 273 + TaC; % Module temperature in Kelvin
Vc = Va / Ns; % Cell voltage
                 % Calculate short-circuit current for TaK
Isc = Isc_TrK * (1 + (a * (TaK - TrK)));
                 % Calculate photon generated current @ given irradiance
Iph = G * Isc;
                  % Define thermal potential (Vt) at temp TrK
Vt_TrK = n * k * TrK / q;
                      % Define b = Eg * q/(n*k);
b = Eg * q /(n * k);
                    % Calculate reverse saturation current for given temperature
Ir_TrK = Isc_TrK / (exp(Voc_TrK / Vt_TrK) -1);
Ir = Ir_TrK * (TaK / TrK)^(3/n) * exp(-b * (1 / TaK -1 / TrK));
                    % Calculate series resistance per cell (Rs = 5.1mOhm)
dVdI_Voc = -1.0/Ns; % Take dV/dI @ Voc from I-V curve of datasheet
Xv = Ir_TrK / Vt_TrK * exp(Voc_TrK / Vt_TrK);
Rs = - dVdI_Voc - 1/Xv;
                 % Define thermal potential (Vt) at temp Ta
Vt_Ta = n * k * TaK / q;
                 % Ia = Iph - Ir * (exp((Vc + Ia * Rs) / Vt_Ta) -1)
                 % f(Ia) = Iph - Ia - Ir * ( exp((Vc + Ia * Rs) / Vt_Ta) -1) = 0
                % Solve for Ia by Newton's method: Ia2 = Ia1 - f(Ia1)/f'(Ia1)
Ia=zeros(size(Vc)); % Initialize Ia with zeros
                % Perform 5 iterations
/*--------------------------------------------------------------------------------------------------------------------*/
/*----------help me to translate this for loop below form matlab to modelica----------------------*/
/*--------------------------------------------------------------------------------------------------------------------*/
for j=1:5;
Ia = Ia - (Iph - Ia - Ir .* ( exp((Vc + Ia .* Rs) ./ Vt_Ta) -1))./ (-1 - Ir * (Rs ./ Vt_Ta) .* exp((Vc + Ia .* Rs) ./ Vt_Ta));
end

Abderezakabidi,
  hello,

    I want to create two blocks in OpenModelica and to connect between them, such that the second block's inputs are the first block's outputs.
can you help me to do this, please?
thank you   

hello
   
  Thank you Adeas for your answer


                               I want to attribute the parameters Inputs and outputs to the block's inputs and outputs how I can do this, please help?
 

Hello,


    can anyone help me to attribute the parameters to the inputs and outputs of the block that i will create it
thank you

Hello,
  thank you @Arinomo23, your answer it was helpful
now I have another question if you want, it is about blocks in OpenModelica, so can you tell me how I can create a block MIMO in OpenModelica and how I can specify the inputs and the outputs in the programme that I will write in this block,
thank you in advance for your answer.
 

How,

    How we can make a difference between variables and constants in OpenModelica code, please give me an example
can anyone help me, please
    thank you in advance for your answer

Hello,

  how will I connect the output (i) of block A to the input (j) of block B
can you help me, please?

Hello,
   thank you sjoelund so much for your answer, it was helpful
    weyy, thank you very much that's nice of you, I applied what you told me and it works very well, but I have another problem where I would like to connect between two multi-input multi-output blocks, so how will I connect the output (i) of block A to the input (j) of block B
my thank 

Hello
thank you sjoelund for your answer;

   I understand now how for loop works in OpenModelica, and you are right for your answer (note that I and Iph also need to be part of the same algorithm section or you will have double assignments), but in my program,  I still not understand how can I use the integer (i) because (Icc, q, K,  Tr, Eg) are the known parameters  but Tac and G are the inputs.
I want to calculate (io11, io22, Iph, I, Relec) at each loop and these parameters are dependently between them.
please, can you help me?

parameter Real np=3;
I := 0;
  Iph := 0;
  for i in 1:np loop
    io11 := io11 + (Icc / (exp(q * ((36 - 0.32 * (Tac - 224)) / 60) / (K * Tr)) - 1)) * (Tac / Tr) ^ 3 * exp(q * Eg * (1 / Tr - 1 / Tac) / K);
    io22 := io22 + (Icc / (exp(q * ((36 - 0.32 * (Tac - 273 - 49)) / 60) / (2 * K * Tr)) - 1)) * (Tac / Tr) ^ 3 * exp(q * Eg * (1 / Tr - 1 / Tac) / (2 * K));
    I := I + ((Icc + ki * (Tac - Tr)) * G / Gr) - (exp(q * ((0.5 * (1 - 0.0028 * (Tac - 273 - 25))) + Rs * I) / (K * Tac)) - 1) * io11 - (exp(q * ((0.5 * (1 - 0.0028 * (Tac - 273 - 25))) +     Rs * I) / (2 * K * Tac)) - 1) * io22 - (((0.5 * (1 - 0.0028 * (Tac - 273 - 25))) + Rs * I) / Rsh);
    Iph := Iph + (Icc + ki * (Tac - Tr)) * G / Gr;
    Relec := Relec + Ro * (1 - b * (Tac - 273 - Tref));
  end for;
end pvcurrent;

Hello,

    Hello, currently I work on the modeling of a PVT with OpenModelica, now I am creating the block MIMO which I will model the equations of the current source that exists in a Matlab file and I would like to convert them into openModelica but I have a problem with the use of the loop (for), I will give you the instructions that I want to translate to openModelica
can you help me, please?
------
(Tac and G are the inputs)
I=0
Iph=0
for i in 1:5 loop

io11 = (Icc / (exp(q * vo / (K * Tr)) - 1)) * (Tac / Tr) ^ 3 * exp(q * Eg * (1 / Tr - 1 / Tac) / K);
    io22 = (Icc / (exp(q * vo / (2 * K * Tr)) - 1)) * (Tac / Tr) ^ 3 * exp(q * Eg * (1 / Tr - 1 / Tac) / (2 * K));
   C = (v + Rs * I) / Rsh;
  I = ((Icc + ki * (Tac - Tr)) * G / Gr) - (exp(q * (v + Rs * I) / (K * Tac)) - 1) * io11 - (exp(q * (v + Rs * I) / (2 * K * Tac)) - 1) * io22 - ((v + Rs * I) / Rsh);
    Iph = (Icc + ki * (Tac - Tr)) * G / Gr;
    Relec = Ro * (1 - b * (Tac - 273 - Tref));
  end for;

end for

  I want to create a MIMO block in openmodelica, which I can introduce in equations like in Matlab/Simulink , can anyone help me, please? 

Apr-16-19 13:18:58
I'm beginner in openmodelica, so I want to create my own photovoltaic cell with parallel and...

Open-Source-PhotoVoltaics-Libraryfor-Systemic-Investigations.pdf

Hello,
I'm beginner in openmodelica, so I want to create my own photovoltaic cell with parallel and series resistor, so there exist in photovoltaics library a model about cell but it is just a basic model, so How I can add a series and parallel resistor in the basic model existe can you help me please

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