Numerical variational problem

  • Thread starter Catria
  • Start date
  • Tags
    Numerical
In summary, the conversation is about trying to find the trajectory that minimizes a given Lagrangian between two points, using the polar-coordinate Euler-Lagrange equation. The integrand of the functional and the variables involved are defined, and a Mathematica code is provided for solving the problem. However, the code encounters an error message due to the stiffness of the system.
  • #1
Catria
152
4

Homework Statement



Here I am, trying to get the trajectory $(x(t),y(t))$ that will minimize the following Lagrangian (i.e. the integrand of the functional) between $(-1,-1)$ and $(-1,y_{eff})$ where $x_{eff}$ is defined as the point where $V(x_{eff},-1)=V(-1,-1),x<0$.

So here's the integrand of the functional:

$L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t))$

with $V(x(t),y(t))$ defined as follows:

$(x(t)^2-1)^2(x(t)^2-\delta_1)+\frac{(y(t)^2-1)^2-\frac{\delta_2}{4}(y(t)-2)(y(t)+1)^2}{x(t)^2+\gamma}$

and

$x(0.0001)=-1=y(0.0001)$

$x(10)=x_{eff},y(10)=-1$

Homework Equations



The polar-coordinate Euler-Lagrange equation

The Attempt at a Solution



Code:
Needs["VariationalMethods`"];
gamma = 0.1;
delta1 = 0.1;
delta2 = 0.1;
tmin = 0.0001;
tmax = 10;
V[x[t_], y[
    t_]] := (x[t]^2 - 1)^2 (x[t]^2 - 
      delta1) + ((y[t]^2 - 1)^2 - (delta2 (y[t] - 2) (y[t] + 1)^2)/
       4)/(x[t]^2 + gamma);
U[x_, y_] := (x^2 - 1)^2 (x^2 - delta1) + ((y^2 - 1)^2 - 
      delta2 (y - 2) (y + 1)^2/4)/(x^2 + gamma);
ftn = 2*Pi*
  t (1/2 (D[x[t], t]^2 + D[y[t], t]^2) + 
    V[x[t], y[t]]); (* Le Lagrangien *)
Veff[x_] := U[x, -1];
x0 = x /. FindRoot[Veff[x] == U[-1, -1], {x, -0.2}]
sln = EulerEquations[ftn, {x[t], y[t]}, t]
solution = 
  NDSolve[{sln, x[tmin] == -1, y[tmin] == -1, x[tmax] == x0, 
    y[tmax] == -1}, {x[t], y[t]}, {t, tmin, tmax}];
psi[t_] = x[t] /. solution[[1, 1]];
phi[t_] = y[t] /. solution[[1, 2]];
NIntegrate[
 t (1/2 (D[psi[t], t]^2 + 
       D[phi[t], t]^2) + ((psi[t]^2 - 1)^2 (psi[t]^2 - 
         delta1) + ((phi[t]^2 - 1)^2 - 
         delta2 (phi[t] - 2) (phi[t] + 1)^2/4)/(psi[t]^2 + 
         gamma))), {t, tmin, tmax}]
Plot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]
ParametricPlot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]

But, when I run that piece of Mathematica code, I run into an error message:

Code:
NDSolve::ndsz: At t == 0.004410099463404809`, step size is effectively zero; singularity or stiff system suspected.

Because of the stiffness of the system the numerical solution has a strange behavior...
 
Physics news on Phys.org
  • #2
Catria said:

Homework Statement



Here I am, trying to get the trajectory $(x(t),y(t))$ that will minimize the following Lagrangian (i.e. the integrand of the functional) between $(-1,-1)$ and $(-1,y_{eff})$ where $x_{eff}$ is defined as the point where $V(x_{eff},-1)=V(-1,-1),x<0$.

So here's the integrand of the functional:

$L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t))$

with $V(x(t),y(t))$ defined as follows:

$(x(t)^2-1)^2(x(t)^2-\delta_1)+\frac{(y(t)^2-1)^2-\frac{\delta_2}{4}(y(t)-2)(y(t)+1)^2}{x(t)^2+\gamma}$

and

$x(0.0001)=-1=y(0.0001)$

$x(10)=x_{eff},y(10)=-1$

Homework Equations



The polar-coordinate Euler-Lagrange equation

The Attempt at a Solution



Code:
Needs["VariationalMethods`"];
gamma = 0.1;
delta1 = 0.1;
delta2 = 0.1;
tmin = 0.0001;
tmax = 10;
V[x[t_], y[
    t_]] := (x[t]^2 - 1)^2 (x[t]^2 - 
      delta1) + ((y[t]^2 - 1)^2 - (delta2 (y[t] - 2) (y[t] + 1)^2)/
       4)/(x[t]^2 + gamma);
