Professional Documents
Culture Documents
RK4 - EjemploVentechow
RK4 - EjemploVentechow
RK4 - EjemploVentechow
S = Almacenamiento S (H)
A = Área = A (H)
Q = Salida del embalse en función de la altura
I = Entrada I(t)
dS
= I (t) - Q (H (t))
dt
dS = A (H) dH
dS dH
= A (H) = I (t) - Q (H (t))
dt dt
dH I (t) - Q (H (t))
=
dt A (H)
Datos
In[1]:= Ao = 43 560;
dt = 600; tmax = 250 * 60; nt = tmax / dt
Out[2]= 25
Caudal elevación
In[3]:= dh = 0.5; nh = 20;
H = Table [i dh, {i, 0, nh}];
Q = {0, 3, 8, 17, 30, 43, 60, 78, 97, 117,
137, 156, 173, 190, 205, 218, 231, 242, 253, 264, 275};
2 RK4_EjemploVentechow.nb
250
200
150
Q
Out[6]=
100
50
0
0 2 4 6 8 10
H
250
200
150
Q
Out[8]= 100
50
0
0 2 4 6 8 10
H
Hidrograma de Entrada
In[9]:=
350
300
250
200
I(t)
Out[13]=
150
100
50
0
0 2000 4000 6000 8000 10 000 12 000 14 000
t
(Ents[t] - QH[h])
In[15]:= f[t_, h_] := dt
Ao
In[16]:= QH[H]
Out[16]= {0., 3., 8., 17., 30., 43., 60., 78., 97., 117., 137.,
156., 173., 190., 205., 218., 231., 242., 253., 264., 275.}
In[17]:= ts = t;
In[21]:= QS;
4 RK4_EjemploVentechow.nb
350
300
250
200 Entrada
Out[22]=
150
Salida
100
50
In[23]:= Max[QS]
Out[23]= 269.475
Función
(Ents[t] - QH[h])
In[24]:= ff[t_, h_] :=
Ao
Método de Euler
In[25]:= He = Table[0, {i, 0, nt}];
InterpolatingFunction::dmval :
Input value {10.3324} lies outside the range of data in the interpolating function. Extrapolation will be used.
InterpolatingFunction::dmval :
Input value {10.3324} lies outside the range of data in the interpolating function. Extrapolation will be used.
350
300
250
200 Entrada
Out[29]=
150
Salida
100
50
350
300
250
200 Entrada
Out[34]=
150
Salida
100
50
NDSolve
In[35]:= sol = NDSolveValue[{HT '[tt] ⩵ ff[tt, HT[tt]], HT[0] == 0}, HT, {tt, 0, tmax}]
350
300
250
200
Out[37]=
150
100
50
Comparación
In[38]:= ListLinePlot[{Transpose[{ts, Hin}], Transpose[{ts, QS}],
Transpose[{ts, QSe}], Transpose[{ts, QSr}], Transpose[{ts, QSND}]},
PlotLegends → {"Entrada", "RK3", "Euler", "RK4", "NDSolve"},
Frame → True, GridLines → Automatic]
350
300
250 Entrada
RK3
200
Out[38]= Euler
150
RK4
100 NDSolve
50
0
0 2000 4000 6000 8000 10 000 12 000 14 000