Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Solving Some Physics Problems. At this point we could implement floating point math. Our computer does have sufficient instructions, but I think our energy would
Solving Some Physics Problems.
At this point we could implement floating point math. Our computer does have sufficient instructions, but I think our energy would be better served by solving some
physics problems with our simple computer.
You are standing on top of a tower and release a ball. We want to simulate the ball being released and hitting the ground. Write a code to solve this problem
using the Euler method.
You must consider the following
how to best scale the problem to minimize round off errors
choosing the integration timestep to minimize trunction errors
To answer these points introduce LENGTHSCALE and TIMESCALE factors that will adjust your inputs, thus your code should adopt an initialization block as listed
below. You may need to take your answer returned from the virtual computer and scale it back to MKS using TIMESCALE see below for an example The idea is to
scale the physics problem to fit in our force numerical scale. This is necessary to solve most modern physics problems even with full bit floatingpoint operations.
You make include the whilevar or whilenot var command in your code to aid with boundary detection. Thus, you cannot use while or other
variations. It may help to note that True and False Thus you are creating a map from your physical space to the simulation space.
Answer the following questions.
How long does it take for the ball to reach the ground using your simulation? We will call this the droptime
Calculate the analytic solution and compare to your answer. How well do they match?
Plot a map of droptime as a function of TIMESCALE and LENGTHSCALE. To visualize the results use MatPlotlib pcolormesh or imshow that has TIMESCALE
on the axis and LENGTHSCALE on the yaxis. To create your map you can wrap your droptime code calculator into any python construct to gather results.
Discuss your map in the content of truncation and roundoff error.
What values of TIMESCALE and LENGTHSCALE produce the best results precison relative to known answer
What are the maximum and minimum useable values of TIMESCALE and LENGTHSCALE?
What valeus of TIMESCALE and LENGTHSCALE optimize the compute time eg minimize prgcnt and precision?
Hint #: I needed to use a grid of to properly explore the behaviour of changing scales. Calculating large grids may take minutes depending on your setup.
Consider using the tqdm package to monitor the runtime of your codes.
Hint #: Note, you may encounter solutions that do not converge and give pure numerical noise, thus you should take care when selecting your colourmap range with
imshow or pcolormesh.
dtsec #timestep in seconds
heightm #height of building in metres
grmks #gravity,
TIMESCALE #Change both as needed
LENGTHSCALE
#Start our computer
computer computerstate #Leave this here.
#load our parameters into our Computer Below is just an example, please change and adopt anything below to suit your needs
time load
load
height loadheight LENGTHSCALE
vel load
gr load grmks LENGTHSCALE
ts loadTIMESCALE
#initial time
#timestep
#initial height
#initial velocity
#acceleration
ls loadLENGTHSCALE
#timescale
#lengthscale
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started