- Introduce “z(t) = y'(t)” to represent the first derivative of y(t).
- Rewrite the second-order ODE as two first-order ODEs:
how to convert second order ODE to first in the below FDTD problem
조회 수: 5 (최근 30일)
이전 댓글 표시
for index=1:iterationsNum
I am currently workin on this particlar FDTD problem where it is required to input the above second order ODE into the below code in the rohNew line.Thougt about using OdeToVectorfield but could not understand how to integrate it in this context.
You can just ignore the constants.
ELz=(EL(2:end)-EL(1:end-1))/dz;
ELnew(2:end)=EL(2:end)+dt*c/n*(1i*kappa*roh(2:end).*ES(2:end)-ELz);
ESz=(ES(2:end)-ES(1:end-1))/dz;
croh=conj(roh);
ESnew(1:end-1)=ES(1:end-1)+dt*c/n*(1i*kappa*croh(1:end-1).*EL(1:end-1)+ESz);
f = wgn(1,N,Q/dt/dz,'complex','linear');%f=sqrt(Q/dz)*(randn(1,N))/sqrt(dt);%sqrt(Q/dz)*(randn(1,N)+1i*randn(1,N))/sqrt(2)/sqrt(dt);
rohNew=roh+dt*(1i*LAMBDA*EL.*conj(ES)+f-GAMMAb*roh/2);
EL=ELnew;
ES=ESnew;
roh=rohNew;
end
댓글 수: 0
답변 (1개)
UDAYA PEDDIRAJU
2024년 1월 15일
Hi Yogesh,
1) To convert a second-order ODE to a first-order system, introduce a new variable for the derivative of the original variable. For the given ODE:
y'(t) = z(t)
z'(t) = f(t, y(t), z(t))
In your case, you can try introducing a new variable “roh'(t) = rohNew(t) - roh(t)” and rewrite the second-order ODE as a system of two first-order ODEs:
ELz=(EL(2:end)-EL(1:end-1))/dz;
ELnew(2:end)=EL(2:end)+dt*c/n*(1i*kappa*roh(2:end).*ES(2:end)-ELz);
ESz=(ES(2:end)-ES(1:end-1))/dz;
croh=conj(roh);
ESnew(1:end-1)=ES(1:end-1)+dt*c/n*(1i*kappa*croh(1:end-1).*EL(1:end-1)+ESz);
f = wgn(1,N,Q/dt/dz,'complex','linear');%f=sqrt(Q/dz)*(randn(1,N))/sqrt(dt);%sqrt(Q/dz)*(randn(1,N)+1i*randn(1,N))/sqrt(2)/sqrt(dt);
rohNew=roh+dt*(1i*LAMBDA*EL.*conj(ES)+f-GAMMAb*roh/2);
rohPrime = rohNew - roh;
EL=ELnew;
ES=ESnew;
roh=rohNew;
2) Regarding the usage of “ odeToVectorField” yes, it is useful to convert the higher order ODEs to a system of first-order ODEs, here is an example.
syms y(t) z(t)
Dy = diff(y, t);
Dz = diff(z, t);
ode = Dz == f(t, y, z); % Replace f(t, y, z) with your specific function
V = odeToVectorField(ode);
M = matlabFunction(V, 'vars', {'t', 'Y'});
I hope this gives you an idea on how to convert 2nd order ODE to 1st order system!
댓글 수: 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!