Physics 281: Computational Physics
Computational Physics,
项目类别:物理
Hello, dear friend, you can consult us at any time if you have any questions, add  WeChat:  zz-x2580

Physics 281: Computational Physics


-1 First-order differential equations with one variable.

-2Differential equations with more than one variable.

-3 Second-order differentialequations. 

These three sections cover the material we will use in P281. You should take a look at the remaining sections of Ch. 8 to get an idea of some more advanced methods for solving ODEs.

Completing all of the non-starred activities will count as A-level work. To receive credit, these activities must be checked off in class or office hours within three weeks (by Fri 4/19).

1.Solving an ODE with odeint: The low-pass filter.

The circuit shownin the figure below built from a resistor R and a capacitor C is called a “low-pass filter”. The input voltage Vin(t) is specified. Then the output voltage Vout(t) is determined by the following first-order ODE:

00000000000000000000000

This is called a low-pass filter because low-frequency sine waves with angular frequencies ω 1/RC pass through this circuit nearly un- changed, while high frequency sine waves with ω 1/RC are (imper- fectly) blocked. For this problem use R = 10 kΩ, C = 1 µF which gives 1/RC = 100 rad/s.


12019-03-27 P281 W9ab.tex §c 2019 Donald Candela

(a)Assume Vin(t) = A sin(ωt) with A = 2.0 V and ω = 50 rad/s. 

Write a program that defines a function to compute Vin(t) and uses this function to make a plot of Vin(t) for 0 < t < tmax, with tmaxchosen to show about two or three complete cycles of the sine Make the number of time points a variable that you can easily change it (or input the number of points when you run your program. Start with several hundred points to get a nice smooth curve.

(b)Write a program to that uses odeint to find Vout(t) at the same set of time points. Use the initial condition Vout(0) = 0.0 V.  Plot Vin(t) and Vout(t) on the same graph (with labeled axes and a legend for the two curves, of course).  Because ω  <  1/RC,the output should be only a little bit smaller than the input and slightly shifted in phase.

(c)Runyour program again, changing ω to 300 rad/s. Now the out- put should be quite a bit smaller than the input, and shifted in phase by nearly π/ For both values of ω you should find that Vout(t) is a sine wave except for an initial transient near t = 0.

2.Euler’s method. 

Add code to your program to compute Vout(t) at thesame set of time points using Euler’s method, and plot the results on the same graph as the odeint  Find the minimum number of time points for which the Euler’s-method results appear identical (by eye) to the odeint results. (For this purpose, you may want to remove the Vin(t) curve from your plot.)

3.Add code to compute Vout(t) using the second-order Runge- Kutta method, and plot the RK2, Euler’s-method, and odeint results together.As with the previous activity, find the minimum number of time points for which the RK2 results appear identical (by eye) to the odeint results. 

4.*RK4. As explained in Newman Sec. 8.1.3, if you didn’t have an ODE integrator like integrate.odeint and  had  to  program  one yourself, you would probably use fourth-order Runge-Kutta, which isquite accurate. Modify your program from the last activity to include an RK4 integration of the ODE, using the formulas from Newman Sec. 8.1.3. To check the accuracy, have your program print out y(tmax)for the various methods (odeint, RK2, RK4).


留学ICU™️ 留学生辅助指导品牌
在线客服 7*24 全天为您提供咨询服务
咨询电话(全球): +86 17530857517
客服QQ:2405269519
微信咨询:zz-x2580
关于我们
微信订阅号
© 2012-2021 ABC网站 站点地图:Google Sitemap | 服务条款 | 隐私政策
提示:ABC网站所开展服务及提供的文稿基于客户所提供资料,客户可用于研究目的等方面,本机构不鼓励、不提倡任何学术欺诈行为。