Editing
Thermodynamics
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Simulating a 2D Ising Model (Ferromagnetism):''' <syntaxhighlight lang="python"> import numpy as np def ising_step(lattice, beta, J=1.0): """Perform one Metropolis-Hastings step for the Ising model.""" N = lattice.shape[0] for _ in range(N*N): i, j = np.random.randint(0, N, 2) # Sum of neighbors (periodic boundary conditions) neighbors = lattice[(i+1)%N, j] + lattice[(i-1)%N, j] + \ lattice[i, (j+1)%N] + lattice[i, (j-1)%N] # Change in energy if we flip this spin delta_E = 2 * J * lattice[i, j] * neighbors # Accept flip if energy decreases or with probability exp(-beta*dE) if delta_E <= 0 or np.random.rand() < np.exp(-beta * delta_E): lattice[i, j] *= -1 return lattice # Setup 20x20 lattice lattice = np.random.choice([1, -1], size=(20, 20)) temp = 2.0 beta = 1.0 / temp # Run for 1000 steps for _ in range(1000): lattice = ising_step(lattice, beta) print("Final Average Magnetization:", np.mean(lattice)) </syntaxhighlight> ; Practical Applications : '''Engine Design''' β Carnot cycle limits, fuel efficiency, turbochargers. : '''Materials Science''' β Predicting alloys, melting points, superconductivity transitions. : '''Meteorology''' β Atmospheric pressure, convection, hurricane formation. : '''Chemistry''' β Chemical equilibrium, protein folding, reaction rates. : '''Information Theory''' β Shannon entropy, data compression (mathematical cousin of physical entropy). </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information