Sytem of ODE with time varying coefficients in a csv file

2 次查看(过去 30 天)
I want to solve 2 simultaneous differential equations whose coefficients are dependent on temperature and solar irradiance whose data i have in a csv file. How should i model this to get the values of voltage and current?
Here the terms in differential equations are dependent on temperature and solar irradiance and are also dependent on the current values of voltage and current.
  3 个评论
Atharva Bhomle
Atharva Bhomle 2023-4-16
编辑:Torsten 2023-4-16
here is the code currently i have written
i have solar irradiance and temperature data for every 5 min in a day
clc;
clear all;
close all;
filename='new.csv';
M=csvread(filename,1,2);
gt=linspace(1,287,287);
TT=linspace(1,287,287);
g=M(:,2);
T=M(:,1)+273;
t_values=linspace(1,287,287);
initial_conditions=[0.1; 0];
[tv, xv]=ode45(@(t,x) myODE(t, x, T, g, TT, gt), t_values, initial_conditions);
subplot(5,1,1);
plot(tv,xv(:,1));
xlabel("time");
ylabel("V");
subplot(5,1,2);
plot(tv,xv(:,2));
xlabel("time");
ylabel("I");
subplot(5,1,3);
plot(tv,xv(:,1).*xv(:,2));
xlabel("time");
ylabel("Power");
subplot(5,1,4);
plot(xv(:,1),xv(:,2));
xlabel("V");
ylabel("I");
subplot(5,1,5);
plot(xv(:,1),xv(:,1).*xv(:,2));
xlabel("V");
ylabel("Power");
function Dx = myODE(t, x, T, g, TT, gt)
%defining constants
C=940e-06;
L=2.5e-3;
voc=21.24;
A=1.6;
B=1.6;
k=1.3805e-23;
q=1.6e-19;
rs=0.051;
rsh=333.36;
r=5.76;
iscr=2.55;
ki=0.0017;
ego=1.1;
ns=36;
pmp=37.26;
T = interp1(TT, T, t);
g = interp1(gt, g, t);
iph=(iscr+ki*(T-298))*(g);
irs= iscr/(exp((q*voc)/(ns*k*A*T))-1);
io= irs*((T/298)^3)*exp(((q*ego)/(B*k))*((1/298)-(1/T)));
id= io*(exp((q*(x(1)+x(2)*rs))/(A*k*T))-1);
Dx=[(1/C)*(iph-id-((x(1)+x(2)*rs)/rsh)); ...
(1/L)*(x(1)+x(2)*rs-x(2)*r-(((x(2)^2)*r)/pmp))];
end
Torsten
Torsten 2023-4-16
Your usage of interp1 is wrong. Look up the documentation.
From the arrays g and T, you must retrieve the values at time instant t.
This works like
g_actual_time = interp1(Time,g,t)
T_actual_time = interp1(Time,T,t)
So you need an array Time that contains the times when g and T were measured.
What the arrays gt and TT are good for: I don't know.
If you are uncertain about how to proceed, take a look at the example "ODE with Time-Dependent Terms" under

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by