Ising model autocorrelation function calculation

Click For Summary
SUMMARY

The discussion focuses on calculating the autocorrelation function (ACF) for a 2D Ising model using Python and NumPy. The user encountered issues with their implementation, particularly with the variable naming, where 'act[]' was likely a typo instead of 'acf[]'. The suggested solution includes verifying the calculation on a smaller dataset before scaling up to ensure accuracy. The provided code snippet correctly follows the formula for ACF calculation, but attention to detail in variable names is crucial for successful execution.

PREREQUISITES
  • Understanding of the Ising model in statistical mechanics
  • Proficiency in Python programming
  • Familiarity with NumPy library for numerical computations
  • Knowledge of autocorrelation functions and their significance
NEXT STEPS
  • Review Python's NumPy documentation for advanced array operations
  • Study the Ising model's statistical properties and implications
  • Learn about autocorrelation function calculations in time series analysis
  • Experiment with smaller datasets to validate ACF calculations before scaling
USEFUL FOR

Researchers in statistical mechanics, physicists studying phase transitions, and data scientists analyzing time series data will benefit from this discussion.

yklee
Messages
1
Reaction score
0
Homework Statement
on going
Relevant Equations
$$c(t) = \langle A(t'+t) A(t) \rangle - \langle A \rangle^{2} = \frac{1}{t_{max}-t}\sum_{t'=0}^{t_{max}-t} A(t'+t)A(t) - \frac{1}{t_{max}-t}\sum_{t'=0}^{t_{max}-t}A(t'+t) \cdot \frac{1}{t_{max}-t} \sum_{t'=0}^{t_{max}-t}A(t)$$
Dear Mr. and Ms.,

I am trying to measure the autocorrelation functions of 2D ising model based on the equation given by
1659496169335.png

where A(t) denote a measure. I calculate a c(t) of magnetization. I calculated in this way

[CODE lang="python" title="acf"] data_path = f"../../trajectory/data.txt"
data = np.loadtxt(data_path)
Nsteps = len(data)
acf = np.zeros(Nsteps, float)
acf[0] = 1.000
for t in range(1,Nsteps):
value = np.mean(data[t:Nsteps]*data[:Nsteps-t]) - np.mean(data[t:Nsteps])*np.mean(data[:Nsteps-t])
act[t] = value[/CODE]

However, the results seems not good. Can you discuss the wrong part of my calculation?
 
Last edited:
Physics news on Phys.org
What is the act[] array? Everything else is acf. I am guessing this is a typo when you entered it here, as this should throw an error.

Other than that - a quick look at your code appears like it should replicate your formula.

Try running this on a small set of data, first - something that you could verify the result of. Then you can scale up to the full data.
 

Similar threads

Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 41 ·
2
Replies
41
Views
5K