实现 Newton-Raphson 迭代方法
我正在尝试使用牛顿拉夫森迭代来实现向后欧拉方案。据我所知,每次迭代时,人们都会做出初步猜测,计算残差并解决变化。就我而言,更改是 del w。之后我知道将值添加到 w^m 并在下一个 m 迭代中获取 w 的更新值。我知道随着迭代的进行检查解决方案的收敛性。我遇到的问题是如何将时间步长 dt 实现为 t=0:Tmax/dt ,其中 Tmax 为 10。我对时间步长是如何进来的感到困惑。我一直在试图解决这个问题同时,任何帮助将不胜感激。谢谢你!
while Rw(m)>10^-6 % Convergence condition
drdw(m)=(1-2*dt+2*t(n+1)^2*w(m)*dt);
Dw(m)=Rw(m)\drdw(m); %Inverse
w(m+1)=w(m)+Dw(m); %Newton method
Rw(m+1)=(-(w(m)-v(1)-2*w(m)*dt+t(n+1)^2*w(m)^2*dt)); %New Residual value
if Rw(m+1)>10^-6 %Check on the level of convergence
m=m+1;
else
Rw=1; % I was thinking I should make the Residual 1 for the next time step.
break
end
I'm trying to implement a backward Euler Scheme using the Newton Raphson iteration. I understand that with each iteration, one makes an initial guess, calculates the residual and solve for the change. In my case the change is del w. After that I know to add the value to w^m and get an update value for w at the next m iteration. I know to check the convergence of the solution as the iterations go on. The problem I am having is how to implement the time step dt as t=0:Tmax/dt where Tmax is say 10. I'm confused on how the time stepping comes in. I've been trying to figure this out for a while so any help will be appreciated. Thank you!
while Rw(m)>10^-6 % Convergence condition
drdw(m)=(1-2*dt+2*t(n+1)^2*w(m)*dt);
Dw(m)=Rw(m)\drdw(m); %Inverse
w(m+1)=w(m)+Dw(m); %Newton method
Rw(m+1)=(-(w(m)-v(1)-2*w(m)*dt+t(n+1)^2*w(m)^2*dt)); %New Residual value
if Rw(m+1)>10^-6 %Check on the level of convergence
m=m+1;
else
Rw=1; % I was thinking I should make the Residual 1 for the next time step.
break
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那里有些奇怪,一阶 ODE 的形式为 dy/dt = f(t,y),但你有 w、v、t、m 和 n。
您正在将时间间隔 (0,T) 上的解决方案计算到具有恒定步长 h 的分区中:
对于此
尝试实现您的牛顿方法(使用上面的 while 条件)将上述问题作为单独的函数求解,然后通过步骤
1 到 n 将其集成到您的欧拉中,其中 n = Tmax/h。
Something is strange in there, a 1st order ODE is of the form dy/dt = f(t,y) yet you have w,v,t,m and n.
You are computing your solution over the time interval (0,T) into a partition with constant step size h:
For this
Try implementing your newton method (using the while conditional as you have above) to solving the above as a separate function and then integrate it into your euler over the steps
1 to n where n = Tmax/h.