이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Analytical or numerical Solution for a coupled differential equation.
조회 수: 5 (최근 30일)
이전 댓글 표시
I need a help in analytical/numerical solution to a coupled differential equation as attached in the image. Where m=n=3
댓글 수: 22
PS
2022년 6월 11일
Thankyou for your reply. This is a coupled mode differential equation for the modes propagating in a perturbed fiber. For m=n=3, ignoring t (time) for now. I have elaborated the equations. There are 3 equations which needs to be solved (attached Equation.png). Cmn is a 3x3 matrix dependent on z and beta_m - beta_n are constant values. Z is varying in small steps and i need the solution of A1,A2,A3 in terms of C,beta,z. For 2 mode equation i could solve it analytically but for 3 modes the solution is becoming tedious. I need help in solving these 3 equations either analytically or numerically. Since we have complex i term, so i am not sure which method could be used or if RK method can be helpul here.
Thanks in advance
Torsten
2022년 6월 11일
Should be easy to solve with ODE45. The solver can handle complex-valued ordinary differential equations.
Give it a try.
Torsten
2022년 6월 12일
The only thing you could try is MATLAB's "dsolve" or MATHEMATICA for an analytical solution.
PS
2022년 7월 2일
Hey, I tried solving using dsolve, but i get a "Warning: Unable to find explicit solution".
David Goodmanson
2022년 7월 3일
Hi PS,
For the two mode case was there a specific form of Cmn(z) that allowed an analytic solution? That won't be the case in general.
PS
2022년 7월 3일
Hi David,
Thanks for your reply, Cmn(z) is a variable dependent on z, which comes after solving an integral. While solving the dsolve i used it as a constant (eg Cmn=2) and tried solving the equation but I still got the warning. I guess dsolve doesnt solve for complex equations,ryt ?
Walter Roberson
2022년 7월 3일
dsolve can handle complex-valued equations. However, it is not all that good with complicated equations.
A trick with dsolve is that if it cannot handle the equations with initial conditions, then sometimes it can handle them without initial conditions, and then you might be able to guide it through to solve for the generated constants. That said, there are a lot of cases that dsolve cannot handle even without initial conditions.
PS
2022년 9월 27일
Hi,
I tried solving the 2 mode equation using RK45 in matlab. I have defined the relative error tolerance of 10^(-6) and absolute error tolerance of 10^(-9) in matlab while using ODE45 function, and the step size to be 10^5. Can we define both error tolerance and step size together? If not, how do we find the step size for the defined error tolerance ?
Torsten
2022년 9월 27일
ODE45 calculates its own step size - you can't prescribe it.
You can only choose a maximum and a minimum stepsize.
You can define all quantities in the options structure independently from each other.
PS
2022년 9월 28일
Thankyou for your reply, actually i was trying to compare 2 mode solution using ODE45 with analytical solution available with me, to understand the error between the two. As you mentioned ODE45 calculates its own step size, is there a way to know that ? As i will be giving the same step size in my analytical method to have a fair comparison between the 2 techniques.
Torsten
2022년 9월 28일
편집: Torsten
2022년 9월 28일
As you mentioned ODE45 calculates its own step size, is there a way to know that ?
You can get an impression of the stepsize from ODE45 by choosing
tspan = [tstart tend]
as a two-element vector.
Then the output T and Y will be given for the (successful) integration steps of ODE45:
[T, Y] = ode45(...)
As i will be giving the same step size in my analytical method to have a fair comparison between the 2 techniques.
An analytical method does not need a stepsize.
Walter Roberson
2022년 9월 28일
The ode* functions are all adaptive step size. Each time a step succeeds they increase the step size, and each time a step fails they decrease it. If you set the option Refine to 1 and your tspan is exactly two elements then an output will be recorded for each step that succeeds, so you could diff(t) to see the instantaneous time step.
Torsten
2022년 9월 28일
Walter is right - additionally to the two-element vector for tspan, you have to set Refine to 1 when using ODE45.
This will give you the solution at the end of all successful time steps.
Walter Roberson
2022년 9월 28일
And of course you can take the t values output by ode45 and subs() them into the dsolve solution to get the analytic solution at the same times, suitable for plotting together with a dashed or dotted line for the second line (to be able to see underneath it in places of overlap)
PS
2022년 10월 8일
편집: Torsten
2022년 10월 9일
Thankyou @Walter Roberson and @Torsten for your replies. I have defined the span beginning and end which is [0 10], ode45 choses the step size, which is then applied in the analytical expression to compare the 2 methods. I am doing this process for couple of equations here, the coefficient named coupling_coefficient_12 is changed in the ode45 equation and the step size is chosen by the ode45 method, the doubt is that the step size used during different coupling coefficients value is significantly different, is this expected or am doing anything wrong here ? I ahve attached the code for your reference.
% Comparison between RK45 method and the analytical solution or a 2 mode
% coupled differential equation
clc;clear all;close all;
cc=0;
for Coupling_Coefficient_12=0:4:20 %coupling coefficient (not solving equation 4 and directly defining coupling coefficient values
cc=cc+1;
del_beta=0.3;
%Using numerial solution ie RK 45 to solve a coupled differential equation
%for 2 modes
options=odeset('RelTol',1e-6,'AbsTol',1e-9);
f=@(z,x) [-1i*Coupling_Coefficient_12*x(2)*exp(1i*del_beta*z);-1i*conj(Coupling_Coefficient_12)*x(1)*exp(-1i*del_beta*z)]; %x(2):LP11a, x(1):LP01
[zz,xa]=ode45(f,[0 10],[1;0],options); %[LP01=1 LP11a=0] represent the initial condition
% [0 10] is the span of z starting from 0 to 10, the steps size chosen
% by ODE45 will later be used for solving by analytical method
% xa(:,1) represent LP01 soluton
% xa(:,2) represents LP11a solution
%Analytical solution obtained using substitution elimination to solve a
%coupled differential equation or 2 mode
%Using the same "adaptive step size for z" and substituting in numerical solutions to compare the differnce between both methods
k=Coupling_Coefficient_12;
s=sqrt((Coupling_Coefficient_12*conj(Coupling_Coefficient_12))+((del_beta/2)^2));
A1_0=1; % defining initial condition LP01=1
A2_0=0; % defining initial condition LP11a=0
A1=(exp(1i*(del_beta/2)*zz')).*((cos(s*zz')-(1i*(del_beta/2)*sin(s*zz'))/s).*A1_0-(((1i*Coupling_Coefficient_12*sin(s*zz')/s)).*A2_0));
A2=(exp(-1i*(del_beta/2)*zz')).*((-1i*conj(Coupling_Coefficient_12)*(sin(s*zz'))/s).*A1_0+(cos(s*zz')+1i*(del_beta/2)*(sin(s*zz'))/s).*A2_0);
diff_method1(cc)=mean(abs(xa(:,1)-A1.').^2); %difference between LP01 solution obtained numerically vs analytically
diff_method2(cc)=mean(abs(xa(:,2)-A2.').^2); %difference between LP11a solution obtained numerically vs analytically
figure(cc)
plot(zz,xa)
end
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Warning: Imaginary parts of complex X and/or Y arguments ignored.
figure(cc+1);
plot(0:4:20,diff_method1)
hold on
plot(0:4:20,diff_method2)
Torsten
2022년 10월 8일
the doubt is that the step size used during different coupling coefficients value is significantly different, is this expected or am doing anything wrong here ?
You mean that ode45 takes different step sizes for different values of "Coupling_Coefficient_12" ? This might be the case. At least the errors in both components show that the ode45 solution approximates the analytical solutions quite well, doesn't it ?
PS
2022년 10월 9일
Hi @Torsten, thankyou for your reply. Yes, ode45 is taking different step size for different coupling coeffificients which may be fine, but i was wondering if the change in step size between the different values would change so significantly as i see in my case.
Couping_coefficient_12 = 0, step size = 41
Couping_coefficient_12 = 4, step size = 929
Couping_coefficient_12 = 8, step size = 1849
Couping_coefficient_12 = 12, step size = 2773
Couping_coefficient_12 = 16 step size = 3689
Couping_coefficient_12 = 20, step size = 4609
Torsten
2022년 10월 9일
편집: Torsten
2022년 10월 9일
Analytical solution and solution from ODE45 are almost identical. So it seems ODE45 needs these smaller time steps to get the correct solution within the prescribed error tolerance.
The coupling coefficient is directly related to the frequency of the sin and cos terms in the analytical solution. And if you plot sin(x) and sin(20*x), you will see that it will be much more difficult to resolve the cycles of the trigonometric functions for bigger coupling coefficients.
Plotting the solutions A1 and A2 might help in understanding why solutions for bigger coupling coefficients are more complicated to get (see above).
David Goodmanson
2022년 10월 10일
편집: David Goodmanson
2022년 10월 10일
Hi PS,
If the elements of Cmn are differing functions of z, then an analytic solution will be rare. If all the Cmn are constants, the following is a solution where C is a square matrix of arbitrary size, within reason.
Let B be the diagonal matrix whose k,k element is beta_0k. Then for the matrix exponential
expB(z) = expm(i*B*z) % diagonal matrix
exp(i*beta_0k*z) % its k,k th element
In matrix notation the original equation is
dA/dt = -i*expB(z)*C*expB(-z)*A,
where A is a column vector with n components.
For the solution, let
[V lambda] = eig(B+C)
Lambda is the diagonal matrix of eigenvalues, and denoting its matrix exponential in a similar way as before,
expL(-z) = expm(-i*lambda*z). % diagonal matrix
exp(-i*lambda_k*z) % its k,k the element
The solution is
A = expB(z)*V*expL(-z)*g
where g is a column vector of constant amplitudes that are determined by initial conditions. If the initial conditions are set as A = A0 at z = 0 for some column vector A0, then
g = V\A0.
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)