# Tag Info

## Hot answers tagged differential-equations

9

Since a fully NDSolve-based solution is acceptable for you, let me give you one. You simply need the magic of "Pseudospectral": mol[n_, o_:"Pseudospectral"] := {"MethodOfLines", "SpatialDiscretization" -> {"TensorProductGrid", "MaxPoints" -> n, "MinPoints" -> n, "DifferenceOrder" -> o}} ic[θ_] = Piecewise[{{1.001, -2 Pi/3 < θ < -...

8

Setup The region to solve the PDEs Clear["Global*"] xMax = 453.595 - Sqrt[450.05^2 - 3^2]; regA = Rectangle[{0, 0}, {xMax, 6}]; regB = ImplicitRegion[{453.595 - Sqrt[450.05^2 - (y - 3)^2] - x < 0}, {{x, 0, xMax}, {y, 0, 6}}]; reg = RegionDifference[regA, regB]; RegionPlot[reg, AspectRatio -> 1/10] Solve the PDEs using NDSolve solV = ...

7

Alternatively, you can use Needs["NDSolveFEM"] \[CapitalOmega] = ToElementMesh[ RegionDifference[Rectangle[{0, 0}, {100, 100}], Rectangle[{40, 40}, {60, 60}]], MaxCellMeasure -> {"Area" -> 1}] This will generate a second order mesh and you'll need far fewer elements to get an accurate solution then with a first order mesh (as ...

4

One can use the new function DistanceMatrix[] for the purpose; this avoids repeated computations (since the underlying matrix is symmetric). With[{stepSize = 2, end = TMax}, MatrixPlot[UnitStep[0.01 - DistanceMatrix[uSolpbc[Range[0, end, stepSize], 0]]]]] and your plot is produced very quickly, without the need to invoke parallelization.

3

Using DiscretizeRegion[] with RegionDifference[] prior to NDSolveValue was the key. Ω = DiscretizeRegion[ RegionDifference[Rectangle[{0, 0}, {100, 100}], Rectangle[{40, 40}, {60, 60}]], Method -> "Continuation", AccuracyGoal -> 7, PrecisionGoal -> 7, MaxCellMeasure -> {"Area" -> 0.1}]; sol = NDSolveValue[{D[u[x, y], x, x] + ...

3

This turns out to be a bug since v9. v8.0.4 gives the correct result: $Version eqn = D[x[t], t] == a*x[t] + c*t^n; bc = x[0] == x0; sol = Simplify[DSolve[{eqn, bc}, x[t], t], {a > 0, n >= 1, c > 0}] (* "8.0 for Microsoft Windows (64-bit) (October 24, 2011)" *) (* {{x[t] -> a^(-1 - n) E^(a t) (a^(1 + n) x0 + c Gamma[1 + n] - c Gamma[1 + n, a t])}}... 2 Let's read the error message: NDSolveIterate::ndsz: At t == -1.*10^10, step size is effectively zero; singularity or stiff system suspected. The "step size is effectively zero" means that in floating-point arithmetic t + dt is equal to t for the computed time step dt. If this is the problem, increasing working precision might help. de = {F'[t] == -(... 2 I have experienced serious memory leaks with NDSolve, NIntegrate, and FindRoot in every version of Mathematica I have owned (still on V9), perhaps over 20 years. They typically show up for me when the routine is called at a deep level in a complex program. The only cure in many cases is to remove the offending routine and write your own. For NIntegrate, ... 2 Making my comment an answer: Try to extract the mesh from the eigenfunction and use that for integration. Something like: NIntegrate[ circlepluck[x, y]*circlefuncs[[i]][x, y], {x, y} \[Element] circlefuncs[[1]]["ElementMesh"]] This would switch off the adaptive mesh refinement. 2 No, that's not possible. If you could show your code there might be other ways to speed it up. 2 ClearAll["Global*"] Remove["Global*"] {ysol, xsol} = ParametricNDSolve[{x'[t] == x[t] + g*x[t]*y[t], y'[t] == 1 - 2*x[t]^2 - g*y[t]^2, x[1] == 1, y[1] == 1}, {y, x}, {t, 0, 10}, {g}]; ParametricPlot[Evaluate@Table[{y[g][t] /. ysol, x[g][t] /. xsol}, {g, 0, 1, 1/4}], {t, 0, 2}, PlotRange -> {{-3, 3}, {-3, 3}}, PlotLegends -> {"g=1/4", "g=2/4", "g=... 2 An alternative approach is to solve for t[x] instead of x[t]. t[x] /. First@DSolve[t'[x] == 1/(5 x^4 + 3 x^(-4/3)), t[x], x] /. C[1] -> 0; ParametricPlot[{Chop@%, x}, {x, 0, 3}, AxesLabel -> {t + C[1], x}, AspectRatio -> GoldenRatio] Because the ODE determines t[x] only up to an arbitrary constant, the curve above can be shifted by an ... 2 Maybe like this: sol = DSolve[x'[t] == 5 x[t]^4 + 3 x[t]^(-4/3), x[t], t] eq = sol[[1, 1, 2, 0, 1]][x] == (sol[[1, 1, 2, 1]] /. C[1] -> 2) ContourPlot[sol[[1, 1, 2, 0, 1]][x] == (sol[[1, 1, 2, 1]] /. C[1] -> 2), {t, -3, 3}, {x, -3, 3}, Axes -> True, Frame -> False, AxesLabel -> {t, x[t]}] EDITED: If You exectue this code: Internal`... 2 Your initial and boundary conditions are inconsistent. Check NDSolve::ibcinc how to avoid that. Also I think you need additional boundary condition. Anyway I'm not sure your constant functions are good for boundary/initial conditions. The r domain includes zero and it gives error in your$1/r\$ term. Using the recipe from above link and adding another ...

2

The plot in the question must have been obtained with stepSize = 15, not stepSize = 2. Using the latter value gives a smooth plot, The computation takes about 78 sec on my PC. To address the specific issue in the question, the run time can be reduced by two orders of magnitude using Block[{stepSize = 2, end = TMax, tt, rd}, tSolpbc = Table[uSolpbc[...

1

Your problem is twofold. The first part is very subtle and sneaky. Your "c" characters are actually typed in as the Unicode Character 'cyrillic small letter es' (U+0441) in the NDSolve expression, as you can see from the following: Inactive[NDSolve][{ I*с00'[t] == с10[t] + с01[t] + с00[t] + с00[t], I*с01'[t] == с11[t] + с00[t] + с01[t] - с01[t], ...

1

Thank for the help with @xzczd ，I want to post a possible answer. The code is kp = 2; vm = 311; w = 100*Pi; k = 1; ki = 100; nsol = NDSolveValue[{y''[ x] + (kp*vm*Cos[w*x - y[x]] - 2/3 kp*k*vm*Cos[w*x] Cos[y[x]]) y'[x] - ki*vm*Sin[w*x - y[x]] - 2/3 ki*k*vm*Cos[w*x] Sin[y[x]] - kp*vm*w*Cos[w*x - y[x]] == 0, y[0] == 0, y'[0]...

Only top voted, non community-wiki answers of a minimum length are eligible