Computational physics 19.5: The Metropolis rule
A shortcut to a system at temperature T: try random changes, and make one that needs extra energy ฮW only with chance e^(โฮW/kT). In one line of NumPy, for 4000 molecules with two energy levelsโฆ
153 posts match
A shortcut to a system at temperature T: try random changes, and make one that needs extra energy ฮW only with chance e^(โฮW/kT). In one line of NumPy, for 4000 molecules with two energy levelsโฆ
Four thousand nitrogen molecules, all started on the ground, make random jumps up and down under the Metropolis rule, with ฮW = mgh. The air settles into the atmosphere of physics lesson 20.3: theโฆ
A grid of tiny magnets, each up or down, that like to point the way their neighbours do. The Metropolis rule, one magnet at a time, shows a cold grid staying magnetised and a hot one losing itsโฆ
Mixed questions from unit 19: the gas in a box, its temperature and pressure, random sharing, the Metropolis rule, the Boltzmann factor checked, and the Ising model. New numbers on every attempt. 80โฆ
Rearrange Schrรถdinger's equation into a step, like a = โ(k/m)x for a spring: the bend of ฯ is โC(E โ U)ฯ. Work out C once, in eV and nm, then step ฯ across a box with EulerโCromer and check itsโฆ
A wave in a box must be zero at both walls. Start at zero at one wall, step across, and see where ฯ ends at the other: that is the shooting method. Scan many energies, and ฯ at the far wall changesโฆ
Hand shoot to the bisect function of unit 10 and it finds each level to a millionth of an eV. The levels of a 1 nm box come out in the ratio 1 : 4 : 9, and the wave of level n has n humps, asโฆ
Physics lesson 19.5 gives the box's levels exactly, KE_n = nยฒhยฒ/(8mLยฒ), so the box can check the shooting method. Its error is tiny, quarters when the step halves, and is bigger for higher levelsโฆ
Give the walls a finite height U0 and the program needs only one change: U(x). In the walls ฯ grows or dies away instead of wiggling. The well's levels come out lower than the box's, and climbโฆ
Add up |ฯ|ยฒ in the walls and in the well: the share in the walls is the chance of finding the particle where a ball could never be. Higher levels leak more. Check that the walls were followed farโฆ
Mixed questions from unit 20: Schrรถdinger's equation as a step, the shooting method, bisection on the energy, the exact box and the error, a finite well and the chance of finding the particle in itsโฆ
An optional extra. The bend of ฯ at every place at once is a matrix times ฯ, so Schrรถdinger's equation becomes H @ psi = E * psi: an eigenvalue problem. np.linalg.eigh finds every level of the boxโฆ
Learn Python from your very first line, then use it to simulate physics: falling objects, orbits, waves, heat, randomness and quantum particles. Short steps, code that runs in your browser, and aโฆ
Already write Python? Fifteen short questions from the four Python units. Pass (80 %) and start at unit 5, the first simulation; if not, each answer names the unit to start from. Units 1โ4 teachโฆ
A program is a list of instructions the computer carries out, one line at a time, from the top. Write and run your first lines of Python: print a number, do a sum, and fix a mistake. A calculatorโฆ
Store a number under a name, and use the name in a sum: distance, time and speed as a program. Choose names Python accepts, and read the error when a name is used before it is set. A physicistโฆ
Store a new value in a variable, add to a variable, and write the physics formula speed = distance / time as a line of code, then turn it round to work out a distance. A car's trip meter starts atโฆ
Write notes for people in a program with #, switch a line off and on, and print a label and a number together: print("speed in m/s:", speed). Python stores numbers, not units. To Python, 12.5 isโฆ
Python works out * before +, as in maths, and brackets first. Write powers with and use them for the distance a stone falls, s = ยฝgtยฒ. Two stopwatches time the same fall: 12 s and 14 s. Their meanโฆ
Convert km/h to m/s, minutes to seconds and millimetres to metres in a program, write powers of ten in e notation, and convert before you calculate. A car's speedometer says km/h; a physics formulaโฆ
Meet the errors every beginner meets: SyntaxError (a missing bracket), TypeError (text and a number added), and the worst bug of all, the one that gives a wrong number and no message. Everyโฆ
The Unit 1 test: short programs and questions with new numbers on every attempt, covering the whole unit. 80 % to pass. Time to show what you can do. The questions mix the whole of Unit 1, and theโฆ
A program decides by asking questions with a yes-or-no answer. Compare numbers with <, >, <=, >=, == and !=, and read Python's two answers: True and False. A speed camera doesn't need to know yourโฆ
if runs some lines only when a comparison is True. Write if, its condition and colon, and its body, pushed in by four spaces; fix an IndentationError and a line left outside the body. A speedโฆ