I have a second order differential equation that I'd like to solve numerically, and then integrate its solution twice to get the parametric equations of a curve. The ODE is:
$2 \kappa''(s)+\kappa^3(s)-\kappa(s)=0$
and the parametric equations are $x(s)=\int \cos (\theta(s))$ and $y(s)=1+\int \sin (\theta(s))$, where: $\theta(s)=\int \kappa(s) \ ds$.
I accomplish this by doing:
curve = NDSolve[{2 \[Kappa]''[s] + \[Kappa][s]^3 - \[Kappa][s] == 0, \[Kappa][0] == -1, \[Kappa][1] == 1}, \[Kappa], {s, 0, 1} ];]
\[Theta][t_?NumericQ] := NIntegrate[\[Kappa][s] /. First@curve, {s, 0, t}]
x[u_?NumericQ] := NIntegrate[Cos[\[Theta][t]], {t, 0, u}]
y[u_?NumericQ] := 1 + NIntegrate[Sin[\[Theta][t]], {t, 0, u}]
ParametricPlot[{x[u], y[u]}, {u, 0, 1}]
Question: How do I either fix the arclength of the curve or fix the end points of the curve at $x(1)=0$ and $y(0)=1$?
My first attempt was along the lines of this similar question: Solve differential equation using a integral form boundary condition with a solution by Jens. This eliminates one numerical integration, getting me closer to putting the boundary conditions into the initial NDSolve
. (Note: I've cleaned up the code with easier symbols, and a better way to incorporate the boundary conditions from MathX).
curve = ParametricNDSolve[{k'''[s] + 1/6 k'[s] k[s]^2 - 1/2 k'[s] == 0, k[0] == 0, k'[0] == bc0, k'[1] == bc1}, k, {s, 0, 1}, {bc0, bc1} ];
x[u_?NumericQ, a_?NumericQ, b_?NumericQ] := NIntegrate[Cos[k[a, b][t] /. curve], {t, 0, u}]
y[u_?NumericQ, a_?NumericQ, b_?NumericQ] := 1 + NIntegrate[Sin[k[a, b][t] /. curve], {t, 0, u}]
ParametricPlot[{x[u, -1, 1], y[u, -1, 1]}, {u, 0, 1}]
EDIT: I'm closer now by continuing the antiderivative procedure out to fourth order. Now I am able to fix $x(1)=0$, but not both $x(1)=0$ and $y(0)=1$:
curve = ParametricNDSolve[{k''''[s] + 1/12 k''[s] k[s] - 1/2 k''[s] == 0, k'[0] == 0, k[1] == 0, k''[0] == bc0, k''[1] == bc1}, k, {s, 0, 1}, {bc0, bc1} ];
Manipulate[Plot[Evaluate[k[-1, n][s] /. curve], {s, 0, 1}, PlotRange -> {{0, 1}, {-0.1, 1}}], {n, -1, 1.4, 0.05, Appearance -> "Labeled"}]
EDIT - Question Clarification: Imagine an elastic beam (say, a thin sheet of metal) bent into an arch. One end of the arch is fixed, and the other end of the arch is being twisted (about an axis orthogonal to the planar curve). The ODE above describes the beam's curvature along its length. In addition to boundary conditions that prescribe the beam's curvature at the fixed end and the twisting end, I am looking for a way to ensure that the beam's end points in $x$ and $y$ don't move, and/or that the beam doesn't change length.
x
andy
? $\endgroup$\[Kappa][1]
(which, in the code above is\[Kappa][1] == 1
). If you run the code for different values of\[Kappa][1]
, you'll see thatx[1]
varies, though I'd like it to remain fixed atx[1]==0
. $\endgroup$\[Kappa][0]
and\[Kappa][1]
, you can't specify any more boundary conditions. If, instead, you want to fix the end pointsx[1]
andy[0]
, you can't specify\[Kappa][0]
and\[Kappa][1]
. By the way, I think you meany[1]
, sincey[0]
is fixed at 1 by definition. Also, the arc length is fixed to be 1 by construction:Integrate[Sqrt[x'[s]^2+y'[s]^2],{s,0,1}] == 1
, so did you mean fixing the distance between the end pointsSqrt[(x[1]-x[0])^2+(y[1]-y[0])^2]
? $\endgroup$