Message Boards Message Boards

Error while using NDSolve?

This code doesn't work, Please, I need help.

$Version
Clear[nN, beta0, gamma, sigma, iI0, sol, sS, eE, iI, rR]
nN = 100 000; (* Estudio para 100 mil personas *)
beta0 = 1.0;
gamma = 1 / 5; (* la enfermedad dura, de media, cinco días *)
sigma = 1 / 7; (* el periodo asintomático dura, de media, siete días *)
iI0 = 1; (* un infectado al principio *)
(* tiempo t en días *)
sol = NDSolve[\:f01csS'[t] == (-beta0) * (sS'[t]) * (iI[t]) \:f00c nN,
eE'[t] == (beta0)*(sS[t]) * (iI[t]) \:f00c (nN) - (sigma) * (eE[t]),
iI'[t] == (sigma)*(eE[t]) - (gamma) * (iI[t]),
rR'[t] == (gamma)*(iI[t]),
sS[0] == (nN) - (iI0), (eE[0]) == (iI0), (iI[0]) == 0, (rR[0]) == 0\:f027,
{sS, eE, iI, rR}, {t, 0, 240}];
Plot[Evaluate[{sS[t], eE[t], iI[t], rR[t]} /. sol], {t, 0, 120},
PlotRange \[RightArrow] All, AxesOrigin \[RightArrow] {0, 0}, AxesLabel \[RightArrow] {"días",},
PlotLegends \[RightArrow] {"susceptibles", "expuestos", "infectados", "recuperados"}]
Attachments:
2 Replies
Posted 3 years ago

Restart Mathematica and, before doing anything else, scrape this code off the screen and paste it into your notebook and run it and report what you get

nN=100000;beta0=1.0;gamma=1/5;sigma=1/7;iI0=1;
sol=NDSolve[{sS'[t]==-beta0*sS'[t]*iI[t]/nN,
eE'[t]==beta0*sS[t]*iI[t]/nN-sigma*eE[t],
iI'[t]==sigma*eE[t]-gamma*iI[t],rR'[t]==gamma*iI[t],
sS[0]==nN-iI0,eE[0]==iI0,iI[0]==0,rR[0]==0},
{sS[t],eE[t],iI[t],rR[t]},{t,0,240}];
Plot[Evaluate[{sS[t],eE[t],iI[t],rR[t]}/.sol],{t,0,120},
PlotRange->All,AxesOrigin->{0,0}]

If it works then compare that character by character with the code you showed above and look at every tiny difference.

POSTED BY: Bill Nelson

Your first equation includes derivative of sS in both parts, left and right

sS'[t] == (-beta0) * (sS'[t]) * (iI[t]) / nN
POSTED BY: Konstantin Nosov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract