[MATLAB] Modeling response of a particle in an anharmonic potential

In summary, your goal is to model the response of a particle in an anharmonic potential. You know that writing position, x as a function of potential energy U is,where T is the period, m is mass, and E is the energy of the system. However, you're not sure if the equation of motion is correct. You can solve the second order differential equation numerically, but you'll need to define the initial conditions first.
  • #1
baouba
41
0
I'm trying to model the response of a particle in an anharmonic potential in MATLAB. I know that writing position, x as a function of potential energy U is,

upload_2015-4-8_16-54-10.png


where T is the period, m is mass, and E is the energy of the system. How would I get a function for T(E) since it's not independent of amplitude obviously. As a starting point, I'm using the anharmonic potential of

upload_2015-4-8_17-0-7.png

Where a and b are constants. Does anybody know how I could program this in matlab?

Thanks
 
Physics news on Phys.org
  • #3
Yes my goal is to plot a potential vs. displacement curve. Is this even possible considering the number of functions in the first equation above?
Here's some of my code: For simplicity, I assume period T(E) = 1%Define Functions

%For a,b = 1

%U = ax^2 + bx^3

%Assuming T(E) = 1
U = @(x) x^2+x^3

fun = @(E,U) T/(sqrt(U-E))^-1

int = @(E) integral(fun,0,U)

ezplot('(-x+(sqrt(2)*2*pi)^-1)*int')
 
  • #4
I think something like this is a step closer, but I'm not convinced it's correct yet.

Code:
a=1;
b=1;
T=1;
U = @(x) a*x.^2 + b*x.^3;
A = (2*pi*sqrt(2))^-1;
I = [];

for n =0:0.1:10
  fun = @(E) T./(sqrt(U(n)-E));
  I = [I, A*integral(fun,0,U(n))];
end

plot(0:0.1:10, I)

The difference here is that I loop through possible values for U and evaluate the integral once for each one.
 
  • #5
Thank you I'll try it. I'm wondering if it would be more beneficial/ shed more light if I plotted x as a function of time. In that case I solved lagrange
L = K - U = .5mv^2 - x^2 - x^3 since U = x^2 + x^3
the associated equation of motion is then ma = -3x^2 - 2x
I would then need to solve this differential equation to plot x(t). However I put this equation into wolfram alpha, and got a massive expression out and it makes me thing that it might not be possible to model this response.

Is this the case?
 
  • #6
You can solve the second order differential equation numerically in MATLAB. Since the ODE functions only work with first order equations, you'll have to rewrite this second order equation

[tex]
m \frac{d^2 x}{dt^2} = -3x^2-2x
[/tex]

As an equivalent system of first order equations,

[tex]
m \dot{y_2} = -3y_1^2-2y_1
[/tex]
[tex]
y_2 = \dot{x}
[/tex]
[tex]
y_1 = x
[/tex]

You'll also need to define the initial conditions of the problem.

Take a look at the examples here:
http://www.mathworks.com/help/matlab/ref/ode45.html

Save the following function file, which defines the equations above (assume m=1):
Code:
function dy = anharmonic(t,y)
  dy = zeros(2,1);
  dy(1) = y(2);
  dy(2) = -3*y(1).^2 - 2*y(1);
end

Then set the time span and initial conditions before calling ode45:
Code:
tspan = [0 15];
y0 = [0; 0.25];
[t,y] = ode45(@anharmonic, tspan, y0);
plot(t,y(:,1),t,y(:,2))
legend('Position','Velocity')

?temp_hash=9239f5d362fbcfce69e50037841c7f57.png


You might want to check my work, because the plot looks more harmonic than anharmonic to me.
 

Attachments

  • anharmonic.png
    anharmonic.png
    10.5 KB · Views: 674
Last edited:

1. What is MATLAB?

MATLAB is a high-level programming language and interactive environment commonly used by scientists and engineers for data analysis, mathematical modeling, and technical computing.

2. What is an anharmonic potential?

An anharmonic potential is a type of potential energy function that describes a non-linear relationship between the position and energy of a particle. It is often used to model the behavior of particles in complex systems, such as molecules or atoms.

3. How can MATLAB be used to model the response of a particle in an anharmonic potential?

MATLAB has built-in functions and tools that allow for the creation and manipulation of mathematical models, making it a powerful tool for modeling the behavior of particles in an anharmonic potential. By defining the potential function and using numerical methods, such as Euler's method or Runge-Kutta methods, MATLAB can simulate the particle's motion and plot its response.

4. What are the benefits of using MATLAB for modeling the response of a particle in an anharmonic potential?

MATLAB offers a user-friendly and versatile platform for modeling complex systems like particles in an anharmonic potential. It has a wide range of built-in functions and tools for mathematical modeling, data analysis, and visualization, making it a comprehensive tool for scientists and engineers. Additionally, MATLAB allows for easy manipulation and modification of the model, allowing for quick and efficient testing of different scenarios.

5. Are there any limitations to using MATLAB for modeling the response of a particle in an anharmonic potential?

While MATLAB is a powerful tool for modeling, it has its limitations. One limitation is that it can only simulate the behavior of particles in an anharmonic potential and cannot provide physical experiments or real-world data. Additionally, MATLAB may not be the most efficient software for large-scale simulations, as it may require significant computational resources.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
802
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
985
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top