Omniadisce

Posts tagged Programming

153 posts match

Type
Subject
Difficulty
Tags
Show all 247 tags
Lesson
Scientific Computing Beginner Lesson

Computational physics 5.4: How small a step?

Smaller steps give smaller errors but take longer. See Euler's error halve with dt, watch round-off add a step too many, and learn the test that works with no exact answer: halve dt until the answerโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 5.5: Air resistance

Air pushes back harder the faster you fall. Take the drag force kยทvยฒ and the acceleration it gives from physics lesson 4.9, and simulate a skydiver who stops speeding up at terminal speed: a fall noโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 5.6: Until it lands

Run a simulation until something happens: the ball reaches the ground. Find how long a fall takes and how fast it lands, check it against physics without air, then add air resistance. So far theโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 6.1: Energy as a check

With no air and no friction, kinetic plus potential energy stays the same. Work it out in a simulation, and it becomes a check that needs no exact answer. Euler's falling ball fails it: it gainsโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 6.2: A spring with Euler's method

Simulate a mass on a spring with Euler's method, using a = โˆ’(k/m)x from physics unit 9. Its swings grow when they shouldn't, and its energy, ยฝmvยฒ + ยฝkxยฒ, climbs step after step. A mass on a springโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 6.6: RK4, a ready-made tool

RK4 tries the acceleration four times in each step and moves on with a weighted average. Use it as a given function: write the acceleration, call rk4_step, and see its error fall sixteen times whenโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 7.1: x and y together

A ball kicked at an angle moves across and up at the same time. Step both directions in one loop, launch at any angle, run until it lands, and check the range against physics lesson 3.5. Physicsโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 7.2: Drag in two dimensions

Air pushes against a ball's velocity, whichever way it is going. Split the drag kvยฒ into an across part and an up part, put them in the loop, and see a tennis ball's path lose its symmetry. Physicsโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 7.3: The best angle

With air there is no formula to check against, so check the program where there is one: turn the air off. Then put one flight in a function, try every angle, and find the one that goes furthestโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 7.4: A planet's orbit

The same loop as a kicked ball, with the pull of the Sun in place of gravity's steady 9.81. Choose units that keep the numbers friendly, split the pull into x and y parts, and send the Earth roundโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 7.5: Checking energy

A planet's energy, kinetic plus potential, must stay the same all the way round. Work it out in the loop, watch plain Euler's planet gain energy and spiral away, and see Eulerโ€“Cromer keep it, on aโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.1: A mass on a spring

The first oscillator: a mass on a spring, pulled back by F = โˆ’kx. Step it with Eulerโ€“Cromer, as in unit 6, draw it against the exact A cos(ฯ‰t), and check that its energy stays put. Springsโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.2: How long is a swing?

Find an oscillator's period from the simulation itself: run until the mass stops at the far end, which takes half a period. Check it against T = 2ฯ€โˆš(m/k), and see that a bigger pull doesn't changeโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.3: A pendulum

Step a pendulum's angle the way you stepped a spring's position, with its angular acceleration โˆ’(g/L) sin ฮธ, in radians. Measure its period with the stopwatch of lesson 8.2 and check it againstโ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.4: Big swings

Let the pendulum swing high and measure how its period grows with the angle: a few percent at 60ยฐ, almost four times 2ฯ€โˆš(L/g) near the top. A table and a graph that no formula from physics unit 9โ€ฆ

1 view by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.5: Damping

Add a damping force against the motion, โˆ’bv, and watch the swings die away. Measure the amplitude near the end of a run, find that it shrinks by the same fraction in equal times, and see heavyโ€ฆ

0 views by Weten 8 days ago
Lesson
Scientific Computing Beginner Lesson

Computational physics 8.6: A resonance curve

Push a damped spring again and again, Fโ‚€ cos(2ฯ€ft), and measure how big its swings get once they settle. Do it for many driving frequencies and plot the resonance curve: a peak at the naturalโ€ฆ

1 view by Weten 8 days ago
× Enlarged view