Clear Filters
Clear Filters

nonlinear dynamics(Measure synchronization)

4 views (last 30 days)
Dear Everyone
I'm working on my Phd thsesis on measure synchronization under nonlinear dynamics.am currently stuck with the average bare energy and interaction energy code for my work.i have gotten the Time series,phase plot,poincare section,frquency and power spectrum of my work.
am trying to reproduce the avareage bare energy code for ''Exploring the route to measure synchronization in non-linearly coupled Hamiltonian systems'' journal. I have done the phase plot,time series ,frequency and power spectrum of this jounal.
this is the code i try to use for the average bare energy of this journal and its not working.
function dxdt = exploring(t,x,y)
dxdt = zeros(4,1);
dxdt(1) = x(3);
dxdt(2) = x(4);
dxdt(3) = -x(1) + y*x(1)*x(2^2);
dxdt(4) = -x(2) + y*x(1)^2*x(2);
%% %% Average bear energy
clear all; close all; clc; %#ok<CLALL>
y=[0 0.07 0.15 0.52];
m=length(y);
tspan=[500:0.001:1400];
T=0:0.01:1400;
L=10;
E=0.2;
p1=0.2;
p2=sqrt(2*E - (p1)^2);
E1=((p1)^2 + y*(p1)^2)/2;
E2=((p2)^2 + y*(p2)^2)/2;
R =(1./ T) * integral((E1*E2),0,T);
for i=1:m
[t,R] = ode45(@(t,R) exploring(t,R,y(i)),tspan,[0 0 p1 p2]);
end
figure(i)
plot(t,R(:,1),'-b');
xlabel('t');
ylabel('X');
hold on
plot(t,R(:,2),'-r')
xlabel('t');
ylabel('x1,x2');%ylim([-1 1]);
I need your assistance, support and suggestion.
i would welcome any code with related to the average bare energy and intereaction energy for any oscillator.
Thanks

Answers (1)

Athanasios Paraskevopoulos
Let's first correct and complete the provided code. We need to make sure that the equations, integration, and plot functions are correctly implemented.
function dxdt = exploring(t, x, y)
dxdt = zeros(4,1);
dxdt(1) = x(3);
dxdt(2) = x(4);
dxdt(3) = -x(1) + y * x(1) * x(2)^2;
dxdt(4) = -x(2) + y * x(1)^2 * x(2);
end
% Parameters
y_values = [0 0.07 0.15 0.52];
m = length(y_values);
tspan = [500:0.001:1400];
T = 0:0.01:1400;
L = 10;
E = 0.2;
p1 = 0.2;
p2 = sqrt(2 * E - (p1)^2);
% Initial conditions
initial_conditions = [0 0 p1 p2];
% Initialize figure
figure;
for i = 1:m
y = y_values(i);
% Solve the ODE
[t, R] = ode45(@(t, R) exploring(t, R, y), tspan, initial_conditions);
% Calculate energies
x1 = R(:, 1);
x2 = R(:, 2);
p1 = R(:, 3);
p2 = R(:, 4);
E1 = (p1.^2 + y .* x1.^2) / 2;
E2 = (p2.^2 + y .* x2.^2) / 2;
average_energy = (E1 + E2) / 2;
% Plot results
subplot(m, 1, i);
plot(t, average_energy, '-b');
xlabel('t');
ylabel(['Average Energy for y = ' num2str(y)]);
hold on;
end
% Enhance the overall figure
sgtitle('Average Bare Energy for Different y Values');
1. Function Definition:
- `exploring(t, x, y)` defines the differential equations.
- `dxdt` contains the derivatives of the state variables.
2. Parameters:
- `y_values` contains the different values of the coupling parameter `y`.
- `tspan` specifies the time span for the ODE solver.
- `initial_conditions` specifies the initial conditions for the state variables.
3. ODE Solver:
- `ode45` is used to solve the differential equations over the specified time span and initial conditions.
4. Energy Calculation:
- `E1` and `E2` represent the energies of the two oscillators.
- `average_energy` is the average of `E1` and `E2`.
5. Plotting:
- The energies are plotted for each value of `y`.
- `subplot` is used to create a separate plot for each value of `y`.
This code will help you calculate and plot the average bare energy for different values of the coupling parameter `y`.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!