T05.3(b) Rocio
the instruction for T05.3(b)is:
Write a computational program, which allows us to generate an arbitraty number of spins configurations for a certain pre-defined temperature.
first thing i did was defining the variables needed fot the ising model:
then, according to the previous results, calculate the probability of a +1 and -1 spin:
For the values that i choose for temperature, i got the following results for the probabilities:
this indicates that in the random generation of spins we should get a little bit more +1 spins than -1 spins.
To generate spins according to their probability, i generated a chain of random numbers between 0 and 1, and we sum this to the probability of getting a spin +1.
If we have a high probability of a +1 spin (for example 0.9) almost all the sums will be greater than 1, and also the other way around, of we have a low probability almost none of the sums will be greater than 1.
So If the result of the sum between probability and random decimal number is greater than 1 we assign the +1 value to the spin chain we are generating, if is not greater than 1, we assign -1. The code is as follows:
the result on generating spin chains was:
when we generate two different spins chains we can see that we do get a little bit mor +1 spins than -1 spins which is what the probability predicts.
Write a computational program, which allows us to generate an arbitraty number of spins configurations for a certain pre-defined temperature.
first thing i did was defining the variables needed fot the ising model:
For the values that i choose for temperature, i got the following results for the probabilities:
this indicates that in the random generation of spins we should get a little bit more +1 spins than -1 spins.
To generate spins according to their probability, i generated a chain of random numbers between 0 and 1, and we sum this to the probability of getting a spin +1.
If we have a high probability of a +1 spin (for example 0.9) almost all the sums will be greater than 1, and also the other way around, of we have a low probability almost none of the sums will be greater than 1.
So If the result of the sum between probability and random decimal number is greater than 1 we assign the +1 value to the spin chain we are generating, if is not greater than 1, we assign -1. The code is as follows:
when we generate two different spins chains we can see that we do get a little bit mor +1 spins than -1 spins which is what the probability predicts.





Thank you for posting. First comment I want to make:
ResponderBorrarWhen you define physical constants, parameters always state what units you are using. You did that in the case of temperature but neither in the case of the Boltzman constant, nor in the case of the magnetic permeability.
Second: Always try to avoid dimensional constants or parameters. In the present case, beta*mu is adimensional. So instead of defining values for the different constants you could just as well asign an adimensional value to bm = beta*mu.
The way you asign randomly +1 and -1 to each spin, is correct.
Thanks for the feedback, teacher!
Borrar