U[x_, y_] := (x^2 - 1)^2 (x^2 - delta1) + ((y^2 - 1)^2 - 
      delta2 (y - 2) (y + 1)^2/4)/(x^2 + gamma);
ftn = 2*Pi*
  t (1/2 (D[x[t], t]^2 + D[y[t], t]^2) + 
    V[x[t], y[t]]); (* Le Lagrangien *)
Veff[x_] := U[x, -1];
x0 = x /. FindRoot[Veff[x] == U[-1, -1], {x, -0.2}]
sln = EulerEquations[ftn, {x[t], y[t]}, t]
solution = 
  NDSolve[{sln, x[tmin] == -1, y[tmin] == -1, x[tmax] == x0, 
    y[tmax] == -1}, {x[t], y[t]}, {t, tmin, tmax}];
psi[t_] = x[t] /. solution[[1, 1]];
phi[t_] = y[t] /. solution[[1, 2]];
NIntegrate[
 t (1/2 (D[psi[t], t]^2 + 
       D[phi[t], t]^2) + ((psi[t]^2 - 1)^2 (psi[t]^2 - 
         delta1) + ((phi[t]^2 - 1)^2 - 
         delta2 (phi[t] - 2) (phi[t] + 1)^2/4)/(psi[t]^2 + 
         gamma))), {t, tmin, tmax}]
Plot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]
ParametricPlot[{psi[t], phi[t]}, {t, tmin, tmax}, PlotRange -> All]

But, when I run that piece of Mathematica code, I run into an error message:

Code:
NDSolve::ndsz: At t == 0.004410099463404809`, step size is effectively zero; singularity or stiff system suspected.

Because of the stiffness of the system the numerical solution has a strange behavior...

For inline equations, use either [i tex] xxxx [/i tex] (no spaces between i and t), or else # # xxx # # (no spaces betweent the two #s). For displayed equations, use [t ex] equations [/t ex] (no spaces between t and e). For example, ##V(x_{eff},-1)=V(-1,-1),x<0## and
[tex] L=\frac{1}{2}((\partial_tx)^2+(\partial_ty)^2)-V(x(t),y(t)).[/tex]
 

1. What is a numerical variational problem?

A numerical variational problem is a mathematical optimization problem that involves finding the minimum value of a functional (a mathematical mapping from a set of functions to the real numbers) by solving a system of equations numerically. This method is used in various fields, including physics, engineering, and economics, to model and solve complex problems.

2. How is a numerical variational problem different from a traditional optimization problem?

A traditional optimization problem usually involves finding the minimum or maximum value of a function by finding its derivative and setting it equal to zero. However, a numerical variational problem involves finding the minimum value of a functional, which may be defined as an integral of a function. This requires a different approach and may involve solving a system of equations rather than finding a single derivative.

3. What are some common methods for solving numerical variational problems?

Some common methods for solving numerical variational problems include the finite element method, the finite difference method, and the boundary element method. These methods involve discretizing the problem domain and solving the resulting system of equations numerically to find the minimum value of the functional.

4. What types of problems can be solved using numerical variational methods?

Numerical variational methods can be applied to a wide range of problems, including structural analysis, heat transfer, fluid dynamics, and electromagnetics. These methods are particularly useful for problems with complex boundaries or material properties, as they can handle non-uniform and anisotropic conditions.

5. What are the advantages of using numerical variational methods?

One of the main advantages of numerical variational methods is their ability to handle complex and non-linear problems. These methods are also versatile and can be applied to a wide range of problems in different fields. Additionally, they can provide accurate solutions with relatively low computational costs, making them efficient for solving large-scale problems.

Similar threads

  • Calculus and Beyond Homework Help
Replies
2
Views
165
  • Calculus and Beyond Homework Help
Replies
3
Views
900
  • Calculus and Beyond Homework Help
Replies
8
Views
607
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
  • Calculus and Beyond Homework Help
Replies
10
Views
2K
  • Calculus and Beyond Homework Help
Replies
5
Views
616
  • Calculus and Beyond Homework Help
Replies
9
Views
1K
  • Calculus and Beyond Homework Help
Replies
3
Views
547
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
2
Views
2K
Back
Top