3
$\begingroup$

I wrote code solving the frenet equations in 2D analytically (so only curvature and no torsion) and plotting the curve with local coordinates afterwards. For constant curvature kappa it functions just fine, and gives out circles. But every other curvature just gives back the arguments given instantaniously, like MMA doesn't even try solving the problem. Any thoughts on how to fix this?

I am really new to MMA but would have thought that simple curvatures should be solvable.

Thanks!

This is the code:

ClearAll[\[Kappa], \[Tau], t, n, r, s, plist, a, b, f, F, x, y, t1, \
t2, n1, n2, sol, rearr, kap]
a = -10;
b = 10;
(*t[s_]={t1[s],t2[s]};
n[s_]={n1[s],n2[s]};
r[s_]={r1[s],r2[s]};
*)
r[s_] = {x[s], y[s]}(*{{t1[s],t2[s]},{n1[s],n2[s]},{r1[s],r2[s]}}*);
t[s_] = {t1[s], t2[s]};
n[s_] = {n1[s], n2[s]};
kap[s_] := 1;

system = {
   t1'[s] == kap[s] n1[s],
   t2'[s] == kap[s] n2[s],
   n1'[s] == -kap[s] t1[s],
   n2'[s] == -kap[s] t2[s],
   x'[s] == t1[s],
   y'[s] == t2[s],
   t1[a] == 1,
   t2[a] == 0,
   n1[a] == 0,
   n2[a] == 1,
   x[a] == 0,
   y[a] == 0};

sol = DSolve[
  system,
  {t1, t2, n1, n2, x, y},
  s]
t[s_] = t[s] /. {sol[[1, 2]], sol[[1, 5]]};
n[s_] = n[s] /. {sol[[1, 1]], sol[[1, 4]]};
r[s_] = r[s] /. {sol[[1, 3]], sol[[1, 6]]};


Manipulate[With[{scale = 0.5},
  Show[ParametricPlot[r[s], {s, a, b}], 
   Graphics[{{Directive[Red], 
      Arrow[{r[s], scale t[s] + r[s]}]}, {Directive[Blue], 
      Arrow[{r[s], scale n[s] + r[s]}]}}, 
    PlotRange -> Full]]], {{s, (a + b)/2}, a, b, .001}]

One can change the domain with a and b and the given curvature with kap[s_].

Also for some reason Dsolve seems to give out (t1,...,y) in different orders depending on kap[s_], this is why the plotting will fail for no-constant curvature.

$\endgroup$

2 Answers 2

1
$\begingroup$

Replace the definition of sol and t,n,r by:

sol = DSolve[system, {t1, t2, n1, n2, x, y}, s][[1]]
t[s_] = t[s] /. sol;
n[s_] = n[s] /. sol;
r[s_] = r[s] /. sol;


Manipulate[
 With[{scale = 0.5}, 
  Show[ParametricPlot[r[s], {s, a, b}], 
   Graphics[{{Directive[Red], 
      Arrow[{r[s], scale  t[s] + r[s]}]}, {Directive[Blue], 
      Arrow[{r[s], scale  n[s] + r[s]}]}}, 
    PlotRange -> Full]]], {{s, (a + b)/2}, a, b, .001}]

Then for e.g.: kap[s_] := s;you get:

enter image description here

$\endgroup$
3
  • $\begingroup$ Thank you so much for your effort! But it doesn't seem to work for me. Dsolve still outputs just the input and thus the plot fails, sind t,n,r can't be replaced. Did maybe you change something about system as well? $\endgroup$ Commented Jan 18 at 11:18
  • 2
    $\begingroup$ I replaced ` kap[s_] := 1;` in your code by kap[s_] := s;. And the code from sol= ..to the end. I checked it again and it works for me. The problem may be the version of MMA I checked it with 13.3 and 14. $\endgroup$ Commented Jan 18 at 13:03
  • $\begingroup$ hmm, i will try to check a newer version of MMA $\endgroup$ Commented Jan 18 at 14:29
1
$\begingroup$
  • It is recommand to use NDSolve since even if we set kap[s_]=s, Mathematica 11 and 12 still can not solve it. Here we set kap[s_] := s^2 + Sin[s] + 1;.
  • We can also avoid using component notation of vectors.
Clear["Global`*"];
a = -10;
b = 10;
kap[s_] := s^2 + Sin[s] + 1;
system = {t'[s] == kap[s]*n[s], n'[s] == -kap[s]*t[s], r'[s] == t[s], 
   r[a] == {0, 0}, t[a] == {1, 0}, n[a] == {0, 1}};
sol = NDSolve[system, {t, n, r}, {s, a, b}];
{t, n, r} = {t, n, r} /. sol[[1]];
Manipulate[
 With[{scale = 0.5}, 
  Show[ParametricPlot[r[s], {s, a, b}, PerformanceGoal -> "Quality"], 
   Graphics[{{Directive[Red], 
      Arrow[{r[s], scale   t[s] + r[s]}]}, {Directive[Blue], 
      Arrow[{r[s], scale   n[s] + r[s]}]}}, 
    PlotRange -> Full]]], {{s, (a + b)/2}, a, b, .001}]

enter image description here

  • If we use v13 or v14, we can also simplify the code by using Matrices.
Clear["Global`*"];
a = -10;
b = 10;
κ[s_] := s;
sol = 
 DSolve[{v'[
     s] == {{0, 1, 0}, {0, 0, κ[s]}, {0, -κ[s], 0}} . 
     v[s], v[a] == {{0, 0}, {1, 0}, {0, 1}}}, 
  v ∈ Matrices[{3, 2}], {s}];
{r[s_], t[s_], n[s_]} = v[s] /. sol[[1]];
Manipulate[
 With[{scale = 0.5}, 
  Show[ParametricPlot[r[s], {s, a, b}, PerformanceGoal -> "Quality"], 
   Graphics[{{Directive[Red], 
      Arrow[{r[s], scale   t[s] + r[s]}]}, {Directive[Blue], 
      Arrow[{r[s], scale   n[s] + r[s]}]}}, 
    PlotRange -> Full]]], {{s, (a + b)/2}, a, b, .001}]
$\endgroup$
1
  • $\begingroup$ I already have working code for the numerik solution, which works just fine. I will try getting my hands on a later version of MMA. But thanks for the tips with the matricies $\endgroup$ Commented Jan 18 at 14:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.