Omniadisce

Posts tagged Programming

153 posts match

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

Computational physics 13.1: A note as numbers

A pure note is a pressure that goes up and down, y = A cos(2ฯ€ft). Draw a tuning fork's note with NumPy, work out its period, make it louder, and add two notes together, as superposition says. Everyโ€ฆ

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

Computational physics 14.2: The rod as an array

Keep the rod's temperatures in one NumPy array. Make it with np.full, set one end with T[0] = 100, and use slices, T[1:-1], T[2:] and T[:-2], to line every inner piece up with its two neighbours. Aโ€ฆ

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

Computational physics 14.4: Watching heat spread

The rod on a grid in space and time: pieces dx apart, steps dt apart. Draw it at 30 s, 60 s, 90 s and 120 s on one graph, and watch heat spread from the hot end, faster in copper than in steel. Aโ€ฆ

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

Computational physics 14.5: Holding the ends

What happens at the ends of the rod is a choice: a boundary condition. Hold both ends at fixed temperatures and the rod settles into a straight line, checked against the exact answer; wrap an endโ€ฆ

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

Computational physics 14.6: Too big a step

A bigger time step means fewer steps, so why not? Try r = 0.6 and the rod zig-zags and blows up. One hot piece shows why, and gives the stability rule: r โ‰ค ยฝ, that is dt โ‰ค dxยฒ/(2ฮฑ). In unit 5 aโ€ฆ

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

Computational physics 15.3: When to stop

Without the answer to compare with, watch the biggest change in each sweep, and stop when it is smaller than a tolerance, with a limit on the sweeps. Then find the field between the plates and checkโ€ฆ

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

Computational physics 15.4: A grid of points

A flat grid of potentials in a two-dimensional array, V[i, j]. On a grid each point has four neighbours, and in empty space its potential is their average: Gauss's law says why. Four shifted slicesโ€ฆ

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

Computational physics 15.5: Relaxation on a grid

Relax the potential inside the square pipe until it settles, check it at the centre, where the answer is exactly a quarter of the lid's potential, and see why a bigger grid needs more sweeps and aโ€ฆ

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

Computational physics 16.1: Pulled by its neighbours

Cut a stretched rope into short pieces, each with a height. A piece out of line with its neighbours is pulled back: its acceleration is (v/dx)ยฒ ร— (y_left โˆ’ 2y + y_right). Unlike heat, that changesโ€ฆ

1 view by Weten 8 days ago
× Enlarged view