**Computational Physics I FYS3150/FYS4150**, Department of Physics, University of Oslo, Norway

Date: **Fall semester 2019**

The Ising model is one of the most frequently used models of statistical mechanics. Recently, this model has also become widely studied in many other disciplines, including mathematics, statistics, biology, economy and sociology.

**For this project you can hand in collaborative reports and programs.**
This project (together with projects 3 and 4) counts 1/3 of the final mark.

The aim of this project is to use the Ising model from project 4 and apply it to the modeling of electoral patterns and social interactions. This project aims at studying the work of Katarzyna Sznajd-Weron and Jozef Sznajd, see also their published work in Int. J. Mod. Phys. C11,(2000) 1157.

We repeat In its simplest form the energy of the Ising model from project 4 without an externally applied magnetic field,

$$
E=-J\sum_{< kl >}^{N}s_ks_l
$$

with $s_k=\pm 1$. The quantity $N$ represents the total number of spins and $J$ is a coupling constant expressing the strength of the interaction between neighboring spins. The symbol $<kl>$ indicates that we sum over nearest neighbors only. ordering, viz $J> 0$.

We will consider as our model a community which time and again should take a stand in some matter, for example vote on a president in a two-party system. If each member of the community can take only two attitudes ($A$ or $B$) then in several votes one expects some difference $m$ of voters for $A$ and against. We assume three limiting cases:

all members of the community vote for $A$ (an

**all**$A$ state),all members of the community vote for $B$ (an

**all**$B$ state),$50\%$ vote for $A$ and $50\%$ vote for $B$,

where the latter is meant to be the stable solutions of our model.

The aim here is to analyze the time evolution of $m$. To model the above mentioned system we consider an Ising spins chain ($S_i;i=1,2,\ldots N$) with the following dynamic rules:

if $S_iS_{i+1}=1$ then $S_{i-1}$ and $S_{i+2}$ take the direction of the pair (i,i+1),

if $S_iS_{i+1}=-1$ then $S_{i-1}$ takes the direction of $S_{i+1}$ and $S_{i+2}$ the direction of $S_i$.

These rules describe the influence of a given pair on the decision of
its nearest neighbours. When members of a pair have the same opinion
then their nearest neighbours agree with them. On the contrary, when
members of a pair have opinions different then the nearest neighbour
of each member disagrees with her/him. These dynamic rules lead to
the three steady states above. However, the third steady state ($50\%$
for $A$ and $50\%$ for $B$) is realized in a very special way. Every
member of the community disagrees with her/his nearest neighbour (it
is easy to see that the Ising model with only next nearest neighbour
interaction has such fixed points: ferro- and antiferromagnetic
state). According to the authors of the above mentioned article,
this rule is in accordance with the well known sentence
*united we stand divided we fall* (USDF-model).

To investigate our model we perform a standard Monte Carlo simulation with random updating. Consider a chain of $N$ Ising spins with free boundary conditions. In our simulation you could use values from $N=1000$ up to $N=10000$. We start from a totally random initial state i.e. to each site of the chain we assign an arrow with a randomly chosen direction: up or down (Ising spin). Show that you obtain as a state, one of the three fixed points (1-3, i.e. AAAA, BBBB, ABAB) with probability 0.25,0.25 and 0.5, respectively. The typical relaxation time for $N=1000$ is $\sim 10^4$ Monte Carlo steps (MCS). Plot the spatial distribution of spins from the initial to a steady state and compare your results with figure 1 of Katarzyna Sznajd-Weron and Jozef Sznajd. Can you see whether there is a formation of clusters? Comment your results.

Let us define the decision as a magnetization, i.e.:

$$
\begin{equation}
m=\frac{1}{N}\sum_{i=1}^N S_i.
\label{em} \tag{1}
\end{equation}
$$

Compute the magnetization and compare your results with figure 2 of Katarzyna Sznajd-Weron and Jozef Sznajd.

Without any external stimulation decision can change dramatically in a relatively short time. Such strongly non-monotonic behaviour of the change of $m$ is typically observed in the USDF-model when the system evolves towards the third steady state (total disagreement or in magnetic language the antiferromagnetic state). Comment your results.

To measure the time correlation of $m$ one can employ the classical autocorrelation function:

