Plotting Phase Portrait of Duffing Equation
I study a paper that describes a stationary problem where the function satisfies the boundary conditions and is governed by a modified Laplace equation with a non-linear term. Here’s a breakdown of the equations and the conditions they represent:
1. Equation Details:
– The first equation:
This is a partial differential equation (PDE) where denotes the Laplacian in dimensions. The equation includes a linear term proportional to and a non-linear term proportional to . The parameter seems to modulate the influence of the spatial derivatives, while and scale the linear and non-linear terms, respectively.
Boundary conditions:
These conditions specify that $ Phi $ is zero at the boundaries of the domain.
2. Special Case (Non-coupled Particles, 🙂
In the limit $ k = 0 $, the spatial derivative terms disappear, simplifying the equation to:
Here, seems to represent the state of a system described by the Duffing equation, which is a well-known model for non-linear oscillators with a cubic nonlinearity. The term introduces damping into the system, representing energy loss.
Here’s the Matlab code for simulating and visualizing the dynamics of the Duffing equation:
% Parameters
omega_d_squared = 1;
beta = 1;
delta = 0.5;
% Duffing equations
duffingEquations = @(t, y) [y(2); omega_d_squared * y(1) – beta * y(1)^3 – delta * y(2)];
% Initial conditions and time span
initial_conditions = [
-1.5, -1.5;
0.01, 0;
-0.01, 0;
1.5, 1.5
];
time_span = [0, 50];
% Colors for the plots
colors = [
0, 0, 1; % Blue
1, 0, 0; % Red
1, 0, 0; % Red
0, 1, 0 % Green
];
% Line styles
line_styles = {‘–‘, ‘-‘, ‘-‘, ‘-‘};
% Plot the solutions
figure;
hold on;
box on; % Add box around the plot
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
plot(sol(:, 1), sol(:, 2), ‘Color’, colors(i, :), ‘LineStyle’, line_styles{i}, ‘LineWidth’, 1);
end
% Customize the plot
axis([-2 2 -2 2]);
grid on;
grid minor;
set(gca, ‘XTick’, -2:0.5:2, ‘YTick’, -2:0.5:2, ‘GridLineStyle’, ‘:’);
set(gca, ‘Box’, ‘on’);
% Add arrows
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
% Adding arrows at specific points
for j = 1:5:length(sol)-1
quiver(sol(j, 1), sol(j, 2), sol(j+1, 1) – sol(j, 1), sol(j+1, 2) – sol(j, 2), ‘AutoScale’, ‘off’, ‘Color’, colors(i, :), ‘LineWidth’, 1);
end
end
% Labels and title
xlabel(‘$U_n$’, ‘Interpreter’, ‘latex’);
ylabel(‘$U_n^prime$’, ‘Interpreter’, ‘latex’);
title(‘Duffing Oscillator Phase Portrait’);
hold off;
My question is the following, how could I those arrows on the trajectoriesI study a paper that describes a stationary problem where the function satisfies the boundary conditions and is governed by a modified Laplace equation with a non-linear term. Here’s a breakdown of the equations and the conditions they represent:
1. Equation Details:
– The first equation:
This is a partial differential equation (PDE) where denotes the Laplacian in dimensions. The equation includes a linear term proportional to and a non-linear term proportional to . The parameter seems to modulate the influence of the spatial derivatives, while and scale the linear and non-linear terms, respectively.
Boundary conditions:
These conditions specify that $ Phi $ is zero at the boundaries of the domain.
2. Special Case (Non-coupled Particles, 🙂
In the limit $ k = 0 $, the spatial derivative terms disappear, simplifying the equation to:
Here, seems to represent the state of a system described by the Duffing equation, which is a well-known model for non-linear oscillators with a cubic nonlinearity. The term introduces damping into the system, representing energy loss.
Here’s the Matlab code for simulating and visualizing the dynamics of the Duffing equation:
% Parameters
omega_d_squared = 1;
beta = 1;
delta = 0.5;
% Duffing equations
duffingEquations = @(t, y) [y(2); omega_d_squared * y(1) – beta * y(1)^3 – delta * y(2)];
% Initial conditions and time span
initial_conditions = [
-1.5, -1.5;
0.01, 0;
-0.01, 0;
1.5, 1.5
];
time_span = [0, 50];
% Colors for the plots
colors = [
0, 0, 1; % Blue
1, 0, 0; % Red
1, 0, 0; % Red
0, 1, 0 % Green
];
% Line styles
line_styles = {‘–‘, ‘-‘, ‘-‘, ‘-‘};
% Plot the solutions
figure;
hold on;
box on; % Add box around the plot
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
plot(sol(:, 1), sol(:, 2), ‘Color’, colors(i, :), ‘LineStyle’, line_styles{i}, ‘LineWidth’, 1);
end
% Customize the plot
axis([-2 2 -2 2]);
grid on;
grid minor;
set(gca, ‘XTick’, -2:0.5:2, ‘YTick’, -2:0.5:2, ‘GridLineStyle’, ‘:’);
set(gca, ‘Box’, ‘on’);
% Add arrows
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
% Adding arrows at specific points
for j = 1:5:length(sol)-1
quiver(sol(j, 1), sol(j, 2), sol(j+1, 1) – sol(j, 1), sol(j+1, 2) – sol(j, 2), ‘AutoScale’, ‘off’, ‘Color’, colors(i, :), ‘LineWidth’, 1);
end
end
% Labels and title
xlabel(‘$U_n$’, ‘Interpreter’, ‘latex’);
ylabel(‘$U_n^prime$’, ‘Interpreter’, ‘latex’);
title(‘Duffing Oscillator Phase Portrait’);
hold off;
My question is the following, how could I those arrows on the trajectories I study a paper that describes a stationary problem where the function satisfies the boundary conditions and is governed by a modified Laplace equation with a non-linear term. Here’s a breakdown of the equations and the conditions they represent:
1. Equation Details:
– The first equation:
This is a partial differential equation (PDE) where denotes the Laplacian in dimensions. The equation includes a linear term proportional to and a non-linear term proportional to . The parameter seems to modulate the influence of the spatial derivatives, while and scale the linear and non-linear terms, respectively.
Boundary conditions:
These conditions specify that $ Phi $ is zero at the boundaries of the domain.
2. Special Case (Non-coupled Particles, 🙂
In the limit $ k = 0 $, the spatial derivative terms disappear, simplifying the equation to:
Here, seems to represent the state of a system described by the Duffing equation, which is a well-known model for non-linear oscillators with a cubic nonlinearity. The term introduces damping into the system, representing energy loss.
Here’s the Matlab code for simulating and visualizing the dynamics of the Duffing equation:
% Parameters
omega_d_squared = 1;
beta = 1;
delta = 0.5;
% Duffing equations
duffingEquations = @(t, y) [y(2); omega_d_squared * y(1) – beta * y(1)^3 – delta * y(2)];
% Initial conditions and time span
initial_conditions = [
-1.5, -1.5;
0.01, 0;
-0.01, 0;
1.5, 1.5
];
time_span = [0, 50];
% Colors for the plots
colors = [
0, 0, 1; % Blue
1, 0, 0; % Red
1, 0, 0; % Red
0, 1, 0 % Green
];
% Line styles
line_styles = {‘–‘, ‘-‘, ‘-‘, ‘-‘};
% Plot the solutions
figure;
hold on;
box on; % Add box around the plot
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
plot(sol(:, 1), sol(:, 2), ‘Color’, colors(i, :), ‘LineStyle’, line_styles{i}, ‘LineWidth’, 1);
end
% Customize the plot
axis([-2 2 -2 2]);
grid on;
grid minor;
set(gca, ‘XTick’, -2:0.5:2, ‘YTick’, -2:0.5:2, ‘GridLineStyle’, ‘:’);
set(gca, ‘Box’, ‘on’);
% Add arrows
for i = 1:size(initial_conditions, 1)
[t, sol] = ode45(duffingEquations, time_span, initial_conditions(i, :));
% Adding arrows at specific points
for j = 1:5:length(sol)-1
quiver(sol(j, 1), sol(j, 2), sol(j+1, 1) – sol(j, 1), sol(j+1, 2) – sol(j, 2), ‘AutoScale’, ‘off’, ‘Color’, colors(i, :), ‘LineWidth’, 1);
end
end
% Labels and title
xlabel(‘$U_n$’, ‘Interpreter’, ‘latex’);
ylabel(‘$U_n^prime$’, ‘Interpreter’, ‘latex’);
title(‘Duffing Oscillator Phase Portrait’);
hold off;
My question is the following, how could I those arrows on the trajectories matlab, differential equations, plotting, equation, graph MATLAB Answers — New Questions
​