# Tag Info

11

Some explanations first The substitution in the question introduces the reduced wave function $u(r)$ by solving the original radial equation in polar coordinates, $$-\frac{1}{2}\left(R''(r)+\frac {1}{r}R'(r)\right) - \frac{1}{r}R(r) + \frac {m^2}{2r^2}R(r) = E R(r)$$ using the ansatz $$R(r)\equiv \frac{1}{\sqrt{r}}u(r)$$ The apparently divergent ...

7

This might be useful if your actual event is more complicated, use a discrete variable as a flag: sols = NDSolve[{(1 + 25 Exp[-u[s]^2] u[s]^2) u'[s]^2 == u[s]^2, u[0] == 0.5, a[0] == 1, WhenEvent[u[s] == 4, a[s] -> 0], WhenEvent[a[s] == 0, "StopIntegration"] }, {u, a}, {s, 0, 20}, DiscreteVariables -> {a[s]}] u /. ...

5

The problem seems to be that you give the initial condition at a different point that your lower limit of the integration. If you change x1 by 0 things seem to work: (*INPUT*)MP = 1; m = 0.2 MP; c = Sqrt[3/2]; x1 = 0; x2 = 4000; (*ODE*) Clear[s2] Table[s2[i] = NDSolve[{y''[x] + c (Sqrt[m^2 y[x]^2 + y'[x]^2]) y'[x] + m^2 y[x] == 0, y[0] == ...

4

There is no solution to your equation. If you specify Reals for k Mathematica outputs an empty list as solution: NSolve[113.68/k + 1345.6/k^2*(1 - Exp[-k/11.6]) == -4.9, k, Reals] (*{}*) If you plot the righ and left hand side of the equation they don't cut each other: Plot[{113.68/k + 1345.6/k^2*(1 - Exp[-k/11.6]), -4.9}, {k, -60, 60}]

4

The corrected equation can be solved using FindRoot: FindRoot[(113.68 t/k - (1345.6/(k^2))*(1 - Exp[-k*t/11.6]) == -4.9 t^2) /. t -> 1, {k, 0.5}] (* {k -> 0.235142} *) This solves the equation for the value of $k$ corresponding to $t$ = 1 second. FindRoot requires an initial "guess" for the value of $k$; in this case, I've used $k = 0.5$. Other ...

4

I am not sure I understand the question 100% but here is what I think you are looking for: {vals3DL0, funs3DL0} = NDEigensystem[-(R''[r]/2) - (R'[r]/r) - (R[r]/r), R[r], {r, 0, 200}, 3, Method -> {"Eigensystem" -> {"Arnoldi", "Criteria" -> "RealPart"}, "SpatialDiscretization" -> {"FiniteElement", {"MeshOptions" -> \ ...

4

Changing parameter values during integration works better with DiscreteVariables. But I think the problem with OP's code, in the question and the OP's answer, has more to do with Mathematica numerics. My solution Clear[bind]; zdot = 1/2 (1 - z[t]); ydot = 1/20*y[t] + z[t] - x[t]; xdotbind = D[Solve[-ydot - zdot == 0, x[t]][[1, 1, 2]], t] /. {y'[t] -> ...

4

If you look at the FullForm of your variable result you will see that it contains some small complex numbers. You can remove these by using Plot[Abs[result[[i]]] instead.

3

Below is a workaround for the simple case. The OP can say whether it works more general. I haven't quite tracked down yet why the system is set up incorrectly with the default Method -> {"EquationSimplification" -> "Solve"} and with Method -> {"EquationSimplification" -> "Residual"}. But it works in this case with Method -> ...

3

soln = ParametricNDSolve[{x'[t] == -I a x[t] + I Sqrt[2] b y[t], y'[t] == I Sqrt[2] b x[t] + I Sqrt[2] b z[t], z'[t] == I Sqrt[2] b y[t] - I a z[t], x[0] == 1, y[0] == 0, z[0] == 0}, {x, y, z}, {t, 0, 20}, {a, b}] Plot[Through[{Re, Im}@#] & /@ {x[.1, .5][t], y[.1, .5][t], z[.1, .5][t]} /. soln, {t, 0, 10}, Evaluated -> True, ...

3

Equations use Equal (==) vice Set (=) eqns = {x'[t] == -I a x[t] + I Sqrt[2] b y[t], y'[t] == I Sqrt[2] b x[t] + I Sqrt[2] b z[t], z'[t] == I Sqrt[2] b y[t] - I a z[t], x[0] == 1, y[0] == z[0] == 0}; soln = DSolve[eqns, {x, y, z}, t][[1]] // FullSimplify {x -> Function[{t}, (4*b^2*E^((-I)*a*t - (1/2)*I* (a + Sqrt[a^2 ...

2

Thanks to those that responded. Applying the boundary in the pde as a formula is okay for simple geometries but for more complicated ones it is cumbersome. I have tried user21's first suggestion: bmesh = ToBoundaryMesh[DiscretizeGraphics[heatsink], "BoundaryMarkerFunction" -> (2 & /@ # &)]; emesh = ToElementMesh[bmesh]; ...

2

A bit long for a comment: What I'd do is split all polygons into quad elements and use those directly. Roughly like this: sidesback1 = Partition[Table[i, {i, 1, nodes}][[3 ;; -1]], 4]; sidesfront1 = Partition[Table[i, {i, nodes + 1, 2*nodes}][[3 ;; -1]], 4]; bmesh = ToBoundaryMesh["Coordinates" -> Join[face1, face2], "BoundaryElements" -> { ...

2

I'm on MMA 10.3 on OSX 10.10.5 Running your code indeed gives me the same result, a straight line. However this is not surprising to me as Evaluate[y /. nds] returns, unexpectedly, y Therefore in the plot we are plotting, y from 0 to 30, hence a straight line, gradient 1, from 0 to 30... Furthermore the syntax in your NDSolve is a little off to ...

2

So, after playing around with this problem all day, I finally stumbled upon a version of the code that gives me my desired result, although I'm not at all clear on why it works where other versions fail. First, here is the working version: zdot=.5*(1-z[t]); ydot=.05*y[t]+z[t]-x[t]; ...

2

happy fish ,he said "nth derivative is not natively supported" Yes it's true,but from here. Method1: For simple functions you can use InverseFourierTransform. f[s_] := Sin[s]; nthDeriv1[f_, s_, n_] := FullSimplify[InverseFourierTransform[(-I k)^n FourierTransform[f, s, k], k, s], {n \[Element] Integers, n > 0}] nthDeriv1[f[s], s, n] \sin ...

1

As suggested by the Documentation Center, you can remove excess (last 3) conditions. s = NDSolve[{D[u[x, t], t] == -D[u[x, t], x] - u[x, t], D[v[x, t], t] == -D[v[x, t], x] - v[x, t], D[w[x, t], t] == -D[w[x, t], x] - w[x, t], D[z[x, t], t] == -D[z[x, t], x] - z[x, t], u[x, 0] == 1, v[x, 0] == 1, w[x, 0] == 1, z[x, 0] == 1, u[0, t] ...

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