Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am trying to solve a system of nested differential equations, and have attached my code below. The first section is some variable declarations, then I solve my first diffeq and store the solution to s. Then I make another function evaluated with that solution, and try to use it in another diffeq, but I get the error

"Computed derivatives do not have dimensionally consistent with the initial conditions".

ClearAll["Global`*"];
falltime = 5*^-12;
Rd[t_] := 200000000000*E^(-t/falltime) + 1300;

Vc = 5; Va = -200; Rl = 220; Rs = 1000000; Ccs = 2*^-12; Cas = 2*^-12; Cac = 2*^-12;

eq1 = (Vc-V1[t])/Rl == (V1[t]-V2[t])/Rd[t] + Ccs*(V1'[t] - V2'[t]);
eq2 = Cac*(V1'[t]-V2'[t]) + (V1[t]-V2[t])/Rd[t] == (V2[t]-Va)/Rs + V2'[t];
eq3 = V2[0] == (Va*(Rd[0] + Rl) + Rs*Vc)/(Rd[0] + Rl + Rs);
eq4 = V1[0] == (Va*Rl + Vc (Rd[0] + Rs))/(Rd[0] + Rl + Rs);

s = NDSolve[{eq1, eq2, eq3, eq4}, {V1[t], V2[t]}, {t, 0, 100*^-9}];


IdRd[t_] := Evaluate[{(V1[t] - V2[t])/Rd[t]} /. s];  (* Current through Rd *)

qt = 10*^-9; \[Tau]q = .2*^-9; Lifetime1 = 50;

IdQuenched[t_] := IdRd[t]*(UnitStep[t] - (UnitStep[t - qt]*(1 - E^-((t - qt)/\[Tau]q))));

s1 = NDSolve[{n'[t] == (IdQuenched[t]/(1.602*^-19)) - (n[t]/(Lifetime1*1*^-9)), 
              n[0] == 0.0000000000001},n[t], {t, 0, 1*^-6}]

I'm really not sure where to go from here and would appreciate any help.

share|improve this question
    
From a glance it looks like you only solve s up to 90% of the interval you later evaluate it in. I suggest you condense your example to the bare minimum you have a problem with, that makes it easier to help. –  ssch Sep 25 '13 at 17:37
    
And IdQuenced[1*^-10] returns {{0.119404}} and not 0.119404 I presume that's where the error stems from –  ssch Sep 25 '13 at 17:40
    
Well so for my application s is a current, which is 'quenched' and shut off. So, in S, I solve for the initial decaying exponential form of the current. Then, when I declare IdQuenched, I multiply it by a couple unitsteps and another exponential, which is defined all the way out to 1*^-6. So I'm not sure it'll make a difference, but I'll give it a try. Also, I tried Flatten on the result from IdQuenched ... shouldn't that put it in the form I need? Sorry, pretty new to Mathematica. –  Michael Wayne Sep 25 '13 at 18:40
    
Ok solved. Your earlier note about only evaluating for 10% of the time was a problem, and I fixed it by extending the evaluation of s out to 1 us. The other issues arose with an unneeded curly bracket set in the declaration of IdRd[t_], which created a list inside a list. Then to put it in usable form for s1, I just replaced IdQuenched[t] with IdQuenched[t][[1]] to access the first element of the list, which reduced {{0.119404}} to 0.119404. Thank you for your help. –  Michael Wayne Sep 25 '13 at 18:57
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.