I wrote a code for ising model simulation which works but I want some help in optimizing it The Next CEO of Stack OverflowOptimizing code for UVAJ 573 The Snail
What happened in Rome, when the western empire "fell"?
Is there a difference between "Fahrstuhl" and "Aufzug"?
Is "three point ish" an acceptable use of ish?
Is it professional to write unrelated content in an almost-empty email?
Can I board the first leg of the flight without having final country's visa?
Traduction de « Life is a roller coaster »
What difference does it make using sed with/without whitespaces?
What flight has the highest ratio of timezone difference to flight time?
What CSS properties can the br tag have?
What steps are necessary to read a Modern SSD in Medieval Europe?
I dug holes for my pergola too wide
Example of a Mathematician/Physicist whose Other Publications during their PhD eclipsed their PhD Thesis
Help understanding this unsettling image of Titan, Epimetheus, and Saturn's rings?
How to Implement Deterministic Encryption Safely in .NET
Can someone explain this formula for calculating Manhattan distance?
AB diagonalizable then BA also diagonalizable
How did Beeri the Hittite come up with naming his daughter Yehudit?
Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank
what's the use of '% to gdp' type of variables?
Expressing the idea of having a very busy time
Does destroying a Lich's phylactery destroy the soul within it?
Is French Guiana a (hard) EU border?
What day is it again?
If Nick Fury and Coulson already knew about aliens (Kree and Skrull) why did they wait until Thor's appearance to start making weapons?
I wrote a code for ising model simulation which works but I want some help in optimizing it
The Next CEO of Stack OverflowOptimizing code for UVAJ 573 The Snail
$begingroup$
I have written this code to simulate Ising Model at one particular temperature in presence of magnetic field to observe hysteresis effect using the metropolis algorithm.
While the code runs and gave me a desired output, it is a badly written code(I feel so) because of my lack of coding experience. Could you help me out as to how could I have written this in a better way? Or what can I do to optimize it next time I write such a code? Or are there any inbuilt functions I could have called instead of writing a block?
P.S. I borrowed the random number generator directly from someone's answer to a thread on this site. I cannot find the exact thread, apologies! (I will cite it once I do)
I hope this kind of a question is allowed on this thread. Any help or resources would be appreciated.
//function to assign random spins to the lattice
int spin(int r)
int s;
if(r>5)
s=+1;
else
s=-1;
return s;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//random number generator
float prandom(int i,int N)
std::random_device rd; //Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
std::uniform_real_distribution<> dis(i,N);
// Use dis to transform the random unsigned int generated by gen into a
// double in [1, 2). Each call to dis(gen) generates a new random double
int t = dis(gen);
return t;
////////////////////////////////////////////////////////////////////////////
//frunction to randomly flip the spins
I am selecting a random site and seeing how the total energy will change by calculating the energy dE for the neighbouring sites. If the energy is negative then I make the spin flip permanent if it is not negative then I gave a probability exp(-dE) by which it can flip the spin
std::vector< std::vector < int > > flip (int N,std::vector< std::vector < int > >lattice, float beta,int tab[],float H)
int a =prandom(0,N);
int b =prandom(0,N);
int s=lattice[a][b];
float dE=(2*s*H)+(2*s*(lattice[tab[a+2]][b]+lattice[tab[a]][b]+lattice[a][tab[b+2]]+lattice[a][tab[b]]));
//std::cout<<dE<<"t"<<a<<"t"<<b<<"n";
if(dE<0)
s=-1*s;
else
float k = 1.0*prandom(0.0,1000)/1000;
float H = exp(-beta*dE);
if(k<=H)
s=-1*s;
else
s = 1*s;
lattice[a][b]=s;
return lattice;
////////////////////////////////////////////////////////////////////////////
// main program///////
int main()
std::ofstream outdata;
outdata.open("ising_model_field_final2.txt");
int a,b,N=20,i,j,k,r,t,sweep=1500;
float M=0,M_sweep=0,H=-0.10;
int tab[N];
tab[0] = N-1;
tab[N+1] = 0;
for (i=1;i<=N;i++)
tab[i]=i-1; // this is the periodic boundary condition to make my lattice infinite (lattice site [x][0] is a neighbour of [x][N] and so on..)
float T, beta;
//beta=1.0/T; // boltzman constant is assumed to be 1.
//creating a 2d lattice and populating it
std::vector< std::vector < int > >lattice;
//populate the lattice
for (i=0; i<N; i++)
std::vector< int > row; //create a row of the lattice
for (j=0;j<N;j++)
row.push_back(-1); //populate the row vector
lattice.push_back(row); //populate the column vector
lattice=flip(N,lattice,beta, tab,H);
/* for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
*/
///////////////////////////////////////////////////////////////////////////
//field control
for(int temp=1;temp<=30;temp++)
if(temp>15)
H=H-0.015;
else
H=H+0.015;
//M=0;
T=2.2;
beta=1.0/T;
///////////////////////////////////////////////////////////////////////////
//number of sweeps
std::cout<<beta<<"n";
for(i=0;i<=sweep;i++)
//T=0.1*i;
///////////////////////////////////////////////////////////////////////////
//Number of flips
//printf("Sweep = %dn",i);
for(j=1;j<=N*N;j++)
lattice=flip(N,lattice,beta, tab,H);
M_sweep=0;
for(t=0;t<N;t++)
for(int u=0;u<N;u++)
if(i>=500)
M_sweep=M_sweep+lattice[t][u];
//std::cout<<"Mag="<<M<<"t";
M=M+ M_sweep/(N*N);
//std::cout<<"Mag="<<M<<"t";
M=M/(sweep-1000);
std::cout<<T<<"n";
outdata << M <<"t"<< H <<"n";
////////////////////////////////////////////////////////////////////////////
//printing the output of 2d lattice
for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
outdata.close();
c++
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I have written this code to simulate Ising Model at one particular temperature in presence of magnetic field to observe hysteresis effect using the metropolis algorithm.
While the code runs and gave me a desired output, it is a badly written code(I feel so) because of my lack of coding experience. Could you help me out as to how could I have written this in a better way? Or what can I do to optimize it next time I write such a code? Or are there any inbuilt functions I could have called instead of writing a block?
P.S. I borrowed the random number generator directly from someone's answer to a thread on this site. I cannot find the exact thread, apologies! (I will cite it once I do)
I hope this kind of a question is allowed on this thread. Any help or resources would be appreciated.
//function to assign random spins to the lattice
int spin(int r)
int s;
if(r>5)
s=+1;
else
s=-1;
return s;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//random number generator
float prandom(int i,int N)
std::random_device rd; //Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
std::uniform_real_distribution<> dis(i,N);
// Use dis to transform the random unsigned int generated by gen into a
// double in [1, 2). Each call to dis(gen) generates a new random double
int t = dis(gen);
return t;
////////////////////////////////////////////////////////////////////////////
//frunction to randomly flip the spins
I am selecting a random site and seeing how the total energy will change by calculating the energy dE for the neighbouring sites. If the energy is negative then I make the spin flip permanent if it is not negative then I gave a probability exp(-dE) by which it can flip the spin
std::vector< std::vector < int > > flip (int N,std::vector< std::vector < int > >lattice, float beta,int tab[],float H)
int a =prandom(0,N);
int b =prandom(0,N);
int s=lattice[a][b];
float dE=(2*s*H)+(2*s*(lattice[tab[a+2]][b]+lattice[tab[a]][b]+lattice[a][tab[b+2]]+lattice[a][tab[b]]));
//std::cout<<dE<<"t"<<a<<"t"<<b<<"n";
if(dE<0)
s=-1*s;
else
float k = 1.0*prandom(0.0,1000)/1000;
float H = exp(-beta*dE);
if(k<=H)
s=-1*s;
else
s = 1*s;
lattice[a][b]=s;
return lattice;
////////////////////////////////////////////////////////////////////////////
// main program///////
int main()
std::ofstream outdata;
outdata.open("ising_model_field_final2.txt");
int a,b,N=20,i,j,k,r,t,sweep=1500;
float M=0,M_sweep=0,H=-0.10;
int tab[N];
tab[0] = N-1;
tab[N+1] = 0;
for (i=1;i<=N;i++)
tab[i]=i-1; // this is the periodic boundary condition to make my lattice infinite (lattice site [x][0] is a neighbour of [x][N] and so on..)
float T, beta;
//beta=1.0/T; // boltzman constant is assumed to be 1.
//creating a 2d lattice and populating it
std::vector< std::vector < int > >lattice;
//populate the lattice
for (i=0; i<N; i++)
std::vector< int > row; //create a row of the lattice
for (j=0;j<N;j++)
row.push_back(-1); //populate the row vector
lattice.push_back(row); //populate the column vector
lattice=flip(N,lattice,beta, tab,H);
/* for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
*/
///////////////////////////////////////////////////////////////////////////
//field control
for(int temp=1;temp<=30;temp++)
if(temp>15)
H=H-0.015;
else
H=H+0.015;
//M=0;
T=2.2;
beta=1.0/T;
///////////////////////////////////////////////////////////////////////////
//number of sweeps
std::cout<<beta<<"n";
for(i=0;i<=sweep;i++)
//T=0.1*i;
///////////////////////////////////////////////////////////////////////////
//Number of flips
//printf("Sweep = %dn",i);
for(j=1;j<=N*N;j++)
lattice=flip(N,lattice,beta, tab,H);
M_sweep=0;
for(t=0;t<N;t++)
for(int u=0;u<N;u++)
if(i>=500)
M_sweep=M_sweep+lattice[t][u];
//std::cout<<"Mag="<<M<<"t";
M=M+ M_sweep/(N*N);
//std::cout<<"Mag="<<M<<"t";
M=M/(sweep-1000);
std::cout<<T<<"n";
outdata << M <<"t"<< H <<"n";
////////////////////////////////////////////////////////////////////////////
//printing the output of 2d lattice
for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
outdata.close();
c++
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
add a comment |
$begingroup$
I have written this code to simulate Ising Model at one particular temperature in presence of magnetic field to observe hysteresis effect using the metropolis algorithm.
While the code runs and gave me a desired output, it is a badly written code(I feel so) because of my lack of coding experience. Could you help me out as to how could I have written this in a better way? Or what can I do to optimize it next time I write such a code? Or are there any inbuilt functions I could have called instead of writing a block?
P.S. I borrowed the random number generator directly from someone's answer to a thread on this site. I cannot find the exact thread, apologies! (I will cite it once I do)
I hope this kind of a question is allowed on this thread. Any help or resources would be appreciated.
//function to assign random spins to the lattice
int spin(int r)
int s;
if(r>5)
s=+1;
else
s=-1;
return s;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//random number generator
float prandom(int i,int N)
std::random_device rd; //Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
std::uniform_real_distribution<> dis(i,N);
// Use dis to transform the random unsigned int generated by gen into a
// double in [1, 2). Each call to dis(gen) generates a new random double
int t = dis(gen);
return t;
////////////////////////////////////////////////////////////////////////////
//frunction to randomly flip the spins
I am selecting a random site and seeing how the total energy will change by calculating the energy dE for the neighbouring sites. If the energy is negative then I make the spin flip permanent if it is not negative then I gave a probability exp(-dE) by which it can flip the spin
std::vector< std::vector < int > > flip (int N,std::vector< std::vector < int > >lattice, float beta,int tab[],float H)
int a =prandom(0,N);
int b =prandom(0,N);
int s=lattice[a][b];
float dE=(2*s*H)+(2*s*(lattice[tab[a+2]][b]+lattice[tab[a]][b]+lattice[a][tab[b+2]]+lattice[a][tab[b]]));
//std::cout<<dE<<"t"<<a<<"t"<<b<<"n";
if(dE<0)
s=-1*s;
else
float k = 1.0*prandom(0.0,1000)/1000;
float H = exp(-beta*dE);
if(k<=H)
s=-1*s;
else
s = 1*s;
lattice[a][b]=s;
return lattice;
////////////////////////////////////////////////////////////////////////////
// main program///////
int main()
std::ofstream outdata;
outdata.open("ising_model_field_final2.txt");
int a,b,N=20,i,j,k,r,t,sweep=1500;
float M=0,M_sweep=0,H=-0.10;
int tab[N];
tab[0] = N-1;
tab[N+1] = 0;
for (i=1;i<=N;i++)
tab[i]=i-1; // this is the periodic boundary condition to make my lattice infinite (lattice site [x][0] is a neighbour of [x][N] and so on..)
float T, beta;
//beta=1.0/T; // boltzman constant is assumed to be 1.
//creating a 2d lattice and populating it
std::vector< std::vector < int > >lattice;
//populate the lattice
for (i=0; i<N; i++)
std::vector< int > row; //create a row of the lattice
for (j=0;j<N;j++)
row.push_back(-1); //populate the row vector
lattice.push_back(row); //populate the column vector
lattice=flip(N,lattice,beta, tab,H);
/* for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
*/
///////////////////////////////////////////////////////////////////////////
//field control
for(int temp=1;temp<=30;temp++)
if(temp>15)
H=H-0.015;
else
H=H+0.015;
//M=0;
T=2.2;
beta=1.0/T;
///////////////////////////////////////////////////////////////////////////
//number of sweeps
std::cout<<beta<<"n";
for(i=0;i<=sweep;i++)
//T=0.1*i;
///////////////////////////////////////////////////////////////////////////
//Number of flips
//printf("Sweep = %dn",i);
for(j=1;j<=N*N;j++)
lattice=flip(N,lattice,beta, tab,H);
M_sweep=0;
for(t=0;t<N;t++)
for(int u=0;u<N;u++)
if(i>=500)
M_sweep=M_sweep+lattice[t][u];
//std::cout<<"Mag="<<M<<"t";
M=M+ M_sweep/(N*N);
//std::cout<<"Mag="<<M<<"t";
M=M/(sweep-1000);
std::cout<<T<<"n";
outdata << M <<"t"<< H <<"n";
////////////////////////////////////////////////////////////////////////////
//printing the output of 2d lattice
for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
outdata.close();
c++
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
$endgroup$
I have written this code to simulate Ising Model at one particular temperature in presence of magnetic field to observe hysteresis effect using the metropolis algorithm.
While the code runs and gave me a desired output, it is a badly written code(I feel so) because of my lack of coding experience. Could you help me out as to how could I have written this in a better way? Or what can I do to optimize it next time I write such a code? Or are there any inbuilt functions I could have called instead of writing a block?
P.S. I borrowed the random number generator directly from someone's answer to a thread on this site. I cannot find the exact thread, apologies! (I will cite it once I do)
I hope this kind of a question is allowed on this thread. Any help or resources would be appreciated.
//function to assign random spins to the lattice
int spin(int r)
int s;
if(r>5)
s=+1;
else
s=-1;
return s;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
//random number generator
float prandom(int i,int N)
std::random_device rd; //Will be used to obtain a seed for the random number engine
std::mt19937 gen(rd()); //Standard mersenne_twister_engine seeded with rd()
std::uniform_real_distribution<> dis(i,N);
// Use dis to transform the random unsigned int generated by gen into a
// double in [1, 2). Each call to dis(gen) generates a new random double
int t = dis(gen);
return t;
////////////////////////////////////////////////////////////////////////////
//frunction to randomly flip the spins
I am selecting a random site and seeing how the total energy will change by calculating the energy dE for the neighbouring sites. If the energy is negative then I make the spin flip permanent if it is not negative then I gave a probability exp(-dE) by which it can flip the spin
std::vector< std::vector < int > > flip (int N,std::vector< std::vector < int > >lattice, float beta,int tab[],float H)
int a =prandom(0,N);
int b =prandom(0,N);
int s=lattice[a][b];
float dE=(2*s*H)+(2*s*(lattice[tab[a+2]][b]+lattice[tab[a]][b]+lattice[a][tab[b+2]]+lattice[a][tab[b]]));
//std::cout<<dE<<"t"<<a<<"t"<<b<<"n";
if(dE<0)
s=-1*s;
else
float k = 1.0*prandom(0.0,1000)/1000;
float H = exp(-beta*dE);
if(k<=H)
s=-1*s;
else
s = 1*s;
lattice[a][b]=s;
return lattice;
////////////////////////////////////////////////////////////////////////////
// main program///////
int main()
std::ofstream outdata;
outdata.open("ising_model_field_final2.txt");
int a,b,N=20,i,j,k,r,t,sweep=1500;
float M=0,M_sweep=0,H=-0.10;
int tab[N];
tab[0] = N-1;
tab[N+1] = 0;
for (i=1;i<=N;i++)
tab[i]=i-1; // this is the periodic boundary condition to make my lattice infinite (lattice site [x][0] is a neighbour of [x][N] and so on..)
float T, beta;
//beta=1.0/T; // boltzman constant is assumed to be 1.
//creating a 2d lattice and populating it
std::vector< std::vector < int > >lattice;
//populate the lattice
for (i=0; i<N; i++)
std::vector< int > row; //create a row of the lattice
for (j=0;j<N;j++)
row.push_back(-1); //populate the row vector
lattice.push_back(row); //populate the column vector
lattice=flip(N,lattice,beta, tab,H);
/* for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
*/
///////////////////////////////////////////////////////////////////////////
//field control
for(int temp=1;temp<=30;temp++)
if(temp>15)
H=H-0.015;
else
H=H+0.015;
//M=0;
T=2.2;
beta=1.0/T;
///////////////////////////////////////////////////////////////////////////
//number of sweeps
std::cout<<beta<<"n";
for(i=0;i<=sweep;i++)
//T=0.1*i;
///////////////////////////////////////////////////////////////////////////
//Number of flips
//printf("Sweep = %dn",i);
for(j=1;j<=N*N;j++)
lattice=flip(N,lattice,beta, tab,H);
M_sweep=0;
for(t=0;t<N;t++)
for(int u=0;u<N;u++)
if(i>=500)
M_sweep=M_sweep+lattice[t][u];
//std::cout<<"Mag="<<M<<"t";
M=M+ M_sweep/(N*N);
//std::cout<<"Mag="<<M<<"t";
M=M/(sweep-1000);
std::cout<<T<<"n";
outdata << M <<"t"<< H <<"n";
////////////////////////////////////////////////////////////////////////////
//printing the output of 2d lattice
for(i=0;i<N;i++)
for(j=0;j<N;j++)
std::cout<<lattice[j][i]<<"t";
std::cout<<std::endl;
outdata.close();
c++
c++
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 2 mins ago
aargieeaargiee
1
1
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
aargiee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
add a comment |
0
active
oldest
votes
StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
);
);
, "mathjax-editing");
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "196"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
aargiee is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216607%2fi-wrote-a-code-for-ising-model-simulation-which-works-but-i-want-some-help-in-op%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
aargiee is a new contributor. Be nice, and check out our Code of Conduct.
aargiee is a new contributor. Be nice, and check out our Code of Conduct.
aargiee is a new contributor. Be nice, and check out our Code of Conduct.
aargiee is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Code Review Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f216607%2fi-wrote-a-code-for-ising-model-simulation-which-works-but-i-want-some-help-in-op%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
