ArticleslgStudy

computer science

Demon algorithm

Demon algorithm is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Demon algorithm rather than just read about it. In short: The demon algorithm is a Monte Carlo method for efficiently sampling members of a microcanonical ensemble with a given energy. An additional degree of freedom, called 'the demon', is added to the system and is able to store and provide energy.

Key takeaways

  • Demon algorithm belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Demon algorithm to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Demon algorithm from memory before moving on to harder problems.

Reference excerpt

The demon algorithm is a Monte Carlo method for efficiently sampling members of a microcanonical ensemble with a given energy. An additional degree of freedom, called 'the demon', is added to the system and is able to store and provide energy. If a drawn microscopic state has lower energy than the original state, the excess energy is transferred to the demon. For a sampled state that has higher energy than desired, the demon provides the missing energy if it is available. The demon can not have negative energy and it does not interact with the particles beyond exchanging energy. Note that the additional degree of freedom of the demon does not alter a system with many particles significantly on a macroscopic level. In thermodynamical systems, equal macroscopic properties (e. g. temperature) can result from different microscopic properties (e. g. velocities of individual particles). Computer simulations of the full equations of motion for every individual particle to simulate microscopic properties is computationally very expensive. Monte Carlo methods can overcome this problem by sampling microscopic states according to stochastic rules instead of modeling the complete microphysics. The microcanonical ensemble is a collection of microscopic states which have fixed energy, volume and number of particles. In an enclosed system with a certain number of particles, energy is the only macroscopic variable affected by the microphysics. The Monte Carlo simulation of a microcanonical ensemble thus requires sampling different microscopic states with the same energy. When the number of possible microscopic states of thermodynamical systems is very large, it is inefficient to randomly draw a state from all possible states and accept it for the simulation if it has the right energy, since many drawn states would be rejected.

The demon algorithm The full procedure can be summarized by the following steps:

Perform a random change in the state of a randomly chosen particle (e. g. change velocity or position). Calculate the change in energy ΔE of the thermal system. Negative ΔE, i. e. excess energy, is given to the demon by adding |ΔE| to the demon. This case (ΔE<0) is always accepted. The demon provides positive ΔE to keep the total energy constant only if it has sufficient energy, i. e. Ed>ΔE. In this case the change is accepted, otherwise the randomly chosen change in velocity is rejected and the algorithm is restarted from the original microscopic state. If the change is accepted, repeat the algorithm for the new configuration. Since energy fluctuations per degree of freedom are only of order 1/N, the presence of the demon has little effect on macroscopic properties of systems with high numbers of particles. After many iterations of the algorithm, the interplay of demon and random energy changes equilibrates the system. Assuming that a particular system approaches all possible states over very long times (quasi-ergodicity), the resulting Monte Carlo dynamics realistically sample microscopic states that correspond to the given energy value. This is only true if macroscopic quantities are stable over many Monte Carlo steps, i. e. if the system is at equilibrium.

See also Monte Carlo methods Metropolis algorithm to sample microscopic states at a fixed temperature

References Harvey Gould and Jan Tobochnik and Wolfgang Christian (2006). "Chapter 15: Monte Carlo Simulations of Thermal Systems". An Introduction to Computer Simulation Methods: Applications to Physical Systems (3rd ed.). Addison Wesley. ISBN 978-0-8053-7758-3. Creutz, Michael (May 1983). "Microcanonical Monte Carlo Simulation". Phys. Rev. Lett. 50 (19). American Physical Society: 1411–1414. Bibcode:1983PhRvL..50.1411C. doi:10.1103/PhysRevLett.50.1411.

Worked examples

Example 1 — a first encounter with Demon algorithm

Start with the simplest possible case. Write down what Demon algorithm claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Demon algorithm before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Demon algorithm ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Demon algorithm

In research
Demon algorithm appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Demon algorithm in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Demon algorithm is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computational physics, Monte Carlo methods, Sampling techniques, so understanding it makes those chapters shorter.
In everyday life
Look for Demon algorithm outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Demon algorithm” →

How to study Demon algorithm in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Demon algorithm means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Demon algorithm out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Demon algorithm in simple terms?

The demon algorithm is a Monte Carlo method for efficiently sampling members of a microcanonical ensemble with a given energy. An additional degree of freedom, called 'the demon', is added to the system and is able to store and provide energy.

Why does Demon algorithm matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Demon algorithm?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Demon algorithm.

Tags

  • Computational physics
  • Monte Carlo methods
  • Sampling techniques

Keep exploring