I am using NDSolve to solve the two equations:
func[x_, t_] := ((v[x, t] - 9/100)*(1 + u[x, t]) - 1/2*u[x, t])/u[x, t]; equ = D[u[x, t], t] - 1/20*func[x, t] + D[u[x, t]^3*(D[u[x, t], x] + D[u[x, t], {x, 3}]), x] == 0; eqv = D[v[x, t], t] + u[x, t]^2/2*(3*D[u[x, t] + D[u[x, t], {x, 2}], x])*D[v[x, t], x] - 1/10*D[v[x, t], {x, 2}] == (1 - v[x, t])*(func[x, t]^2 - (1/10*Log[(1 - v0)/(1 - v[x, t])])^2); with the parameters and trial code (it takes about 30s on my i5 laptop):
L = 10 \[Pi]; c = 1/40; v0 = 1/5; tmax = 200; eqns = {equ, eqv, u[0, t] == u[L, t], v[0, t] == v[L, t], u[x, 0] == 1 + c*Cos[x], v[x, 0] == 1/10}; {solnu, solnv} = NDSolveValue[eqns, {u, v}, {x, 0, L}, {t, 0, tmax}] By plotting the solution, we found that after $t>100$, the solutions begin to disappear partially (see red lines for $t=101$):
Plot[{solnu[x, 0], solnu[x, 50], solnu[x, 100], solnu[x, 101]}, {x, 0, L}, PlotRange -> {{0, L}, All}, ImageSize -> 400, PlotPoints -> 80, Frame -> True, Axes -> False, AspectRatio -> 0.4, PlotStyle -> {Black, Green, Blue, Red}] Plot[{solnv[x, 0], solnv[x, 50], solnv[x, 100], solnv[x, 101]}, {x, 0, L}, PlotRange -> {{0, L}, All}, ImageSize -> 400, Frame -> True, Axes -> False, AspectRatio -> 0.4, PlotStyle -> {Black, Green, Blue, Red}] My thought:
By evaluating the functions at a certain position, say, $x=4$, I can understand that the disappearance of the solutions is because the solutions become complex numbers as $t$ increases.
Table[solnu[4, tn], {tn, 0, tmax, 20}] (*{0.983661, 0.894927, 0.873114, 0.859587, 0.853879, 0.828441, 0.729746 - 0.0799211 I, 0.291994 + 0.0356712 I, 0.170041 - 0.089365 I, 0.166466 - 0.0930112 I, 0.166531 - 0.0929651 I}*) Table[solnv[4, tn], {tn, 0, tmax, 20}] (*{0.1, 0.313017, 0.316713, 0.316615, 0.315822, 0.432728, 0.999884 - 0.000152834 I, 0.781819 - 0.00317719 I, 0.999983 - 5.23657*10^-6 I, 1. - 1.08127*10^-7 I, 1. - 6.74084*10^-8 I}*) In my problem, I need the solutions to be real over the entire domain. I suspected that the solutions with the imaginary parts result from the last term, Log[(1 - v0)/(1 - v[x, t])], of the 2nd equation, because the Log function itself has the domain of definition to be a real function. In addition, the function v[x, t] should not be larger than $1$, which is a physical constraint. See also the lower fig, the curves of solnv begin to vanish as the peak approaches to $1$).
My first question is:
Is it possible to add a physical constraint of 0<v[x, t]<=vlim[x,t] in the code to make the solution reasonable? Here, vlim[x, t] is determined by the solutions:
vlim[x_, t_] := Exp[4800*(1/350 - solnu[x, t]/((solnv[x, t] - 1/10)*solnu[x, t]))]; Or, is it acceptable if I only take the solutions before they vanish (i.e. $t\le 100$). In other words, is it equivalent to the constraint if one only takes the solutions from the current code, which still satisfy the constraint (e.g. by checking v[x, t])?
If you think there is something wrong with my idea, please also leave your comments and suggestion.
My second problem (solved by @Alx):
By defining a function based on the solutions, I need to numerically integrate the function at a given time, say, $t=50$. But NIntegrate runs for a very long time ... (aborted by myself). Please help me with defining such a function and then NIntegrate it correctly. Thank you in advance!
funcSol[x_, t_] := ((solnv[x, t] - 1/10)*(1 + solnu[x, t]) - solnu[x, t])/solnu[x, t]; NIntegrate[funcSol[x, 50], {x, 0, L}] 













funcSol[x_?NumericQ, t_?NumericQ]:= ...so thatNIntegratewill get numerical input as it expects. $\endgroup$1canvbecome? $\endgroup$Log[Abs[(1 - v0)/(1 - v[x, t])]]$\endgroup$