When running the following code, I get the error message that "NIntegrate::inumr: The integrand ... has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,0.0695171}}". Can anyone help?
Here is the code:
ClearAll["Global`*"]
R0[S_] := Integrate[RC[s] - RA, {s, 0, S}];
V[s_, S_] := αh ((RC[s] + ph)^(-(ρ/σ)) + (αh/αz)^(-(ρ/σ)))^((1 - ρ)/ρ)*
(w - Tw + G + R0[S]/L - pf s - FC) ;
h[s_, S_] := (RC[s] + ph)^-σ/((αh/αz)^(-(ρ/σ)) + (RC[s] + ph)^(-(ρ/σ)))*
(w - Tw + G + R0[S]/L - pf s - FC);
sol[S_] = Solve[{D[V[s, S], s] == 0}, RC'[s]];
solprime = Equal @@@ Flatten[sol[S]];
αh = 0.2; αz = 0.2; γ = 5; ph = 0.01; pf = 1; Tw = 0.3; G = 2; FC = 0.1;
w = 1; ρ = 0.2; σ = 1/(1 - ρ); L = 1; RA = 0.1; S = 0.9;
solND = NDSolve[{solprime[[1]], RC[S] == RA}, RC, {s, 0, S}]
Plot[RC[s] /. solND, {s, 0, S}]
pop = NIntegrate[1/h[s, S] /. First[solND], {s, 0, S}];
I don't know what goes wrong here.
ADDED after Henrik Schumacher's comment:
ClearAll["Global`*"]
R0[S_] := Integrate[RC[s] - RA, {s, 0, S}];
P[s_, S_] := γ Integrate[(((αh/αz)^(-(ρ/σ))) + ((RC[x] + ph)^(-(ρ/σ))) )/
((RC[x] + ph)^-σ (w - Tw + G + R0[S]/L - (pf + tC) x - FC - TC)), {x, s, S}]
V[s_, S_] := αh ((RC[s] + ph)^(-(ρ/\[Sigma])) + (αh/αz)^(-(ρ/σ)))^((1 - ρ)/
ρ) (w - Tw + G + R0[S]/L - (pf + tC) s - FC - TC) - P[s, S] ;
h[s_, S_] := (RC[s] + ph)^-σ/((αh/αz)^(-(ρ/σ)) + (RC[s] + ph)^(-(ρ/σ)))*
(w - Tw + G + R0[S]/L - (pf + tC) s - FC - TC);
sol[S_] = Solve[{D[V[s, S], s] == 0}, RC'[s]];
solprime = Equal @@@ Flatten[sol[S]]
αh = 0.2; αz = 0.2; γ = 5; ph = 0.01; pf = 1; Tw = 0.3; G = 2; FC = 0.1;
tC = 0; TC = 0; w = 1; ρ = 0.2; σ = 1/(1 - ρ); L = 1; RA = 0.1; R0 = 1; S = 0.9;
solND = NDSolve[{solprime[[1]], RC[S] == RA}, RC, {s, 0, S}]
pop = NIntegrate[1/h[s, S] /. First[solND] /. Integrate -> NIntegrate, {s, 0, S}]
This gives me the same error message.