$$
\begin{equation}
G(\Delta t) = \frac
{\sum \left( m(t)-<m>\right) \left( m(t+ \Delta t)- <m>\right)}
{\sum (m(t)-<m>)^2}.
\label{_auto1} \tag{2}
\end{equation}
$$

In the work of Sznajd-Weron and Snajzd, there is a comparison of simulation results with empirical data as shown in their figure 3. Make a plot similar to their figure 3 and comment your results. Following the changes of one particular individual, the dynamics seem to lead to some interesting effects. If an individual changes her/his opinion at time $t$ she/he will probably change it also at time $t+1$.

On the other hand an individual can stay for a long time without changing her/his decision. Let us denote by $\tau$ the time needed by an individual to change her/his opinion. From the autocorrelation function it can be seen that $\tau$ is usually very short, but sometimes can be very long. The distribution of $(\tau)$ ($P(\tau)$) follows seeminingly a power law behavior with an exponent $-3/2$. Plot this distribution and compare your results with figure 4 Sznajd-Weron and Snajzd. Comment your results.

We will now study the influence of the initial conditions on the evolution of the system by considering two different ways - randomly and in clusters. In both cases you could start from an initial concentration $c_B$ of opinion $B$. In the random setup $c_B*N$ individuals are randomly (uniformly) chosen out of all $N$ individuals. In the cluster setup simply the first $c_B*N$ individuals are chosen.

Study whether the distribution of decision time $\tau$ still follows the power law with the same exponent as you found in the previous part. A non-monotonic behaviour of decision change is still typical and sometimes even much stronger. However, it is obvious that if initially there is more $A$'s then $B$'s the final state should be more often "all $A$" then "all $B$". Compare your results to figure 5 of Sznajd-Weron and Snajzd and comment your results.

It is well known that the changes of opinion are determined by the social impact. Till now we have considered a community in which a change of an individuals opinion is caused only by a contact with its neighbours. It was the simplest social impact one can imagine. Now, we introduce to our model noise $p$, which is the probability that an individual, instead of following the dynamic rules, will make a random decision. We start from an "all $A$" state to investigate if there is a $p \in (0,1)$ which does not throw the system out of this state.

See if you can reproduce figures 6 and 7 of the above authors and comment your final results. Their discussion section contains several interesting observations you may consider discussing. The text by Serge Galam contains several other interesting obeservations which can be useful in the present analysi.

Here follows a brief recipe and recommendation on how to write a report for each project.

Give a short description of the nature of the problem and the eventual numerical methods you have used.

Describe the algorithm you have used and/or developed. Here you may find it convenient to use pseudocoding. In many cases you can describe the algorithm in the program itself.

Include the source code of your program. Comment your program properly.

If possible, try to find analytic solutions, or known limits in order to test your program when developing the code.

Include your results either in figure form or in a table. Remember to label your results. All tables and figures should have relevant captions and labels on the axes.

Try to evaluate the reliabilty and numerical stability/precision of your results. If possible, include a qualitative and/or quantitative discussion of the numerical stability, eventual loss of precision etc.

Try to give an interpretation of you results in your answers to the problems.

Critique: if possible include your comments and reflections about the exercise, whether you felt you learnt something, ideas for improvements and other thoughts you've made when solving the exercise. We wish to keep this course at the interactive level and your comments can help us improve it.

Try to establish a practice where you log your work at the computerlab. You may find such a logbook very handy at later stages in your work, especially when you don't properly remember what a previous test version of your program did. Here you could also record the time spent on solving the exercise, various algorithms you may have tested or other topics which you feel worthy of mentioning.

The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:

Use Devilry to hand in your projects, log in at http://devilry.ifi.uio.no with your normal UiO username and password and choose either 'fys3150' or 'fys4150'. There you can load up the files within the deadline.

Upload

**only**the report file! For the source code file(s) you have developed please provide us with your link to your github domain. The report file should include all of your discussions and a list of the codes you have developed. Do not include library files which are available at the course homepage, unless you have made specific changes to them.In your git repository, please include a folder which contains selected results. These can be in the form of output from your code for a selected set of runs and input parametxers.

In this and all later projects, you should include tests (for example unit tests) of your code(s).

Comments from us on your projects, approval or not, corrections to be made etc can be found under your Devilry domain and are only visible to you and the teachers of the course.

Finally, we encourage you to work two and two together. Optimal working groups consist of 2-3 students.