Message Boards Message Boards

0
|
3913 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

NDSolve giving an error

Posted 8 years ago

Hello,

I have a system with 6 differential equations that I try to solve with NDSolve.

The code I use is ;

u[c_] := (c^(1 - \[Sigma]) - 1^(1 - \[Sigma]))/(1 - \[Sigma])

f[s_] := s + g s (1 - s/sbar1) 

h[s_] := (2 hbar)/(1 + Exp[\[Eta] (s/sbar - 1)])

mit[m_] := m^\[Alpha]

co[a_] := \[Phi]  (a^2)/2

\[Psi][k_] := wbar (\[Omega] + (1 - \[Omega]) Exp[-\[Gamma] k])

The calibration I use ;

paramFinal3 = {\[Sigma] -> 1.5, \[Rho] -> 0.025, g -> 0.05,  sbar -> 51.25, \[Eta] -> 5,  hbar -> 0.5, \[Chi] -> 10, \[Omega] -> 0.9, \[Delta] ->  0.065, \[Phi] -> 0.5, sbar1 -> 5, pricemit -> 0.0005, \[Alpha] -> 0.75, wbar -> 10, \[Gamma] -> 0.6};

My equation system is ;

dec1 = c'[t] == u'[c[t]]/u''[c[t]] (f'[s[t]] - (\[Rho] + h[s[t]]) - (\[Psi][k[t]]  h'[s[t]])/u'[c[t]] - (h'[s[t]] adj3[t])/u'[c[t]] );

dea1 = a'[t] == - (co'[a[t]]/co''[a[t]] (\[Rho] + h[s[t]] + (\[Psi]'[k[t]] h[s[t]])/co'[a[t]] + \[Delta]));

deadj1 = adj3'[t] == -((\[Rho] + h[s[t]]) adj3[t] - (u[c[t]] - \[Psi][k[t]] h[s[t]] - co[a[t]] - pricemit mit[m[t]]));

des1 = s'[t] ==   -(f[s[t]] - c[t] + mit[m[t]]);

dek1 = k'[t] == -(a[t] - \[Delta] k[t]);

dem1 = m'[t] == -(mit'[m[t]]/mit''[m[t]] (f'[s[t]] - (\[Rho] + h[s[t]]) - (\[Psi][k[t]]  h'[s[t]])/u'[c[t]] - (h'[s[t]] adj3[t])/u'[c[t]]));

deast1 = st3'[t] == -(-h[s[t]] st3[t]);

I use NDSolve as follows ;

nbsa = NDSolve[{dec1 /. paramFinal3, des1 /. paramFinal3, dea1 /. paramFinal3, dek1 /. paramFinal3, deadj1 /. paramFinal3, dem1 /. paramFinal3, deast1 /. paramFinal3, c[0] ==   49.8, s[0] == 126 , a[0] ==  0.0077, k[0] ==  4.1, adj3[0] == 65.2, m[0] ==330, st3[0] == 0}, {c[t], s[t], k[t], a[t], adj3[t], m[t], st3[t]}, {t, 0, 350}]

The code gives the following error ;

NDSolve::ndfdmc: Computed derivatives do not have dimensionality consistent with the initial conditions. >>

I looked on examples given on the site and MathematicaSE but none of them helped.

Thanks in advance.

4 Replies
Posted 8 years ago

With your revised code I include this extra line of code

Plot[{c[t], s[t], k[t], a[t], adj3[t], m[t], st3[t]} /. nbsa, {t, 0, 0.546}]

and evaluate thenotebook which gives one warning message

NDSolve::ndsz: At t == 0.5455485223604837`, step size is effectively zero; singularity or stiff system suspected. >>

and then this

enter image description here

I suspect this means that one of your denominators might be blowing up. Does that plot seem to behave the way your system should?

POSTED BY: Bill Simpson

Thanks so much, it was what I was looking for.

Posted 8 years ago

kk2 has not been assigned a constant numeric value prior to use in the NDSolve

POSTED BY: Bill Simpson

Sorry, I modified it with a constant numeric value.

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